public async Task <IActionResult> Create([Bind("Id,CustomerName,PurchasedFood,Quantity,TotalPrice")] PurchaseHistory purchaseHistory) { if (ModelState.IsValid) { _context.Add(purchaseHistory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(purchaseHistory)); }
public async Task <IActionResult> Create([Bind("Id,FoodName,Price,FoodImagePath")] Menu menu) { if (ModelState.IsValid) { _context.Add(menu); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(menu)); }
public async Task <IActionResult> Index(PurchaseHistory model) { if (ModelState.IsValid) { PurchaseHistory obj = new PurchaseHistory() { Id = Guid.NewGuid().ToString(), CustomerName = model.CustomerName, PurchasedFood = model.PurchasedFood, UnitPrice = model.UnitPrice, Quantity = model.Quantity, TotalPrice = model.TotalPrice }; _context.PurchaseHistory.Add(obj); await _context.SaveChangesAsync(); return(RedirectToAction("Index", "ViewMenus")); } return(View(model)); }