コード例 #1
0
ファイル: DoctorMethods.cs プロジェクト: abonSerg/Clinic
 public string UpdateDoctor(Doctor doctor)
 {
     string message = ValidateDoctor(doctor);
     if (string.IsNullOrEmpty(message))
     {
         Doctor uniqueDoctorInClinic = DoctorMethods.Instance.GetDoctorByClinic(ClinicMethods.Instance.GetClinicByCode(doctor.Clinic.Code).Code);
         if (uniqueDoctorInClinic == null)
         {
             doctor.Clinic.Id = ClinicMethods.Instance.GetClinicByCode(doctor.Clinic.Code).Id;
             bool isProcessDone = InsertEntity<Doctor>(doctor);
             if (isProcessDone)
             {
                 log.Info(string.Format("Doctor {0} changed", doctor.Code));
                 return string.Empty;
             }
             else
             {
                 return "Code will be UNIQE!";
             }
         }
         else
         {
             return "Doctor for this Clinic is exists already!";
         }
     }
     else
     {
         return message;
     }
 }
コード例 #2
0
ファイル: DoctorService.svc.cs プロジェクト: abonSerg/Clinic
 public string EditDoctor(DtoDoctor dtoDoctor)
 {
     var uniqueDoctor = DoctorMethods.Instance.GetDoctorByCode(dtoDoctor.Code);
     if (!dtoDoctor.IsEdit)
     {
         var doctor = new Doctor()
         {
             Code = dtoDoctor.Code,
             FirstName = dtoDoctor.FirstName,
             LastName = dtoDoctor.LastName,
             MiddleName = dtoDoctor.MiddleName,
             Clinic = new DataAccess.Clinic()
             {
                 Code = dtoDoctor.Clinic.Code
             }
         };
         return DoctorMethods.Instance.InsertDoctor(doctor);
     }
     else
     {
         var doctor = new Doctor()
         {
             Id = uniqueDoctor.Id,
             Code = dtoDoctor.Code,
             FirstName = dtoDoctor.FirstName,
             LastName = dtoDoctor.LastName,
             MiddleName = dtoDoctor.MiddleName,
             Clinic = new DataAccess.Clinic()
             {
                 Code = dtoDoctor.Clinic.Code
             }
         };
         return DoctorMethods.Instance.UpdateDoctor(doctor);
     }
 }
コード例 #3
0
ファイル: DoctorMethods.cs プロジェクト: abonSerg/Clinic
 private static string ValidateDoctor(Doctor doctor)
 {
     if (!string.IsNullOrEmpty(doctor.FirstName) && !string.IsNullOrEmpty(doctor.LastName))
     {
         if(!string.IsNullOrEmpty(doctor.Clinic.Code))
         {
             return string.Empty;
         }
         else
         {
             return "Choose CLinic!";
         }
     }
     else
     {
         return "Last Name and Fist Name are mandatory fields!";
     }
 }