public async Task <IActionResult> Edit(int id, [Bind("Id,MerchantName,PurchaseDate,Kilos,Price")] MelangePurchase melangePurchase) { if (id != melangePurchase.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(melangePurchase); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MelangePurchaseExists(melangePurchase.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(melangePurchase)); }
public async Task <ActionResult <MelangePurchase> > PostMelangePurchase(MelangePurchase melangePurchase) { _context.MelangePurchase.Add(melangePurchase); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetMelangePurchase), new { id = melangePurchase.Id }, melangePurchase)); }
public async Task <IActionResult> PutMelangePurchase(int id, MelangePurchase melangePurchase) { if (id != melangePurchase.Id) { return(BadRequest()); } _context.Entry(melangePurchase).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MelangePurchaseExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Id,MerchantName,PurchaseDate,Kilos,Price")] MelangePurchase melangePurchase) { if (ModelState.IsValid) { _context.Add(melangePurchase); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(melangePurchase)); }