Exemplo n.º 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);
     }
 }
Exemplo n.º 2
0
        public int MemberRegister(MemberEnumGender gender, string ssn, string password, string name, string surname, string phone, string mail, DateTime birthday)
        {
            int returnValueInt = 0;

            if (!string.IsNullOrEmpty(ssn) && !string.IsNullOrWhiteSpace(ssn) && !string.IsNullOrEmpty(password) && !string.IsNullOrWhiteSpace(password) && !string.IsNullOrEmpty(name) && !string.IsNullOrWhiteSpace(name) && !string.IsNullOrEmpty(surname) && !string.IsNullOrWhiteSpace(surname) && ssn.Length == 11 && birthday != null)
            {
                string tempPhone;
                string tempMail;
                if (string.IsNullOrEmpty(phone.Trim()))
                {
                    tempPhone = null;
                }
                else
                {
                    tempPhone = phone;
                }
                if (string.IsNullOrEmpty(mail.Trim()))
                {
                    tempMail = null;
                }
                else
                {
                    tempMail = mail;
                }
                using (RepositoryMember repositoryMember = new RepositoryMember())
                {
                    if (!repositoryMember.AnyWithExplicitLoad(I => I.Ssn == ssn))
                    {
                        if (!repositoryMember.AnyWithExplicitLoad(I => I.Phone == phone))
                        {
                            if (!repositoryMember.AnyWithExplicitLoad(I => I.Mail == mail))
                            {
                                repositoryMember.CUDOperation(new Member()
                                {
                                    Id       = Guid.NewGuid(),
                                    Ssn      = ssn,
                                    Name     = BLLHelper.TrimName(name),
                                    Surname  = BLLHelper.TrimSurname(surname),
                                    Gender   = gender,
                                    Birthday = birthday,
                                    Phone    = tempPhone,
                                    Mail     = tempMail,
                                    Password = PasswordCrypto.EncryptToSha512(password),
                                    Picture  = BLLHelper.DefaultUserPic()
                                }, EntityState.Added);
                                returnValueInt = repositoryMember.SaveChanges();
                            }
                            else
                            {
                                returnValueInt = -102;
                            }
                        }
                        else
                        {
                            returnValueInt = -101;
                        }
                    }
                    else
                    {
                        returnValueInt = -100;
                    }
                }
            }
            else
            {
                returnValueInt = -1;
            }
            return(returnValueInt);
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 4
0
 public int ForgotPassword(string ssn, string name, string surname, string phone, string mail, DateTime birthday, string newPassword, string newPasswordRepeat)
 {
     if (!string.IsNullOrEmpty(ssn) && !string.IsNullOrWhiteSpace(ssn) && !string.IsNullOrEmpty(name) && !string.IsNullOrWhiteSpace(name) && !string.IsNullOrEmpty(surname) && !string.IsNullOrWhiteSpace(surname) && !string.IsNullOrEmpty(newPassword) && !string.IsNullOrWhiteSpace(newPassword) && !string.IsNullOrEmpty(newPasswordRepeat) && !string.IsNullOrWhiteSpace(newPasswordRepeat) && birthday != null)
     {
         string tempPhone;
         string tempMail;
         if (string.IsNullOrEmpty(phone.Trim()))
         {
             tempPhone = null;
         }
         else
         {
             tempPhone = phone;
         }
         if (string.IsNullOrEmpty(mail.Trim()))
         {
             tempMail = null;
         }
         else
         {
             tempMail = mail;
         }
         using (RepositoryMember repositoryMember = new RepositoryMember())
         {
             Member member = repositoryMember.FirstWithExplicitLoad(I => I.Ssn == ssn);
             if (member != null)
             {
                 if (member.Name == BLLHelper.TrimName(name) && member.Surname == BLLHelper.TrimSurname(surname) && member.Phone == tempPhone && member.Mail == tempMail && member.Birthday.ToString("dd.MM.yyyy") == birthday.ToString("dd.MM.yyyy"))
                 {
                     if (newPassword == newPasswordRepeat)
                     {
                         member.Password = PasswordCrypto.EncryptToSha512(newPassword);
                         repositoryMember.CUDOperation(member, EntityState.Modified);
                         return(repositoryMember.SaveChanges());
                     }
                     else
                     {
                         return(-4);
                     }
                 }
                 else
                 {
                     return(-6);
                 }
             }
             else
             {
                 return(-5);
             }
         }
     }
     else
     {
         return(-1);
     }
 }