public ActionResult NewPatient()
 {
     Service serv = new Service();
     ViewBag.City = serv.GetCity();
     PatientViewModel patient = new PatientViewModel();
     return PartialView("NewPatient", patient);
 }
 public ActionResult NewPatient(PatientViewModel patient)
 {
     Service serv = new Service();
     if (ModelState.IsValid)
     {
         serv.CreatePatient(patient);
         return Json(new { success = true}, JsonRequestBehavior.AllowGet);
     }
     else
     {
         ViewBag.City = serv.GetCity();
         return Json(new { success = false, textError = "During save patient error" }, JsonRequestBehavior.AllowGet);
     }
 }
Beispiel #3
0
 public void CreatePatient(PatientViewModel patient)
 {
     db.Patients.Add(new Patient { CityId = patient.CityId, FirstName = patient.FirstName, LastName = patient.LastName, Gender = patient.Gender == GenderSelector.Male ? false : true, Pesel = patient.Pesel.HasValue ? patient.Pesel.Value : 0 });
     db.SaveChanges();
 }
Beispiel #4
0
        public PatientViewModel GetPatientById(int id)
        {
            var patientDB = db.Patients.FirstOrDefault(x => x.Id == id);
            PatientViewModel patient = new PatientViewModel();
            patient.FirstName = patientDB.FirstName;
            patient.LastName = patientDB.LastName;
            patient.Pesel = patientDB.Pesel;
            patient.Id = patientDB.Id;

            return patient;
        }