コード例 #1
0
 public IActionResult OnGet(int id)
 {
     Doctor = doctorData.GetDoctorById(id);
     if (Doctor == null)
     {
         return(RedirectToPage("~/NotFound"));
     }
     return(Page());
 }
コード例 #2
0
        public IActionResult OnPost()
        {
            if (ModelState.IsValid)
            {
                var doctor = doctorData.GetDoctorById(Patient.DoctorId);
                Patient.Doctor = doctor;
                if (Patient.Id == 0)
                {
                    Patient = patientData.Create(Patient);
                    TempData["TempMessage"] = "New patient is created!";
                }
                else
                {
                    Patient = patientData.Update(Patient);
                    TempData["TempMessage"] = "Data for patient is updated!";
                }

                patientData.Commit();
                return(RedirectToPage("./List"));
            }

            var doctors = doctorData.GetDoctors().ToList().Select(d => new { Id = d.Id, Display = $"{d.FirstName} {d.LastName}" });

            Doctors = new SelectList(doctors, "Id", "Display");
            Gender  = htmlHelper.GetEnumSelectList <Gender>();
            return(Page());
        }
コード例 #3
0
        public IActionResult OnGet(int?id)
        {
            if (id.HasValue)
            {
                Doctor = doctorData.GetDoctorById(id.Value);
                if (Doctor == null)
                {
                    return(RedirectToPage("./NotFound"));
                }
            }
            else
            {
                Doctor = new Core.Doctor();
            }
            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());
        }