예제 #1
0
        public async Task <IActionResult> Create([Bind("Id,Name,Email,Address,City,PhoneNumber")] Client client)
        {
            if (ModelState.IsValid)
            {
                _context.Add(client);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(client));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("Id,UserName,Password,FullName")] Manager manager)
        {
            if (ModelState.IsValid)
            {
                _context.Add(manager);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(LogIn)));
            }
            return(View(manager));
        }
예제 #3
0
        public async Task <IActionResult> Create([Bind("Id,Name,Price,Description,Image,KitchenDish")] Dish dish)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dish);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(dish));
        }
예제 #4
0
        public async Task <IActionResult> Create([Bind("Id,Total")] Order order, Client client
                                                 , string cardNumber, string expiryMonth, string expiryYear,
                                                 string cvv, string CreditOwnerName)
        {
            //if (ModelState.IsValid)
            ViewData["Order"] = "order";
            int j = 0;

            order = globalOrder;

            //check if client did order in the past.
            var existsClient = _context.Client.FirstOrDefault(c => c.Id == client.Id);

            //if is new client, add him to the system.
            if (existsClient == null)
            {
                _context.Client.Add(client);
                _context.SaveChanges();
            }

            bool success = true;    //should use payment paramters for perform payment. now ignore it.     :))))))))))))))))BE HAPPY))))))))))))))))))

            if (success)
            {
                //enter the order to DB
                order.Client = client;
                _context.Add(order);
                await _context.SaveChangesAsync();

                globalOrder = order;

                string   cart      = HttpContext.Session.GetString("Cart");
                string[] DishesIds = cart.Split(",", StringSplitOptions.RemoveEmptyEntries);
                string[] Ids_NonDuplicate;

                Ids_NonDuplicate = RemoveDuplicates(DishesIds);

                foreach (var id in Ids_NonDuplicate)
                {
                    DeleteDIshesOrder(int.Parse(id), order);
                }
                HttpContext.Session.SetString("Cart", "");
            }
            // else
            //   {
            //  ViewBag.OrderFailed = "מצטערים הזמנה נכשלה. אנא צרו קשר עם שירות לקוחות";
            // }

            //}

            //return View(order);
            return(RedirectToAction("OrderDone"));
        }
예제 #5
0
        public async Task <IActionResult> Create([Bind("DishId,OrderId,Quantity")] DishOrder dishOrder)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dishOrder);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DishId"]  = new SelectList(_context.Dish, "Id", "Id", dishOrder.DishId);
            ViewData["OrderId"] = new SelectList(_context.Order, "Id", "Id", dishOrder.OrderId);
            return(View(dishOrder));
        }