public ActionResult UpdateDelineationGeometry(UpdateDelineationGeometryViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                var viewData = new UpdateDelineationGeometryViewData(CurrentPerson, null, null, CurrentPerson.GetStormwaterJurisdictionsPersonCanView());
                return(RazorPartialView <UpdateDelineationGeometryErrors, UpdateDelineationGeometryViewData, UpdateDelineationGeometryViewModel>(viewData, viewModel));
            }

            viewModel.UpdateModel(CurrentPerson);

            var stormwaterJurisdictionID = viewModel.StormwaterJurisdictionID.GetValueOrDefault();
            var treatmentBMPAKs          = HttpRequestStorage.DatabaseEntities.DelineationStagings.Select(x => new { x.TreatmentBMPName, StormwaterJurisdictionID = stormwaterJurisdictionID });

            var treatmentBMPsWithUpstreamBMPAlreadySet = HttpRequestStorage.DatabaseEntities.TreatmentBMPs.Where(x =>
                                                                                                                 treatmentBMPAKs.Contains(new { x.TreatmentBMPName, x.StormwaterJurisdictionID })).Where(x => x.UpstreamBMPID != null);

            if (treatmentBMPsWithUpstreamBMPAlreadySet.Any())
            {
                var namesOfInvalidBMPs = treatmentBMPsWithUpstreamBMPAlreadySet.Select(x => x.TreatmentBMPName);

                namesOfInvalidBMPs.ToList().ForEach(x =>
                {
                    ModelState.AddModelError("Upstream BMP", $"Treatment BMP:{x} has an Upstream BMP and cannot accept delineations. Please either remove this Treatment BMP from your file or remove the Upstream BMP from the Treatment BMP and try again.");
                });
                var viewData = new UpdateDelineationGeometryViewData(CurrentPerson, null, null, CurrentPerson.GetStormwaterJurisdictionsPersonCanView());
                return(RazorPartialView <UpdateDelineationGeometryErrors, UpdateDelineationGeometryViewData,
                                         UpdateDelineationGeometryViewModel>(viewData, viewModel));
            }

            return(RedirectToAction(new SitkaRoute <DelineationUploadController>(c => c.ApproveDelineationGisUpload())));
        }
        private ViewResult ViewUpdateDelineationGeometry(UpdateDelineationGeometryViewModel viewModel)
        {
            var newGisUploadUrl = SitkaRoute <DelineationUploadController> .BuildUrlFromExpression(c => c.UpdateDelineationGeometry());

            var approveGisUploadUrl = SitkaRoute <DelineationUploadController> .BuildUrlFromExpression(c => c.ApproveDelineationGisUpload());

            var viewData = new UpdateDelineationGeometryViewData(CurrentPerson, newGisUploadUrl, approveGisUploadUrl, CurrentPerson.GetStormwaterJurisdictionsPersonCanView());

            return(RazorView <UpdateDelineationGeometry, UpdateDelineationGeometryViewData, UpdateDelineationGeometryViewModel>(viewData, viewModel));
        }