public async Task <IActionResult> Edit(int id, [Bind("DialysisID,PouchID,DialysisDate,DialysisTime,OutWeight")] Dialysis dialysis) { if (id != dialysis.DialysisID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(dialysis); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DialysisExists(dialysis.DialysisID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["PouchID"] = new SelectList(_context.Pouch, "PouchID", "Name", dialysis.PouchID); return(View(dialysis)); }
public async Task <IActionResult> Create([Bind("DialysisID,PouchID,DialysisDate,DialysisTime,OutWeight")] Dialysis dialysis) { if (ModelState.IsValid) { _context.Add(dialysis); await _context.SaveChangesAsync(); Pouch pou = _context.Pouch.First(p => p.PouchID == dialysis.PouchID); pou.StockOut -= 1; await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["PouchID"] = new SelectList(_context.Pouch, "PouchID", "Name", dialysis.PouchID); return(View(dialysis)); }