public ActionResult ViewEditDrug() { ClASDBEntities db = new ClASDBEntities(); Drug d = new Drug(); AddDrugModel adm = new AddDrugModel(); var getdata = db.Drugs.ToList(); List <AddDrugModel> lst1 = new List <AddDrugModel>(); //string value = ""; foreach (var item in getdata) { lst1.Add(new AddDrugModel { DName = item.DrugName, DrugId = item.DrugID, MfgDate = item.ManufactureDate, ExpDate = item.ExpiryDate, IsDeleted = item.IsDeleted, SideEff = item.SideEffect, Qtty = item.TotalQuantityAvailable, Use = item.UsedFor }); } adm.ListDrug = lst1; return(View(adm)); }
public AddDrugViewModel(AdminShellViewModel containingVm) { addDrugM = new AddDrugModel(); this.containingVm = containingVm; UpdateDbCommand = new AddToDbCommand(this); IsNewDrug = true; BackCommand = new BackCommand(this); IngredientToAdd = new ActiveIngredient(); Ingredients = new ObservableCollection <ActiveIngredient>(); AddIngredientCommand = new AddIngredientToDrugCommand(this); DeleteIngredientCommand = new DeleteItemCommand(this); FileDialogCommand = new OpenFileDialogCommand(this); }
public ActionResult EditDrug(int id) { ClASDBEntities db = new ClASDBEntities(); var getdata = db.Drugs.Where(m => m.DrugID == id).FirstOrDefault(); AddDrugModel adm = new AddDrugModel(); adm.DName = getdata.DrugName; adm.DrugId = getdata.DrugID; adm.ExpDate = getdata.ExpiryDate; adm.MfgDate = getdata.ManufactureDate; adm.Qtty = getdata.TotalQuantityAvailable; adm.SideEff = getdata.SideEffect; adm.Use = getdata.UsedFor; adm.IsDeleted = getdata.IsDeleted; return(View(adm)); }
public ActionResult EditDrug(AddDrugModel ad, int id) { if (ModelState.IsValid) { ClASDBEntities db = new ClASDBEntities(); var d = db.Drugs.Where(m => m.DrugID == id).FirstOrDefault(); d.DrugName = ad.DName; d.ManufactureDate = ad.MfgDate; d.ExpiryDate = ad.ExpDate; d.SideEffect = ad.SideEff; d.TotalQuantityAvailable = ad.Qtty; d.IsDeleted = ad.IsDeleted; d.UsedFor = ad.Use; db.SaveChanges(); ViewBag.text = "Edited Successfully"; } else { ViewBag.text = "Error Occured"; } return(RedirectToAction("ViewEditDrug", "Admin")); }
public ActionResult AddDrugDetails(AddDrugModel ad) { if (ModelState.IsValid) { ClASDBEntities db = new ClASDBEntities(); Drug d = new Drug(); d.DrugName = ad.DName; d.ManufactureDate = ad.MfgDate; d.ExpiryDate = ad.ExpDate; d.SideEffect = ad.SideEff; d.TotalQuantityAvailable = ad.Qtty; d.UsedFor = ad.Use; d.IsDeleted = "No"; db.Drugs.Add(d); db.SaveChanges(); ViewBag.text = "Drug Inserted Succesfully"; } else { ViewBag.text = "Drug Not Inserted"; } return(View(ad)); }