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 List <DrugModel> GetAll() { using (var drgR = new DrugRespo()) { return(drgR.GetAll().Select(x => new DrugModel() { DrugId = x.DrugId, DrugCode = x.DrugCode, DrugName = x.DrugName, DrugCategory = x.DrugCategory, DrugDescription = x.DrugDescription, DrugQuantity = x.DrugQuantity, Status = x.Status, DrugType = x.DrugType, DrugPrice = x.DrugPrice }).ToList()); } }