From c08803930859d7251112f7d9fe1b3fc159b46d59 Mon Sep 17 00:00:00 2001 From: Ivan Lieckens Date: Fri, 29 Nov 2024 17:18:37 +0100 Subject: [PATCH] Fixed additional partial application updates --- .../Apply/ApplicationFormViewComponent.cs | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/headapps/MvpSite/MvpSite.Rendering/ViewComponents/Apply/ApplicationFormViewComponent.cs b/headapps/MvpSite/MvpSite.Rendering/ViewComponents/Apply/ApplicationFormViewComponent.cs index 49f33221..b8ef4a5f 100644 --- a/headapps/MvpSite/MvpSite.Rendering/ViewComponents/Apply/ApplicationFormViewComponent.cs +++ b/headapps/MvpSite/MvpSite.Rendering/ViewComponents/Apply/ApplicationFormViewComponent.cs @@ -310,12 +310,9 @@ private async Task ExecuteMvpTypeStep(ApplicationFormModel model) { if (model.CurrentApplication != null) { - Application updateApplication = new(model.CurrentApplication.Id) - { - MvpType = new MvpType(model.MvpTypeId) - }; + model.CurrentApplication.MvpType = new MvpType(model.MvpTypeId); Response applicationResponse = - await Client.UpdateApplicationAsync(updateApplication); + await Client.UpdateApplicationAsync(model.CurrentApplication); if (applicationResponse is { StatusCode: HttpStatusCode.OK, Result: not null }) { model.CurrentApplication = applicationResponse.Result; @@ -364,16 +361,13 @@ private async Task ExecuteMvpTypeStep(ApplicationFormModel model) private async Task ExecuteObjectivesStep(ApplicationFormModel model) { - if (model.IsNavigation.HasValue && !model.IsNavigation.Value && !string.IsNullOrWhiteSpace(model.Eligibility) && !string.IsNullOrWhiteSpace(model.Objectives)) + if (model.IsNavigation.HasValue && !model.IsNavigation.Value && !string.IsNullOrWhiteSpace(model.Eligibility) && !string.IsNullOrWhiteSpace(model.Objectives) && model.CurrentApplication != null) { - Application updateApplication = new(model.CurrentApplication!.Id) - { - Eligibility = model.Eligibility, - Objectives = model.Objectives, - Mentor = model.Mentors - }; + model.CurrentApplication.Eligibility = model.Eligibility; + model.CurrentApplication.Objectives = model.Objectives; + model.CurrentApplication.Mentor = model.Mentors; Response applicationResponse = - await Client.UpdateApplicationAsync(updateApplication); + await Client.UpdateApplicationAsync(model.CurrentApplication); if (applicationResponse is { StatusCode: HttpStatusCode.OK, Result: not null }) { model.CurrentApplication = applicationResponse.Result; @@ -568,13 +562,10 @@ private async Task ExecuteConfirmationStep(ApplicationFormModel model) private async Task ExecuteSubmittedStep(ApplicationFormModel model) { - if (model.IsNavigation.HasValue && !model.IsNavigation.Value) + if (model.IsNavigation.HasValue && !model.IsNavigation.Value && model.CurrentApplication != null) { - Application updateApplication = new(model.CurrentApplication!.Id) - { - Status = ApplicationStatus.Open - }; - Response applicationResponse = await Client.UpdateApplicationAsync(updateApplication); + model.CurrentApplication.Status = ApplicationStatus.Open; + Response applicationResponse = await Client.UpdateApplicationAsync(model.CurrentApplication); if (applicationResponse is { StatusCode: HttpStatusCode.OK, Result: not null }) { model.CurrentApplication = applicationResponse.Result;