Exemple #1
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var pizza = _service.GetPizza((int)id);

            if (pizza == null)
            {
                return(HttpNotFound());
            }
            if (!Request.IsAjaxRequest())
            {
                return(RedirectToAction("Index"));
            }
            ViewBag.Components        = _service.FindNotPizzaComponent(id);
            ViewBag.CurrentComponents = _service.FindComponents(id);
            var pizzaSizePrices = _service.GetPizzaSizePrices(id);
            var pizzaViewModel  = new PizzaViewModel()
            {
                ID             = pizza.ID,
                Name           = pizza.Name,
                PriceForSmall  = pizzaSizePrices[0].Price,
                PriceForMedium = pizzaSizePrices[1].Price,
                PriceForLarge  = pizzaSizePrices[2].Price
            };

            return(PartialView("_EditPartial", pizzaViewModel));
        }