public async Task <IActionResult> Edit(long id, [Bind("SoldId,SoldBy,SoldMedicine,SoldDate,SoldTo")] MedicinesSold medicinesSold) { if (id != medicinesSold.SoldId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(medicinesSold); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MedicinesSoldExists(medicinesSold.SoldId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["SoldBy"] = new SelectList(_context.Pharmacist, "PharmacistId", "PharmacistName", medicinesSold.SoldBy); ViewData["SoldMedicine"] = new SelectList(_context.MedicinesStored, "MedicineId", "Category", medicinesSold.SoldMedicine); ViewData["SoldTo"] = new SelectList(_context.Users, "UserId", "Pwd", medicinesSold.SoldTo); return(View(medicinesSold)); }
public async Task <IActionResult> Create([Bind("SoldId,SoldBy,SoldMedicine,SoldDate,SoldTo")] MedicinesSold medicinesSold) { if (ModelState.IsValid) { _context.Add(medicinesSold); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["SoldBy"] = new SelectList(_context.Pharmacist, "PharmacistId", "PharmacistName", medicinesSold.SoldBy); ViewData["SoldMedicine"] = new SelectList(_context.MedicinesStored, "MedicineId", "Category", medicinesSold.SoldMedicine); ViewData["SoldTo"] = new SelectList(_context.Users, "UserId", "Pwd", medicinesSold.SoldTo); return(View(medicinesSold)); }