Exemple #1
0
        public IActionResult CreateCustomer(CustomerViewModel customerViewModel)
        {
            List <string> DrinkIDs = Request.Cookies.Keys.ToList();
            var           drinks   = drinkColl.GetAllDrinks();

            var itemsModel = itemColl.GetDrinkByIDs(DrinkIDs, drinks);

            foreach (var item in itemsModel)
            {
                var cartItem = new CartItemModel(item.CartID, item.DrinkID, Convert.ToInt32(Request.Cookies[Convert.ToString(item.DrinkID)]));
                CIM.Add(cartItem);
            }


            var TotalPrice = cartColl.GetTotalPrice(CIM, drinks, totalPrice);

            shoppingCartModel = new ShoppingCartModel(tempid, tempid, TotalPrice, DateTime.Now);

            customerModel = new CustomerModel(customerViewModel.CustomerID, customerViewModel.Name, customerViewModel.Adress, customerViewModel.Email);
            customerCollection.Create(customerModel, shoppingCartModel, CIM);
            //customerCollection.SendEmail(customerModel.Email, customerModel.Name);

            foreach (var key in DrinkIDs)
            {
                Response.Cookies.Delete(key);
            }

            return(RedirectToAction("Index", "Drink"));
        }