コード例 #1
0
        public async Task <ActionResult> DispositionWithServices(OutcomeViewModel model, string submitAction, DosEndpoint?endpoint = null)
        {
            var postcodeValidatorResponse = _postCodeAllowedValidator.IsAllowedPostcode(model.CurrentPostcode);

            model.UserInfo.CurrentAddress.IsInPilotArea = postcodeValidatorResponse == PostcodeValidatorResponse.InPathwaysArea;
            if (postcodeValidatorResponse == PostcodeValidatorResponse.InvalidSyntax)
            {
                ModelState.AddModelError("CurrentPostcode", "Enter a valid postcode.");
                return(View("ChangePostcode", model));
            }
            if (postcodeValidatorResponse == PostcodeValidatorResponse.PostcodeNotFound)
            {
                ModelState.AddModelError("CurrentPostcode", "We can't find any services in '" + model.CurrentPostcode + "'. Check the postcode is correct.");
                return(View("ChangePostcode", model));
            }
            model.UserInfo.CurrentAddress.IsInPilotArea = _postCodeAllowedValidator.IsAllowedPostcode(model.CurrentPostcode) == PostcodeValidatorResponse.InPathwaysArea;
            var viewName = "ChangePostcode";

            if (submitAction == "manualpostcode")
            {
                return(View(viewName, model));
            }
            if (!model.UserInfo.CurrentAddress.IsInPilotArea)
            {
                return(View("OutOfArea", model));
            }

            var outcomeModel = await _outcomeViewModelBuilder.PopulateGroupedDosResults(model, null, null, endpoint);

            viewName = _viewRouter.GetViewName(model, ControllerContext);

            return(View(viewName, outcomeModel));
        }
コード例 #2
0
        public ActionResult FindByAddress(ConfirmLocationViewModel model)
        {
            ModelState.Clear();
            var postcodeValidationRepsonse = _postCodeAllowedValidator.IsAllowedPostcode(model.SelectedPostcode);

            return(DeriveApplicationView(model, postcodeValidationRepsonse, _postCodeAllowedValidator.CcgModel));
        }
コード例 #3
0
        public async Task <ActionResult> ServiceList(OutcomeViewModel model, [FromUri] DateTime?overrideDate, [FromUri] bool?overrideFilterServices)
        {
            if (!ModelState.IsValidField("UserInfo.CurrentAddress.PostCode"))
            {
                return(View(Path.GetFileNameWithoutExtension(model.CurrentView), model));
            }

            if (!_postCodeAllowedValidator.IsAllowedPostcode(model.UserInfo.CurrentAddress.Postcode))
            {
                ModelState.AddModelError("UserInfo.CurrentAddress.Postcode", "Sorry, this service is not currently available in your area.  Please call NHS 111 for advice now");
                return(View(Path.GetFileNameWithoutExtension(model.CurrentView), model));
            }

            model.DosCheckCapacitySummaryResult = await GetServiceAvailability(model, overrideDate, overrideFilterServices.HasValue?overrideFilterServices.Value : model.FilterServices);

            await _auditLogger.LogDosResponse(model);

            if (model.DosCheckCapacitySummaryResult.Error == null && !model.DosCheckCapacitySummaryResult.ResultListEmpty)
            {
                return(View("ServiceList", model));
            }

            return(View(Path.GetFileNameWithoutExtension(model.CurrentView), model));
        }
コード例 #4
0
 public bool IsPostcodeInArea(string postcode)
 {
     return(PostCodeAllowedValidator.IsAllowedPostcode(postcode).IsInAreaForOutcome());
 }
コード例 #5
0
        public async Task <ActionResult> Outcome(OutcomeViewModel model, [FromUri] DateTime?overrideDate, [FromUri] bool?overrideFilterServices)
        {
            const string outcomeView  = "Outcome";
            const string servicesView = "Services";

            if (!ModelState.IsValidField("UserInfo.CurrentAddress.PostCode"))
            {
                return(View("Postcode", model));
            }

            var dosViewModel = Mapper.Map <DosViewModel>(model);

            if (overrideDate.HasValue)
            {
                dosViewModel.DispositionTime = overrideDate.Value;
            }

            if (string.IsNullOrEmpty(model.UserInfo.CurrentAddress.Postcode))
            {
                await _auditLogger.LogEventData(model, "User did not enter a postcode");

                return(View(_viewRouter.GetOutcomeViewPath(model, ControllerContext, outcomeView), model));
            }

            model.UserInfo.CurrentAddress.IsInPilotArea = _postCodeAllowedValidator.IsAllowedPostcode(model.UserInfo.CurrentAddress.Postcode);

            if (!model.UserInfo.CurrentAddress.IsInPilotArea)
            {
                await _auditLogger.LogEventData(model, "User entered a postcode outside of pilot area");

                return(View(_viewRouter.GetOutcomeViewPath(model, ControllerContext, outcomeView), model));
            }

            await _auditLogger.LogDosRequest(model, dosViewModel);

            model.DosCheckCapacitySummaryResult = await _dosBuilder.FillCheckCapacitySummaryResult(dosViewModel, overrideFilterServices.HasValue?overrideFilterServices.Value : model.FilterServices);

            model.DosCheckCapacitySummaryResult.ServicesUnavailable = model.DosCheckCapacitySummaryResult.ResultListEmpty;
            await _auditLogger.LogDosResponse(model);

            if (model.DosCheckCapacitySummaryResult.Error == null && !model.DosCheckCapacitySummaryResult.ResultListEmpty)
            {
                if (model.UserInfo.CurrentAddress.IsPostcodeFirst)
                {
                    return(View(_viewRouter.GetOutcomeViewPath(model, ControllerContext, outcomeView), model));
                }
                else
                {
                    return(View(_viewRouter.GetOutcomeViewPath(model, ControllerContext, servicesView), model));
                }
            }
            else if (model.DosCheckCapacitySummaryResult.Error != null || model.DosCheckCapacitySummaryResult.ResultListEmpty)
            {
                return(View(_viewRouter.GetOutcomeViewPath(model, ControllerContext, outcomeView), model));
            }
            else
            {
                //present screen with validation errors
                return(View(_viewRouter.GetOutcomeViewPath(model, ControllerContext, outcomeView), model));
            }
        }