Exemple #1
0
        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));
        }
Exemple #2
0
 public ActionResult Create(PatientVm patient)
 {
     if (ModelState.IsValid)
     {
         iPatientBL.AddPatient(patient);
         return(RedirectToAction("Index"));
     }
     return(View());
 }
Exemple #3
0
        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"));
        }
Exemple #4
0
 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();
     }
 }
Exemple #5
0
        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);
        }