public async Task <IActionResult> Edit(int id, [Bind("DosageAmountId,ResultValue,UnitTypeId,DosageTypeId")] PtsDosageAmount ptsDosageAmount) { if (id != ptsDosageAmount.DosageAmountId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(ptsDosageAmount); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PtsDosageAmountExists(ptsDosageAmount.DosageAmountId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DosageTypeId"] = new SelectList(_context.PtsDosageType, "DosageTypeId", "DosageTypeId", ptsDosageAmount.DosageTypeId); ViewData["UnitTypeId"] = new SelectList(_context.PtsUnitType, "UnitTypeId", "UnitTypeName", ptsDosageAmount.UnitTypeId); return(View(ptsDosageAmount)); }
public async Task <IActionResult> Create([Bind("DosageAmountId,ResultValue,UnitTypeId,DosageTypeId")] PtsDosageAmount ptsDosageAmount) { if (ModelState.IsValid) { _context.Add(ptsDosageAmount); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DosageTypeId"] = new SelectList(_context.PtsDosageType, "DosageTypeId", "DosageTypeId", ptsDosageAmount.DosageTypeId); ViewData["UnitTypeId"] = new SelectList(_context.PtsUnitType, "UnitTypeId", "UnitTypeName", ptsDosageAmount.UnitTypeId); return(View(ptsDosageAmount)); }