예제 #1
0
        public async Task <IActionResult> Create([Bind("TableID,OrderID,OrderName,Amount")] Order order)
        {  //hata var pancake dene
            //int table = @ViewBag.TableNo;
            if (ModelState.IsValid)
            {
                var sonuc = _context.Orders.FirstOrDefault(x => x.TableID == order.TableID && x.OrderName.Equals(order.OrderName));

                //if (!FoodExists(order.OrderName, order.TableID))
                if (sonuc == null)
                {
                    _context.Add(order);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Det", new { id = order.TableID }));
                    //return View("Create");
                }
                else
                {
                    var deneme = _context.Orders.Where(x => x.OrderName == order.OrderName && x.TableID == order.TableID).FirstOrDefault();
                    deneme.Amount += order.Amount;
                    _context.Update(deneme);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Det", new { id = order.TableID }));
                }
            }
            return(View(order));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("Type,FID,FoodName,Price")] Menu menu)
        {
            if (ModelState.IsValid)
            {
                _context.Add(menu);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(menu));
        }
예제 #3
0
        public async Task <IActionResult> Create([Bind("ID,Email,Name,LName,Password,JTitle")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(employee));
        }