Ejemplo n.º 1
0
 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;
     }
 }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
0
 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!";
     }
 }