Example #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));
        }
Example #2
0
        public async Task <ActionResult> DispositionWithServices(OutcomeViewModel model, string submitAction, DosEndpoint?endpoint = null, DateTime?dosSearchTime = null)
        {
            ModelState.Clear();
            if (submitAction == "manualpostcode")
            {
                return(View("../Outcome/ChangePostcode", model));
            }
            var postcodeValidatorResponse = PostCodeAllowedValidator.IsAllowedPostcode(model.CurrentPostcode);

            if (postcodeValidatorResponse == PostcodeValidatorResponse.InvalidSyntax)
            {
                ModelState.AddModelError("CurrentPostcode", "Enter a valid postcode.");
                return(View("../Outcome/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("../Outcome/ChangePostcode", model));
            }

            model = PopulateCCGAndStp(model);

            if (postcodeValidatorResponse == PostcodeValidatorResponse.PostcodeNotFound)
            {
                if (model.IsEmergencyPrescriptionOutcome)
                {
                    return(View("../Pathway/EmergencyPrescriptionsOutOfArea", model));
                }

                return(View("../Outcome/OutOfArea", model));
            }

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

            var viewRouter = _viewRouter.Build(outcomeModel, ControllerContext);

            return(View(viewRouter.ViewName, outcomeModel));
        }