Exemple #1
0
        public async Task <IActionResult> SavePlacementInformationAsync(PlacementInformationSaveViewModel viewModel)
        {
            await Validate(viewModel);

            if (!ModelState.IsValid)
            {
                return(View("PlacementInformation", viewModel));
            }

            var dto = _mapper.Map <PlacementInformationSaveDto>(viewModel);
            await _opportunityService.UpdateOpportunityItemAsync(dto);

            if (viewModel.OpportunityType == OpportunityType.ProvisionGap)
            {
                await _opportunityService.UpdateProvisionGapAsync(dto);
            }

            var opportunityItemCount = await _opportunityService.GetSavedOpportunityItemCountAsync(viewModel.OpportunityId);

            //if First Opp (saved opportunity items == 0) then LoadWhoIsEmployer else if referral then check answer of if ProvisionGap then OpportunityBasket
            return(opportunityItemCount == 0 ?
                   RedirectToRoute("GetOpportunityCompanyName", new { viewModel.OpportunityId, viewModel.OpportunityItemId })
                : viewModel.OpportunityType == OpportunityType.Referral ?
                   RedirectToRoute("GetCheckAnswers", new { viewModel.OpportunityItemId })
                    : await SaveCheckAnswers(viewModel.OpportunityId, viewModel.OpportunityItemId));
        }