public ActionResult Index(string stateId, string currentStepName, string[] selectedOptions) { // PRG (Post-Redirect-Get) pattern: make changes on the POST and then redirect to a GET // Load the state object var priorState = stateRepository.Load(stateId); // Check that it was loaded if (priorState != null) { // Check if the current step already exists in the state object. If it does, remove it if (priorState.StepResults.Any(x => x.StepName == currentStepName)) { priorState.StepResults.Remove(priorState.StepResults.Single(x => x.StepName == currentStepName)); } // Add the current step's data to the state object var newStepResult = new PizzaStepResult() { StepName = currentStepName }; if (selectedOptions != null) { newStepResult.SelectedOptions.AddRange(selectedOptions); } priorState.StepResults.Add(newStepResult); // Save the state object stateRepository.Save(priorState); } // Redirect back to the GET, passing the id of the current state return(RedirectToAction("Index", new { id = stateId })); }
public string ValidationErrorMessage(PizzaStepResult result) { if (result.SelectedOptions.Count == 0) { return("You must select at least one topping"); } throw new NotImplementedException(); }
public string ValidationErrorMessage(PizzaStepResult result) { return(""); }
public bool Validate(PizzaStepResult result) { return(true); }
public string ValidationErrorMessage(PizzaStepResult result) { throw new NotImplementedException(); }
public string ValidationErrorMessage(PizzaStepResult result) { return(replacedStep.ValidationErrorMessage(result)); }
public bool Validate(PizzaStepResult result) { return(replacedStep.Validate(result)); }
public bool Validate(PizzaStepResult result) { return(result.SelectedOptions.Count >= 1); }