public async Task <IActionResult> CreateProviderDetailAsync(CreateProviderDetailViewModel viewModel) { if (viewModel.IsSaveSection) { return(await PerformSaveSection(viewModel)); } if (!ModelState.IsValid) { return(View("ProviderDetail", viewModel)); } if (viewModel.IsSaveAndAddVenue) { var providerId = await _providerService.CreateProviderAsync(viewModel); return(RedirectToRoute("AddProviderVenue", new { providerId })); } if (!viewModel.IsCdfProvider) { return(RedirectToAction("SearchProvider")); } return(RedirectToAction(nameof(AddProviderDetail), new AddProviderViewModel { UkPrn = viewModel.UkPrn, Name = viewModel.Name })); }
public When_ProviderVenueQualificationService_Is_Called_With_New_Provider() { _providerService = Substitute.For <IProviderService>(); var providerVenueService = Substitute.For <IProviderVenueService>(); var providerQualificationService = Substitute.For <IProviderQualificationService>(); var qualificationRouteMappingService = Substitute.For <IQualificationRouteMappingService>(); var qualificationService = Substitute.For <IQualificationService>(); var routePathService = Substitute.For <IRoutePathService>(); _providerService.SearchAsync(10000001) .Returns((ProviderSearchResultDto)null); _providerService.CreateProviderAsync(Arg.Any <CreateProviderDetailViewModel>()).Returns(1); var providerVenueQualificationService = new ProviderVenueQualificationService ( _providerService, providerVenueService, providerQualificationService, qualificationService, routePathService, qualificationRouteMappingService ); var dtoList = new ValidProviderVenueQualificationDtoListBuilder().Build(); _results = providerVenueQualificationService.UpdateAsync(dtoList).GetAwaiter().GetResult(); }
public async Task <IActionResult> Create(ProviderItemViewModel providerModel) { if (ModelState.IsValid) { await _service.CreateProviderAsync(providerModel); return(RedirectToAction(nameof(Index))); } return(View(providerModel)); }
private async Task <int> CreateOrUpdateProviderAsync(ProviderVenueQualificationDto providerVenueQualification) { int providerId; var provider = await _providerService.SearchAsync(providerVenueQualification.UkPrn); if (provider == null) { //Create the new provider var createProviderViewModel = new CreateProviderDetailViewModel { UkPrn = providerVenueQualification.UkPrn, Name = providerVenueQualification.Name, DisplayName = !string.IsNullOrWhiteSpace(providerVenueQualification.DisplayName) ? providerVenueQualification.DisplayName : providerVenueQualification.Name, PrimaryContact = providerVenueQualification.PrimaryContact, PrimaryContactEmail = providerVenueQualification.PrimaryContactEmail, PrimaryContactPhone = providerVenueQualification.PrimaryContactPhone, SecondaryContact = providerVenueQualification.SecondaryContact, SecondaryContactEmail = providerVenueQualification.SecondaryContactEmail, SecondaryContactPhone = providerVenueQualification.SecondaryContactPhone, IsEnabledForReferral = providerVenueQualification.IsEnabledForReferral, IsCdfProvider = providerVenueQualification.IsCdfProvider, //NOTE: IsTLevelProvider needs to be set manually Source = Source }; providerId = await _providerService.CreateProviderAsync(createProviderViewModel); Debug.WriteLine($"Created provider with id {providerId} for UKPRN {providerVenueQualification.UkPrn}"); } else { //Update an existing provider providerId = provider.Id; var providerViewModel = await _providerService.GetProviderDetailByIdAsync(providerId); if (providerViewModel != null) { var providerValidator = ValidateProviderToUpdate(providerViewModel, providerVenueQualification); if (providerValidator.IsUpdated) { await _providerService.UpdateProviderDetailAsync(providerValidator .ProviderDetailViewModel); } } } return(providerId); }
public When_Provider_Controller_CreateProviderDetail_Is_Called_With_SubmitAction_SaveAndAddVenue() { _providerService = Substitute.For <IProviderService>(); var providerController = new ProviderController(_providerService, new MatchingConfiguration()); var controllerWithClaims = new ClaimsBuilder <ProviderController>(providerController).Build(); _providerService.CreateProviderAsync(Arg.Any <CreateProviderDetailViewModel>()) .Returns(1); _result = controllerWithClaims.CreateProviderDetailAsync(new CreateProviderDetailViewModel { SubmitAction = "SaveAndAddVenue" }).GetAwaiter().GetResult(); }