Beispiel #1
0
 public int DoctorUpdateRecord(Doctor doctor, Hospital hospital, string ssn, string appellation, string expertise, string ageRange, string name, string surname, DateTime birthday, string phone, string mail, string city, string county)
 {
     if (!string.IsNullOrEmpty(ssn) && !string.IsNullOrWhiteSpace(ssn) && ssn.Length == 11 && !string.IsNullOrEmpty(appellation) && !string.IsNullOrWhiteSpace(appellation) && !string.IsNullOrEmpty(expertise) && !string.IsNullOrWhiteSpace(expertise) && !string.IsNullOrEmpty(ageRange) && !string.IsNullOrWhiteSpace(ageRange) && !string.IsNullOrEmpty(surname) && !string.IsNullOrWhiteSpace(surname) && !string.IsNullOrEmpty(name) && !string.IsNullOrWhiteSpace(name) && birthday != null && doctor != null && hospital != null)
     {
         string tempPhone;
         string tempMail;
         string tempCity;
         string tempCounty;
         if (string.IsNullOrEmpty(phone.Trim()))
         {
             tempPhone = null;
         }
         else
         {
             tempPhone = phone;
         }
         if (string.IsNullOrEmpty(mail.Trim()))
         {
             tempMail = null;
         }
         else
         {
             tempMail = mail;
         }
         if (string.IsNullOrEmpty(city.Trim()))
         {
             tempCity = null;
         }
         else
         {
             tempCity = city;
         }
         if (string.IsNullOrEmpty(county.Trim()))
         {
             tempCounty = null;
         }
         else
         {
             tempCounty = county;
         }
         using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor())
         {
             if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Id != doctor.Id && I.Ssn == ssn))
             {
                 if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Id != doctor.Id && I.Phone == phone))
                 {
                     if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Id != doctor.Id && I.Mail == mail))
                     {
                         doctor.Ssn         = ssn;
                         doctor.Appellation = BLLHelper.GetEnumValueFromDescription <DoctorEnumAppellation>(appellation);
                         doctor.Expertise   = BLLHelper.GetEnumValueFromDescription <DoctorEnumExpertise>(expertise);
                         doctor.AgeRange    = BLLHelper.GetEnumValueFromDescription <DoctorEnumAgeRange>(ageRange);
                         doctor.Name        = BLLHelper.TrimName(name);
                         doctor.Surname     = BLLHelper.TrimSurname(surname);
                         doctor.Birthday    = birthday;
                         doctor.Phone       = tempPhone;
                         doctor.Mail        = tempMail;
                         doctor.City        = tempCity;
                         doctor.County      = tempCounty;
                         doctor.UpdateTime  = DateTime.Now;
                         doctor.HospitalId  = hospital.Id;
                         repositoryDoctor.CUDOperation(doctor, EntityState.Modified);
                         return(repositoryDoctor.SaveChanges());
                     }
                     else
                     {
                         return(-112);
                     }
                 }
                 else
                 {
                     return(-111);
                 }
             }
             else
             {
                 return(-110);
             }
         }
     }
     else
     {
         return(-1);
     }
 }
Beispiel #2
0
        public int DoctorInfoUpdate(Doctor doctor, string phone, string mail, string city, string county)
        {
            string tempPhone;
            string tempMail;
            string tempCity;
            string tempCounty;

            if (string.IsNullOrEmpty(phone.Trim()))
            {
                tempPhone = null;
            }
            else
            {
                tempPhone = phone;
            }
            if (string.IsNullOrEmpty(mail.Trim()))
            {
                tempMail = null;
            }
            else
            {
                tempMail = mail;
            }
            if (string.IsNullOrEmpty(city.Trim()))
            {
                tempCity = null;
            }
            else
            {
                tempCity = city;
            }
            if (string.IsNullOrEmpty(county.Trim()))
            {
                tempCounty = null;
            }
            else
            {
                tempCounty = county;
            }
            using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor())
            {
                if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Id != doctor.Id && I.Phone == phone))
                {
                    if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Id != doctor.Id && I.Mail == mail))
                    {
                        doctor.Phone  = tempPhone;
                        doctor.Mail   = tempMail;
                        doctor.City   = tempCity;
                        doctor.County = tempCounty;
                        repositoryDoctor.CUDOperation(doctor, EntityState.Modified);
                        return(repositoryDoctor.SaveChanges());
                    }
                    else
                    {
                        return(-112);
                    }
                }
                else
                {
                    return(-111);
                }
            }
        }
Beispiel #3
0
 public int DoctorNewRecord(Hospital hospital, string ssn, string appellation, string expertise, string ageRange, string name, string surname, DateTime birthday, string phone, string mail, string city, string county)
 {
     if (!string.IsNullOrEmpty(ssn) && !string.IsNullOrWhiteSpace(ssn) && ssn.Length == 11 && !string.IsNullOrEmpty(appellation) && !string.IsNullOrWhiteSpace(appellation) && !string.IsNullOrEmpty(expertise) && !string.IsNullOrWhiteSpace(expertise) && !string.IsNullOrEmpty(ageRange) && !string.IsNullOrWhiteSpace(ageRange) && !string.IsNullOrEmpty(surname) && !string.IsNullOrWhiteSpace(surname) && !string.IsNullOrEmpty(name) && !string.IsNullOrWhiteSpace(name) && birthday != null && hospital != null)
     {
         string tempPhone;
         string tempMail;
         string tempCity;
         string tempCounty;
         if (string.IsNullOrEmpty(phone.Trim()))
         {
             tempPhone = null;
         }
         else
         {
             tempPhone = phone;
         }
         if (string.IsNullOrEmpty(mail.Trim()))
         {
             tempMail = null;
         }
         else
         {
             tempMail = mail;
         }
         if (string.IsNullOrEmpty(city.Trim()))
         {
             tempCity = null;
         }
         else
         {
             tempCity = city;
         }
         if (string.IsNullOrEmpty(county.Trim()))
         {
             tempCounty = null;
         }
         else
         {
             tempCounty = county;
         }
         using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor())
         {
             if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Ssn == ssn))
             {
                 if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Phone == phone))
                 {
                     if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Mail == mail))
                     {
                         Doctor doctor = new Doctor()
                         {
                             Id          = Guid.NewGuid(),
                             Ssn         = ssn,
                             Appellation = BLLHelper.GetEnumValueFromDescription <DoctorEnumAppellation>(appellation),
                             Expertise   = BLLHelper.GetEnumValueFromDescription <DoctorEnumExpertise>(expertise),
                             AgeRange    = BLLHelper.GetEnumValueFromDescription <DoctorEnumAgeRange>(ageRange),
                             Name        = BLLHelper.TrimName(name),
                             Surname     = BLLHelper.TrimSurname(surname),
                             Birthday    = birthday,
                             Phone       = tempPhone,
                             Mail        = tempMail,
                             City        = tempCity,
                             County      = tempCounty,
                             Picture     = BLLHelper.DefaultDoctorPic(),
                             Password    = PasswordCrypto.EncryptToSha512(ssn),
                             UpdateTime  = DateTime.Now,
                             HospitalId  = hospital.Id
                         };
                         repositoryDoctor.CUDOperation(doctor, EntityState.Added);
                         return(repositoryDoctor.SaveChanges());
                     }
                     else
                     {
                         return(-112);
                     }
                 }
                 else
                 {
                     return(-111);
                 }
             }
             else
             {
                 return(-110);
             }
         }
     }
     else
     {
         return(-1);
     }
 }