public ActionResult SendMedicineToCenter(MedicineStore model) { try { if (ModelState.IsValid) { _medicineStoreManager.Add(model); ViewBag.message = "Medicine Send Sucessfully to a Center"; } } catch (Exception ex) { ViewBag.message = ex.Message; } SelectList aList = new SelectList(_centerManager.GetAllDistricts(), "Id", "Name"); SelectList list = new SelectList(_medicineManager.GetAll(), "Id", "GenericName"); ViewBag.districts = aList; ViewBag.medicines = list; return(View()); }
public ActionResult DeliverMedicineToPatient(DeliverMedicineViewModel model) { if (Session["CenterId"] == null) { ViewBag.message = "Center Id not found!! Please give Correct Center"; return(View()); } int centerId = (int)Session["CenterId"]; MedicineStore store = (MedicineStore)_medicineStoreManager.GetAll().ToList().FirstOrDefault(m => m.CenterId == centerId); PatientTreatment patientTreatment = _patientTreatmentManager.GetById(model.Id); foreach (PatientDisease disease in patientTreatment.PatientDiseases) { StoreDetail storeDetail = store.StoreDetails.ToList().FirstOrDefault(m => m.MedicineId == disease.MedicineId); if (storeDetail == null) { ViewBag.message = "Medicine Id " + disease.MedicineId + " no Found in this Center Store"; return(View()); } storeDetail.Quantity = storeDetail.Quantity - disease.MedicineQuantity; if (storeDetail.Quantity < 0) { ViewBag.message = "Medicine Id " + disease.MedicineId + " is out of Stock!!! Please Inform Head office for Medicine"; return(View()); } } bool result = _medicineStoreManager.Update(store); if (result) { ViewBag.message = "Medicine Given Sucessfully to Patient"; } SelectList aList = new SelectList(_patientTreatmentManager.GetAll().ToList(), "Id", "TreatmentCode"); ViewBag.treatmentList = aList; return(View()); }
public ActionResult MedicineStockReport(int centerId) { MedicineStore medicineStore = _medicineStoreManager.GetAll().FirstOrDefault(m => m.CenterId == centerId); return(View(medicineStore)); }