Example #1
0
        private PizzaListingModel BuildModel(OrderedPizza orderedPizza)
        {
            var sizes    = _sizeService.GetAll();
            var depths   = _depthService.GetAll();
            var toppings = _toppingService.GetAll();
            var model    = new PizzaListingModel
            {
                Sizes         = sizes,
                Depths        = depths,
                Toppings      = toppings,
                CustomerPizza = orderedPizza
            };

            return(model);
        }
Example #2
0
 public IActionResult Index(PizzaListingModel model)
 {
     // If there are errors e.g. no size/depth selected then re-display the Index with a new model
     if (model.SelectedSizeId != 0 && model.SelectedDepthId != 0)
     {
         // Build the pizza object based on Customer selections and display the prices
         var orderedPizza = BuildNewPizza(model.SelectedSizeId, model.SelectedDepthId, model.IsToppingChecked);
         var newmodel     = BuildModel(orderedPizza);
         return(View(newmodel));
     }
     else
     {
         model = BuildModel(new OrderedPizza());
         return(View(model));
     }
 }