public ActionResult DispenseDrug(DispenseDrug DD, string id) { Consultation consult = da.Consultations.ToList().Find(x => x.ConsultId == DD.ConsultId); foreach (var drug in consult.CustLis) { Drug dg = drugrep.GetAll().Find(x => x.DrugName == drug.DrugId); dg.DrugQuantity -= drug.Quantity; drugrep.Update(dg); } return(RedirectToAction("ViewDrugsConsultation").WithNotification(Status.Success, "Dispensed Drugs Sucessfully")); }
public DrugModel PostReviewMethod(DrugModel model) { using (var drugr = new DrugRespo()) { if (model.DrugId == 0) { Drug _drug = new Drug { DrugId = model.DrugId, DrugCode = model.DrugCode, DrugName = model.DrugName, DrugCategory = model.DrugCategory, DrugDescription = model.DrugDescription, DrugQuantity = model.DrugQuantity, Status = model.Status, DrugPrice = model.DrugPrice, DrugType = model.DrugType, }; drugr.Insert(_drug); } else { //var _drug = drugr.GetById(dr.DrugId); Drug _drug = drugr.GetById(model.DrugId); _drug.DrugId = model.DrugId; _drug.DrugCode = model.DrugCode; _drug.DrugName = model.DrugName; _drug.DrugCategory = model.DrugCategory; _drug.DrugDescription = model.DrugDescription; _drug.DrugQuantity = model.DrugQuantity; _drug.Status = model.Status; _drug.DrugPrice = model.DrugPrice; _drug.DrugType = model.DrugType; drugr.Update(_drug); } return(model); } }