private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (PathTextBox.Text != "")
            {
                PizzaModel model = new PizzaModel()
                {
                    Name        = NameTextBox.Text,
                    Price       = decimal.Parse(PriceTextBox.Text),
                    Description = DescriptionTextBox.Text,
                    Image       = ImageToBase64(PathTextBox.Text)
                };

                HttpWebRequest httpWebRequest = WebRequest.CreateHttp($"https://localhost:44361/api/pizzas/add/{admin.Login}:{admin.Password}");
                httpWebRequest.Method      = "POST";
                httpWebRequest.ContentType = "application/json";



                using (Stream stream = httpWebRequest.GetRequestStream())
                {
                    using (StreamWriter writer = new StreamWriter(stream))
                    {
                        writer.Write(JsonConvert.SerializeObject(model));
                    }
                }
                string      response = "";
                WebResponse web      = httpWebRequest.GetResponse();
                using (Stream stream = web.GetResponseStream())
                {
                    StreamReader reader = new StreamReader(stream);
                    response = reader.ReadToEnd();
                }
            }
            this.NavigationService.GoBack();
        }
        public IActionResult AddToCart(int?id, bool maso, bool lychok, bool tomats, string centimeter, int count)
        {
            if (centimeter is null)
            {
                return(Content("Выберите длнну пиццы."));
            }
            if (count == 0)
            {
                return(Content("Выберите кол-во пицц."));
            }
            var        cart        = SessionHelper.GetObjectFromJson <List <PizzaModel> >(HttpContext.Session, "cart");
            int        centimeters = Convert.ToInt32(centimeter);
            PizzaModel currModel   = new PizzaModel {
                Id = Startup._cartPosition++, Pizza = new MyDbContext().AllPizzas.First(x => x.Id == (int)id), Centimeters = centimeters, Meat = maso, Onion = lychok, Tomatoes = tomats, Amount = count
            };

            if (cart == null)
            {
                List <PizzaModel> newCart = new();
                newCart.Add(currModel);
                SessionHelper.SetObjectAsJson(HttpContext.Session, "cart", newCart);
            }
            else
            {
                cart.Add(new PizzaModel {
                    Pizza = new MyDbContext().AllPizzas.First(x => x.Id == (int)id), Centimeters = centimeters, Meat = maso, Onion = lychok, Tomatoes = tomats, Amount = count
                });
                SessionHelper.SetObjectAsJson(HttpContext.Session, "cart", cart);
            }
            return(RedirectToAction("Cart"));
        }
        public IActionResult Buy(string id)
        {
            PizzaModel pizzaModel = new PizzaModel();

            if (SessionHelper.GetObjectFromJson <List <CartItem> >(HttpContext.Session, "cart") == null)
            {
                List <CartItem> cart = new List <CartItem>();
                cart.Add(new CartItem {
                    Pizza = pizzaModel.find(id), Quantity = 1
                });
                SessionHelper.SetObjectAsJson(HttpContext.Session, "cart", cart);
            }
            else
            {
                List <CartItem> cart  = SessionHelper.GetObjectFromJson <List <CartItem> >(HttpContext.Session, "cart");
                int             index = isExist(id);
                if (index != -1)
                {
                    cart[index].Quantity++;
                }
                else
                {
                    cart.Add(new CartItem {
                        Pizza = pizzaModel.find(id), Quantity = 1
                    });
                }
                SessionHelper.SetObjectAsJson(HttpContext.Session, "cart", cart);
            }
            return(RedirectToAction("Index"));
        }
Exemple #4
0
        public void ValidarPrecioTamanioExtraGrande()
        {
            PizzaModel modelo    = new PizzaModel();
            int        resultado = modelo.getTamanoPrice("extra");

            Assert.AreEqual(resultado, 6000);
        }
        public ActionResult ConfirmPizza(int?store, int?pan, int?crust, int?pizza)
        {
            ViewBag.StoreId = store;
            ViewBag.PanId   = pan;
            ViewBag.CrustId = crust;
            ViewBag.PizzaId = pizza;

            PizzaModel pm = new PizzaModel
            {
                pizzaId    = ViewBag.PizzaId,
                crustId    = ViewBag.CrustId,
                panId      = ViewBag.PanId,
                PanSize    = _repository.GetPanSizeById(ViewBag.PanId).Size,
                PanPrice   = _repository.GetPanSizeById(ViewBag.PanId).Price,
                CrustName  = _repository.GetCrustTypeById(ViewBag.CrustId).CrustName,
                CrustPrice = _repository.GetCrustTypeById(ViewBag.CrustId).Price,
                PizzaName  = _repository.OurPizzaById(ViewBag.PizzaId).PizzaName,
                PizzaPrice = _repository.OurPizzaById(ViewBag.PizzaId).Price
            };


            pizzaList.Add(pm);

            OrderViewModel orderVM = new OrderViewModel
            {
                Storeid       = ViewBag.StoreId,
                PizzasOrdered = pizzaList
            };

            return(View(orderVM));
        }
Exemple #6
0
        public void ValidarPrecioMasaCrunchy()
        {
            PizzaModel modelo    = new PizzaModel();
            int        resultado = modelo.getMasaPrice("crunchy");

            Assert.AreEqual(resultado, 1500);
        }
Exemple #7
0
        public void ValidarPrecioTamanioPequeno()
        {
            PizzaModel modelo    = new PizzaModel();
            int        resultado = modelo.getTamanoPrice("pequena");

            Assert.AreEqual(resultado, 4000);
        }
Exemple #8
0
        /// <summary>
        /// Deletes pizza with specific id from database
        /// </summary>
        /// <param name="pizzaId">identifier of pizza</param>
        /// <returns>Result of status Deleted or Error</returns>
        public async Task <IServiceResult> DeleteAsync(int pizzaId)
        {
            try
            {
                // get pizza to delete
                PizzaModel pizza = await GetPizzaById(pizzaId);

                if (pizza != null)
                {
                    // delete the pizza and save context changes
                    _repository.Pizzas.Delete(pizza);
                    await _repository.SaveChangesAsync();

                    return(new ServiceResult(ResultType.Deleted));
                }

                return(new ServiceResult(ResultType.Error, new List <string> {
                    $"Cannot delete pizza with id {pizzaId}"
                }));
            }
            catch (Exception e)
            {
                // catch exception and pass errors to controller
                return(new ServiceResult(ResultType.Error, new List <string> {
                    e.Message
                }));
            }
        }
Exemple #9
0
        /// <summary>
        /// Updates total price of pizza. The total price is based on stater price and included ingredients prices.
        /// </summary>
        /// <param name="pizzaId">id of pizza </param>
        /// <returns>Updated pizza model</returns>
        public async Task <IServiceResult <PizzaModel> > UpdatePriceAsync(int pizzaId)
        {
            try
            {
                // get pizza with id value of pizzaId
                PizzaModel pizza = await GetPizzaById(pizzaId);

                // if pizza was found
                if (pizza != null)
                {
                    // update price and save context changes
                    UpdateTotalPizzaPrices(pizza);
                    _repository.Pizzas.Update(pizza);

                    return(new ServiceResult <PizzaModel>(ResultType.Correct, pizza));
                }

                return(new ServiceResult <PizzaModel>(ResultType.Error, new List <string> {
                    $"Pizza with id {pizzaId} was not found"
                }));
            }
            catch (Exception e)
            {
                // catch exception and pass errors to controller
                return(new ServiceResult <PizzaModel>(ResultType.Error, new List <string> {
                    e.Message
                }));
            }
        }
Exemple #10
0
        /// <summary>
        /// Pizza stored with name passed by parameter
        /// </summary>
        /// <param name="name">name of pizza</param>
        /// <returns>Pizza to return object with specific name</returns>
        public async Task <IServiceResult <PizzaToReturnDto> > GetByNameAsync(string name)
        {
            try
            {
                // get pizza that have name equal parameter value
                PizzaModel pizza = await GetPizzasByName(name);

                if (pizza != null)
                {
                    // convert it to object to retun
                    PizzaToReturnDto pizzaToReturn = CreatePizzaToReturn(pizza);

                    // return converted pizza objects
                    return(new ServiceResult <PizzaToReturnDto>(ResultType.Correct, pizzaToReturn));
                }

                // pass error if pizzas with this name was not found in database
                return(new ServiceResult <PizzaToReturnDto>(ResultType.Error, new List <string> {
                    $"Pizzas with name: {name} were not found"
                }));
            }
            catch (Exception e)
            {
                // catch exception and pass errors to controller
                return(new ServiceResult <PizzaToReturnDto>(ResultType.Error, new List <string> {
                    e.Message
                }));
            }
        }
Exemple #11
0
        /// <summary>
        /// Creates new pizza in database
        /// </summary>
        /// <param name="pizzaToCreate">data of pizza to be created</param>
        /// <returns>Pizza data to return or errors that occured during creation (depending on returned ServiceResult state)</returns
        public async Task <IServiceResult <PizzaToReturnDto> > CreateAsync(PizzaToCreateDto pizzaToCreate)
        {
            try
            {
                PizzaModel nameUsed = await GetPizzasByName(pizzaToCreate.Name);

                if (nameUsed == null)
                {
                    PizzaModel createdPizza = await CreatePizza(pizzaToCreate);

                    PizzaToReturnDto pizzaToReturn = CreatePizzaToReturn(createdPizza);

                    return(new ServiceResult <PizzaToReturnDto>(ResultType.Created, pizzaToReturn));
                }

                return(new ServiceResult <PizzaToReturnDto>(ResultType.Error, new List <string> {
                    $"Pizza name: {pizzaToCreate.Name} is already taken"
                }));
            }
            catch (Exception e)
            {
                return(new ServiceResult <PizzaToReturnDto>(ResultType.Error, new List <string> {
                    e.Message
                }));
            }
        }
Exemple #12
0
        /* public void UpdateCart(OrderModel cart, int oid){
         *
         * List<OrderModel> orders = db.Order.Where(o => o.Placed == false).ToList();
         *
         * Console.WriteLine("UPDATECART CARTCOUNT: " + cart.Pizzas.Count);
         *
         * if (orders.Count == 0){
         *
         *  Console.WriteLine("PIZZAS IN CART: " + cart.Pizzas.Count);
         *  PlaceOrder(cart);
         *  foreach(PizzaModel pizza in cart.Pizzas){
         *
         *    if (db.OrderPizzas.Where(p => p.PizzaId == pizza.Id).ToList().Count == 0){ //If order not in junction table, add order to junction table
         *
         *      db.OrderPizzas.Add(new OrderPizzas() {Pizza = pizza, Order = cart});
         *
         *    }
         *
         *  }
         *
         *  db.SaveChanges();
         *
         * } else {
         *
         *  for (int i = 0; i < cart.Pizzas.Count - orders[0].Pizzas.Count; i++){
         *    orders[0].Pizzas.Add(cart.Pizzas[cart.Pizzas.Count + i]);
         *  }
         *
         * }
         *
         * } */

        public void AddPizzaToCart(PizzaModel pizza, int orderId)
        {
            OrderModel cart = db.Order.FirstOrDefault(o => o.Id == orderId);

            List <PizzaModel>  pizzas2      = new List <PizzaModel>();
            List <OrderPizzas> orderPizzas2 = db.OrderPizzas.Where(op => op.OrderId == orderId).Include("Pizza.Crust").Include("Pizza.Size").ToList();

            foreach (OrderPizzas orderPizza in orderPizzas2)
            {
                PizzaModel           pizza3        = orderPizza.Pizza;
                List <ToppingModel>  toppings      = new List <ToppingModel>();
                List <PizzaToppings> pizzaToppings = db.PizzaToppings.Where(pt => pt.PizzaId == pizza3.Id).Include("Topping").ToList();
                Console.WriteLine(pizzaToppings.Count);
                foreach (PizzaToppings topping in pizzaToppings)
                {
                    toppings.Add(topping.Topping);
                }

                pizza3.Toppings = toppings;
                pizzas2.Add(pizza3);
            }
            cart.Pizzas = pizzas2;
            db.SaveChanges();

            Console.WriteLine("Add Pizza to cart before add: " + cart.Pizzas.Count);
            cart.Pizzas.Add(pizza);
            Console.WriteLine("Add Pizza to cart after add: " + cart.Pizzas.Count);
            db.SaveChanges();
        }
Exemple #13
0
        public async void TestPizzaRepositoryGetAll()
        {
            await _connection.OpenAsync();

            await dbo.Database.EnsureCreatedAsync();

            PizzaModel tempPizza = new PizzaModel()
            {
                Crust = new CrustModel {
                    Name = "garlic", Description = "delicousness"
                }, Size = new SizeModel {
                    Name = "large", Diameter = 16
                }, Toppings = new System.Collections.Generic.List <ToppingsModel> {
                    new ToppingsModel {
                        Name = "onions", Description = "they have layers"
                    }
                }, Name = "shrek", Description = "right form the swamp", SpecialPizza = true
            };

            dbo.Pizzas.Add(tempPizza);
            dbo.SaveChanges();
            PizzaRepository PR = new PizzaRepository(dbo);

            Assert.NotNull(PR.GetAll());
        }
Exemple #14
0
        public IActionResult PizzaInventory()
        {
            int userId = Convert.ToInt32(TempData["user"]);

            TempData["user"] = userId;


            Domain.Model.Puser        user   = repository.GetUser(userId);
            List <Domain.Model.Pizza> pizzas = repository.GetPizzas(user.LocationId);

            List <PizzaModel> pizzModels = new List <PizzaModel>();

            foreach (Domain.Model.Pizza pizza in pizzas)
            {
                PizzaModel model = new PizzaModel()
                {
                    PizzaId     = pizza.PizzaId,
                    PType       = pizza.PType,
                    PSize       = pizza.PSize,
                    Crust       = pizza.Crust,
                    PPrice      = pizza.PPrice,
                    SLocationId = pizza.SLocationId
                };

                pizzModels.Add(model);
            }


            return(View(pizzModels));
        }
        public bool Post(PizzaTamanhoEnum tamanho_valor, PizzaSaborEnum sabor_valor)
        {
            int novo_id_pizza  = 1;
            int novo_id_pedido = 1;

            if (pizzas.Count > 0)
            {
                novo_id_pizza = pizzas.Max(pizza => pizza.Id) + 1;
            }
            if (pedidos.Count > 0)
            {
                novo_id_pedido = pedidos.Max(pedido => pedido.Id) + 1;
            }

            PizzaTamanhoModel tamanho = this.getPizzaTamanhos()
                                        .Where(pizzaTamanho => pizzaTamanho.Tamanho == tamanho_valor)
                                        .Select(pizzaTamanho => pizzaTamanho).First();
            PizzaSaborModel sabor = this.getPizzaSabores()
                                    .Where(pizzaSabor => pizzaSabor.Sabor == sabor_valor)
                                    .Select(pizzaSabor => pizzaSabor).First();
            PizzaModel novaPizza = new PizzaModel(novo_id_pizza, tamanho, sabor);

            pizzas.Add(novaPizza);
            PedidoModel novoPedido = new PedidoModel(novo_id_pedido, novaPizza);

            pedidos.Add(novoPedido);
            return(true);
        }
Exemple #16
0
        /// <summary>
        /// Gets PizzaModel object by identifier
        /// </summary>
        /// <param name="id">id of pizza</param>
        /// <returns>Single PizzaModel object or list of errors</returns>
        public async Task <IServiceResult <PizzaToReturnDto> > GetByIdAsync(int id)
        {
            try
            {
                // try to get pizza with all child objects
                PizzaModel pizza = await GetPizzaById(id);

                if (pizza != null)
                {
                    PizzaToReturnDto pizzaToReturn = CreatePizzaToReturn(pizza);

                    // return the object if it was found in database
                    return(new ServiceResult <PizzaToReturnDto>(ResultType.Correct, pizzaToReturn));
                }

                // pass error state to controller
                return(new ServiceResult <PizzaToReturnDto>(ResultType.Error, new List <string> {
                    "Cannot load pizza from database"
                }));
            }
            catch (Exception e)
            {
                // catch exception and pass errors to controller
                return(new ServiceResult <PizzaToReturnDto>(ResultType.Error, new List <string> {
                    e.Message
                }));
            }
        }
Exemple #17
0
        public void ValidarPrecioMasaOriginal()
        {
            PizzaModel modelo    = new PizzaModel();
            int        resultado = modelo.getMasaPrice("original");

            Assert.AreEqual(resultado, 1000);
        }
Exemple #18
0
        public void Testing_PriceCalculation()
        {
            var sut = new PizzaModel();

            sut.Crust = new CrustModel()
            {
                Price = 5
            };
            sut.Size = new SizeModel()
            {
                Price = 7.5m
            };
            sut.Toppings = new List <ToppingModel>()
            {
                new ToppingModel()
                {
                    Price = 0.25m
                },
                new ToppingModel()
                {
                    Price = 0.5m
                }
            };

            decimal price = 13.25m;

            Assert.True(sut.CalculatePrice() == price);
        }
Exemple #19
0
        public void ValidarPrecioMasaQueso()
        {
            PizzaModel modelo    = new PizzaModel();
            int        resultado = modelo.getMasaPrice("queso");

            Assert.AreEqual(resultado, 2000);
        }
        public List <PizzaModel> ValidatePizza(List <string> pizzas)
        {
            foreach (var product in pizzas)
            {
                if (String.IsNullOrWhiteSpace(product) ||
                    !_menu.PizzasWithIngredients
                    .Any(p => p.Key
                         .Equals(product
                                 .ToLower()
                                 .Trim()))
                    )
                {
                    throw new ArgumentException("Invalid input for pizza. PizzaModel is not availible on _menu");
                }

                var pizza = new PizzaModel()
                {
                    Name        = product.ToLower().Trim(),
                    Price       = _menu.Prices[product.ToLower().Trim()],
                    Ingredients = _menu.PizzasWithIngredients[product.ToLower().Trim()]
                };
                ValidPizzas.Add(pizza);
            }
            return(ValidPizzas);
        }
Exemple #21
0
        public void ValidarPrecioTamanioMediana()
        {
            PizzaModel modelo    = new PizzaModel();
            int        resultado = modelo.getTamanoPrice("mediana");

            Assert.AreEqual(resultado, 4500);
        }
        public PizzaModel GetPizzaInfoById(int pizzaId)
        {
            SqlDataReader reader = this.ExecuteReader(
                @"SELECT Id,
                          Name,
                          Description,
                          PicturePath
                     FROM Pizzas
                    WHERE Id = @pizzaId",
                new Dictionary <string, object>()
            {
                { "@pizzaId", pizzaId }
            });

            using (reader)
            {
                if (reader.Read())
                {
                    int    id          = reader.GetInt32(0);
                    string name        = reader.GetString(1);
                    string description = reader.GetString(2);
                    string picturePath = reader.GetString(3);

                    PizzaModel pizza = new PizzaModel(id, name, description, picturePath);
                    return(pizza);
                }

                return(null);
            }
        }
        public async Task <int> RemoveFromCartAsync(PizzaModel pizza)
        {
            var CartItem =
                await _DBContext.cart.SingleOrDefaultAsync(
                    s => s.Pizzas.Id == pizza.Id && s.Cartitem == CartId);

            var localAmount = 0;

            if (CartItem != null)
            {
                if (CartItem.Total > 1)
                {
                    CartItem.Total--;
                    localAmount = CartItem.Total;
                }
                else
                {
                    _DBContext.cart.Remove(CartItem);
                }
            }

            await _DBContext.SaveChangesAsync();

            return(localAmount);
        }
Exemple #24
0
        private PizzaModel AddPizzaOrder(string id, string size, BotUserState userState)
        {
            PizzaModel pizzaModelFind = userState.OrderModel.Pizzas.Where(x => x.PizzaId == int.Parse(id) && x.SizeName == size).FirstOrDefault();

            if (pizzaModelFind != null)
            {
                pizzaModelFind.Quantity++;
                userState.OrderModel.PriceTotal += pizzaModelFind.Price;
                return(pizzaModelFind);
            }
            else
            {
                Pizza     pizza     = context.Pizzas.Where(x => x.PizzaId == int.Parse(id)).FirstOrDefault();
                PizzaSize pizzaSize = context.Pizzas.Include(x => x.PizzaIngredients).ThenInclude(y => y.Ingredient)
                                      .Include(x => x.PizzaSizes).ThenInclude(y => y.SizeP).FirstOrDefault().PizzaSizes.Where(x => x.SizeP.Size == size).FirstOrDefault();

                PizzaModel pizzaModel = new PizzaModel
                {
                    PizzaId   = pizza.PizzaId,
                    PizzaName = pizza.Name,
                    SizeId    = pizzaSize.SizePId,
                    SizeName  = pizzaSize.SizeP.Size,
                    Quantity  = 1,
                    Price     = pizzaSize.Price
                };
                userState.OrderModel.Pizzas.Add(pizzaModel);
                userState.OrderModel.PriceTotal += (pizzaModel.Quantity * pizzaModel.Price);
                return(pizzaModel);
            }
        }
        public IActionResult Index()
        {
            PizzaModel pizzaModel = new PizzaModel();

            ViewBag.pizzas = pizzaModel.findAll();
            return(View());
        }
Exemple #26
0
        public ActionResult ProceedToBuy(int id)
        {
            PizzaModel model = new PizzaModel();

            var pizza = _context.Pizza.Where(s => s.SNo == id).ToList();

            if (pizza.Count > 0)
            {
                model = pizza[0];
            }

            List <PizzaModel> lstOlddata = SessionHelper.GetObjectFromJson <List <PizzaModel> >(HttpContext.Session, "Placeorder");

            if (lstOlddata == null)
            {
                lstOlddata = new List <PizzaModel>();
            }

            if (pizza.Count > 0)
            {
                lstOlddata.Add(model);
            }

            SessionHelper.SetObjectAsJson(HttpContext.Session, "Placeorder", lstOlddata);


            return(RedirectToAction("Address", "Address"));
        }
        public async Task GetPizzaById()
        {
            int        expectedId    = 1;
            PizzaModel expectedPizza = (await GetPizzaById(expectedId)).Single();

            pizzaRepoMock.Setup(x => x.GetByExpressionAsync(It.IsAny <Expression <Func <PizzaModel, bool> > >(),
                                                            It.IsAny <Func <IQueryable <PizzaModel>, IIncludableQueryable <PizzaModel, object> > >())).Returns(GetPizzaById(expectedId));

            uowMock.Setup(x => x.Pizzas).Returns(pizzaRepoMock.Object);

            // create instance of service
            IPizzaService service = new PizzaService(uowMock.Object);

            // call function to test
            IServiceResult <PizzaToReturnDto> result = await service.GetByIdAsync(expectedId);

            // asserts
            Assert.AreEqual(ResultType.Correct, result.Result);
            Assert.IsNotNull(result.ReturnedObject);
            Assert.AreEqual(expectedPizza.Id, result.ReturnedObject.Id);
            Assert.AreEqual(expectedPizza.Name.ToLower(), result.ReturnedObject.Name.ToLower());
            Assert.AreEqual(expectedPizza.PizzaIngredients.Count + 3, result.ReturnedObject.Ingredients.Count);
            Assert.AreEqual(expectedPizza.PizzaDetails.Count, result.ReturnedObject.TotalPrices.Count);

            // check of total price makes sure that also ingredients have correct prices
            for (int i = 0; i < expectedPizza.PizzaDetails.Count; i++)
            {
                Assert.AreEqual(expectedPizza.PizzaDetails.ElementAt(i).TotalPrice, result.ReturnedObject.TotalPrices.ElementAt(i).Price);
            }
        }
        public IActionResult Save(CustomerModel customerModel, PizzaModel pizzaModel, ExtraIngredientsModel extraIngredients, OrderModel orderModel)
        {
            if (customerModel.ID == 0)
            {
                _context.Customer.Add(customerModel);

                _context.ExtraIngredients.Add(extraIngredients);

                var customerID = customerModel.ID;

                orderModel.CustomerModelID = customerID;

                _context.Order.Add(orderModel);

                pizzaModel.OrderModelID            = orderModel.ID;
                pizzaModel.ExtraIngredientsModelID = extraIngredients.ID;

                _context.Pizza.Add(pizzaModel);
            }

            else
            {
                throw new System.Exception("Not implemented");
            }

            _context.SaveChanges();

            return(RedirectToAction("Index", "CustomerModels"));
        }
Exemple #29
0
        //not used yet
        public async Task <IServiceResult> DeletePizzaPhotoAsync(int pizzaId)
        {
            try
            {
                PizzaModel photoRecipent = (await _unitOfWork.Pizzas.GetByExpressionAsync(x => x.Id == pizzaId, i => i.Include(p => p.Photo))).SingleOrDefault();

                if (photoRecipent.Photo != null)
                {
                    bool deletionResult = await DeletePhotoAsync(photoRecipent.Photo);

                    if (deletionResult == true)
                    {
                        return(new ServiceResult(ResultType.Deleted));
                    }
                }

                return(new ServiceResult(ResultType.Error, new List <string> {
                    "Error during deletion of pizza photo"
                }));
            }
            catch (Exception e)
            {
                return(new ServiceResult(ResultType.Error, new List <string> {
                    e.Message
                }));
            }
        }
        public IActionResult CreatePizza([Bind("SizeID,CrustID,PresetID,ToppingIDs,MaxToppings,Amount")] PizzaModel pizza)
        {
            if (order == null)
            {
                return(RedirectToAction("CreateOrder"));
            }
            try
            {
                if (!ModelState.IsValid)
                {
                    ViewBag.Restaurant = ModelMapper.Map(RestaurantController.Repository.Read((int)order.Restaurant.ID));
                    return(View());
                }

                pizza.InitFromRestaurant(ModelMapper.Map(RestaurantController.Repository.Read((int)order.Restaurant.ID)));

                order.AddPizza(pizza);
                return(RedirectToAction("CreateOrder"));
            }
            catch (Exception e)
            {
                ViewBag.Restaurant = ModelMapper.Map(RestaurantController.Repository.Read((int)order.Restaurant.ID));
                return(View());
            }
        }