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)); }
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)); }
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)); }