Ejemplo n.º 1
0
        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 }));
        }
Ejemplo n.º 2
0
 public string ValidationErrorMessage(PizzaStepResult result)
 {
     if (result.SelectedOptions.Count == 0)
     {
         return("You must select at least one topping");
     }
     throw new NotImplementedException();
 }
Ejemplo n.º 3
0
 public string ValidationErrorMessage(PizzaStepResult result)
 {
     return("");
 }
Ejemplo n.º 4
0
 public bool Validate(PizzaStepResult result)
 {
     return(true);
 }
Ejemplo n.º 5
0
 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));
 }
Ejemplo n.º 8
0
 public bool Validate(PizzaStepResult result)
 {
     return(result.SelectedOptions.Count >= 1);
 }