コード例 #1
0
        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());
        }
コード例 #2
0
        public IActionResult OnPost(int doctorId)
        {
            var doctor = doctorData.Delete(doctorId);

            doctorData.Commit();

            if (doctor == null)
            {
                return(RedirectToPage("./NotFound"));
            }

            TempData["Message"] = $"{doctor.Name} deleted";
            return(RedirectToPage("./List"));
        }
コード例 #3
0
        public IActionResult OnPost(int id)
        {
            var temp = doctorData.GetDoctorById(id);

            if (temp == null)
            {
                return(RedirectToPage("~/NotFound"));
            }
            var temp2 = doctorData.Delete(temp.Id);

            doctorData.Commit();
            TempData["TempMessage"] = "The doctor is fired!";
            return(RedirectToPage("./List"));
        }
コード例 #4
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 }));
 }