public IActionResult OnPost()
        {
            if (ModelState.IsValid)
            {
                var clinic = clinicData.GetClinicById(Doctor.ClinicId);
                Doctor.Clinic = clinic;
                if (Doctor.Id == 0)
                {
                    Doctor = doctorData.Create(Doctor);
                    TempData["TempMessage"] = "New doctor is hired!";
                }
                else
                {
                    Doctor = doctorData.Update(Doctor);
                    TempData["TempMessage"] = "Doctor information is updated!";
                }

                doctorData.Commit();
                return(RedirectToPage("./List"));
            }
            var clinics = clinicData.GetClinics().ToList().Select(p => new { Id = p.Id, Display = p.Name });

            Clinics = new SelectList(clinics, "Id", "Display");
            Gender  = htmlHelper.GetEnumSelectList <Gender>();
            return(Page());
        }
Beispiel #2
0
 public IActionResult OnPost()
 {
     if (!ModelState.IsValid)
     {
         Types = htmlHelper.GetEnumSelectList <DoctorType>();
         return(Page());
     }
     if (Doctor.Id > 0)
     {
         doctorData.Update(Doctor);
     }
     else
     {
         doctorData.Add(Doctor);
     }
     doctorData.Commit();
     TempData["Message"] = "Doctor Saved";
     return(RedirectToPage("./Detail", new { doctorId = Doctor.Id }));
 }