FritzAndFriends / ResourceManagement

A resource management application originally designed for Sebastian Riding Associates.
MIT License
35 stars 28 forks source link

Migrate Blazor components to ComponentBase style ViewModels #72

Open csharpfritz opened 5 years ago

csharpfritz commented 5 years ago

DayPickerViewModel is a good example of using this technique

SimonGeering commented 5 years ago

@csharpfritz I can have a crack at this if you like?

csharpfritz commented 5 years ago

Assigned to you @SimonGeering

SimonGeering commented 5 years ago

@csharpfritz As it stands the dev branch gives the following error if you pull a clean fork, run the restoreDb.cmd and register a user:

WASM: Unhandled exception rendering component:
WASM: System.NullReferenceException: Object reference not set to an instance of an object.
WASM:   at Fritz.ResourceManagement.WebClient.Pages.DayView.<OnInit>b__20_0 (System.Object o, Fritz.ResourceManagement.WebClient.Data.ScheduleState+SelectedDateChangedArgs args) <0x2490510 + 0x0005a> in <97b570a6db5944e68f9c37c0d3aaea0f>:0 
WASM:   at (wrapper delegate-invoke) System.EventHandler`1[Fritz.ResourceManagement.WebClient.Data.ScheduleState+SelectedDateChangedArgs].invoke_void_object_TEventArgs(object,Fritz.ResourceManagement.WebClient.Data.ScheduleState/SelectedDateChangedArgs)
WASM:   at Fritz.ResourceManagement.WebClient.Data.ScheduleState.SelectDate (System.DateTime newDate) <0x248ff90 + 0x0007e> in <97b570a6db5944e68f9c37c0d3aaea0f>:0 
WASM:   at Fritz.ResourceManagement.WebClient.ViewModels.AvailabilityViewModel.OnInitAsync (System.Security.Claims.ClaimsPrincipal user) <0x2363920 + 0x001f0> in <97b570a6db5944e68f9c37c0d3aaea0f>:0 
WASM:   at Fritz.ResourceManagement.WebClient.Pages.Availability.OnInitAsync () <0x2362b48 + 0x00246> in <97b570a6db5944e68f9c37c0d3aaea0f>:0 
WASM:   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync () <0x1ebe718 + 0x00182> in <b9c0a2e1f675400685e6d6841f63a5eb>:0 
WASM:   at Microsoft.AspNetCore.Components.Rendering.Renderer.GetErrorHandledTask (System.Threading.Tasks.Task taskToHandle) <0x21000c0 + 0x00100> in <b9c0a2e1f675400685e6d6841f63a5eb>:0 

I could either: A) Continue with this refactoring without the ability to run and dev test this, relying on the compiler mainly since the unit tests don't have the coverage needed in the UI layer to be of much reassurance. This may need some considerable TLC on merging the PR, as was the case when we did the merge of the initial ViewModel changes without being able to dev test!

B) Wait for you to fix the above bug and/or improve the "I'm a new contributor experience" when first doing a GitClone of a fork - further to my points in #42 so the app runs and a test account can be logged into based on some instructions in readme.md

Let me know which way you would like to proceed, please.

SimonGeering commented 5 years ago

Additionally in terms of solution structure and layout - would we want to remove the ViewModel folder and instead move to a more functional file structure by adding, for each razor file, a corresponding xxx.Component.cs file in the Pages folder?

This would help group code by functional area in one place, similar to the Angular feature-based naming structure

GoranHalvarsson commented 5 years ago

@SimonGeering try to do a ef migration. It should fix your error

SimonGeering commented 5 years ago

It looks like the fixes that were added on stream for the preview 8 update will un-block this. I will pick it up after that is PR to the main repo