public ActionResult SavePatient(PatientVm patient) { bool result = false; if (ModelState.IsValid) { if (patient.RoomCategoryID != 0 && patient.RoomCategory1 == null) { Patient newPatient = new Patient(); newPatient.PatientName = patient.PatientName; newPatient.Age = patient.Age; newPatient.Gender = patient.Gender; newPatient.ContactNumber = patient.ContactNumber; newPatient.AdmissionDate = DateTime.Now; newPatient.RoomID = patient.RoomID; newPatient.IsDeleted = true; db.Patients.Add(newPatient); db.SaveChanges(); } } result = true; return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Create(PatientVm patient) { if (ModelState.IsValid) { iPatientBL.AddPatient(patient); return(RedirectToAction("Index")); } return(View()); }
public async Task <IActionResult> Edit(PatientVm patient) { if (string.IsNullOrEmpty(Convert.ToString(patient.PatientId))) { return(View()); } var model = await iPatientBL.UpdatePatientAsync(patient); return(RedirectToAction("Index")); }
public void AddPatient(PatientVm patient) { if (!string.IsNullOrEmpty(patient.FirstName)) { iRepository.HealthCareDbContext.Patients.Add( new Patient() { Address = patient.Address, DOB = patient.DOB, FirstName = patient.FirstName, LastName = patient.LastName, Gender = patient.Gender }); iRepository.HealthCareDbContext.SaveChanges(); } }
public async Task <bool> UpdatePatientAsync(PatientVm patientvm) { var patient = iRepository.HealthCareDbContext.Patients.FirstOrDefault(x => x.PatientId == patientvm.PatientId); if (patient != null) { patient.FirstName = patientvm.FirstName; patient.LastName = patientvm.LastName; patient.DOB = patientvm.DOB; patient.Gender = patientvm.Gender; patient.Address = patientvm.Address; await iRepository.HealthCareDbContext.SaveChangesAsync(); return(true); } return(false); }