public async Task <IActionResult> Edit(int id, [Bind("SaleDate,SaleWeight,SaleUnitPrice,SaleActive,VegetableId")] Sale sale) { if (id != sale.SaleId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sale); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SaleExists(sale.SaleId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(sale)); }
public async Task <IActionResult> Create([Bind("SaleDate,SaleWeight,SaleUnitPrice,SaleActive,VegetableId")] Sale sale) { if (ModelState.IsValid) { _context.Add(sale); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(sale)); }