public void ChemicalComposition_Post_BackToOverview_MaintainsRouteValue(bool? backToOverview) { var chemicalCompositionType = RadioButtonStringCollectionViewModel.CreateFromEnum<ChemicalComposition>(); chemicalCompositionType.SelectedValue = "Wood"; var model = new ChemicalCompositionTypeViewModel() { ChemicalCompositionType = chemicalCompositionType }; var result = chemicalCompositionController.Index(model, backToOverview) as RedirectToRouteResult; var backToOverviewKey = "backToOverview"; Assert.True(result.RouteValues.ContainsKey(backToOverviewKey)); Assert.Equal<bool?>(backToOverview.GetValueOrDefault(), ((bool?)result.RouteValues[backToOverviewKey]).GetValueOrDefault()); }
public void ChemicalComposition_Post_BackToOverview_MaintainsRouteValue(bool?backToOverview) { var chemicalCompositionType = RadioButtonStringCollectionViewModel.CreateFromEnum <ChemicalComposition>(); chemicalCompositionType.SelectedValue = "Wood"; var model = new ChemicalCompositionTypeViewModel() { ChemicalCompositionType = chemicalCompositionType }; var result = chemicalCompositionController.Index(model, backToOverview) as RedirectToRouteResult; var backToOverviewKey = "backToOverview"; Assert.True(result.RouteValues.ContainsKey(backToOverviewKey)); Assert.Equal <bool?>(backToOverview.GetValueOrDefault(), ((bool?)result.RouteValues[backToOverviewKey]).GetValueOrDefault()); }
public async Task <ActionResult> Index(Guid id, bool?backToOverview = null) { var model = new ChemicalCompositionTypeViewModel { NotificationId = id, ChemicalCompositionType = RadioButtonStringCollectionViewModel.CreateFromEnum <ChemicalComposition>() }; var wasteTypeData = await mediator.SendAsync(new GetWasteType(id)); if (wasteTypeData != null) { model.ChemicalCompositionType.SelectedValue = Prsd.Core.Helpers.EnumHelper.GetDisplayName(wasteTypeData.ChemicalCompositionType); } return(View(model)); }
public ActionResult Index(ChemicalCompositionTypeViewModel model, bool?backToOverview = null) { if (!ModelState.IsValid) { return(View(model)); } switch (model.ChemicalCompositionType.SelectedValue) { case "Solid recovered fuel (SRF)": return(RedirectToAction("Parameters", new { id = model.NotificationId, chemicalCompositionType = ChemicalComposition.SRF, backToOverview })); case "Refuse derived fuel (RDF)": return(RedirectToAction("Parameters", new { id = model.NotificationId, chemicalCompositionType = ChemicalComposition.RDF, backToOverview })); case "Wood": return(RedirectToAction("Parameters", new { id = model.NotificationId, chemicalCompositionType = ChemicalComposition.Wood, backToOverview })); default: return(RedirectToAction("OtherWaste", new { id = model.NotificationId, chemicalCompositionType = ChemicalComposition.Other, backToOverview })); } }