Example #1
0
 public int MedicineUpdateRecord(Medicine medicine, string name, string type, bool?ssi, string description)
 {
     if (!string.IsNullOrEmpty(name) && !string.IsNullOrWhiteSpace(name) && !string.IsNullOrEmpty(type) && !string.IsNullOrWhiteSpace(type) && medicine != null)
     {
         string tempDescription;
         if (string.IsNullOrEmpty(description.Trim()))
         {
             tempDescription = null;
         }
         else
         {
             tempDescription = description;
         }
         using (RepositoryMedicine repositoryMedicine = new RepositoryMedicine())
         {
             if (!repositoryMedicine.AnyWithExplicitLoad(I => I.Id != medicine.Id && I.Name == name))
             {
                 medicine.Name        = name;
                 medicine.Type        = BLLHelper.GetEnumValueFromDescription <MedicineEnumType>(type);
                 medicine.Ssi         = ssi;
                 medicine.Description = tempDescription;
                 medicine.UpdateTime  = DateTime.Now;
                 repositoryMedicine.CUDOperation(medicine, EntityState.Modified);
                 return(repositoryMedicine.SaveChanges());
             }
             return(-103);
         }
     }
     else
     {
         return(-1);
     }
 }
Example #2
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);
     }
 }
Example #3
0
        public List <Doctor> GetSelectedHospitalExpertiseDoctors(Hospital hospital, DoctorEnumExpertise expertise, Member member)
        {
            DoctorEnumAgeRange ageRange = BLLHelper.GetAgeRange(member);
            List <Doctor>      doctors  = hospital.Doctors.Where(I => I.AgeRange == ageRange && I.Expertise == expertise).ToList();

            foreach (var item in doctors)
            {
                item.Age = (DateTime.Now.Year - item.Birthday.Year);
            }
            return(doctors);
        }
Example #4
0
 public int MedicineNewRecord(string name, string type, bool?ssi, string description)
 {
     if (!string.IsNullOrEmpty(name) && !string.IsNullOrWhiteSpace(name) && !string.IsNullOrEmpty(type) && !string.IsNullOrWhiteSpace(type))
     {
         string tempDescription;
         if (string.IsNullOrEmpty(description.Trim()))
         {
             tempDescription = null;
         }
         else
         {
             tempDescription = description;
         }
         using (RepositoryMedicine repositoryMedicine = new RepositoryMedicine())
         {
             if (!repositoryMedicine.AnyWithExplicitLoad(I => I.Name == name))
             {
                 Medicine medicine = new Medicine()
                 {
                     Id          = Guid.NewGuid(),
                     Name        = name,
                     Type        = BLLHelper.GetEnumValueFromDescription <MedicineEnumType>(type),
                     Description = tempDescription,
                     Ssi         = ssi
                 };
                 repositoryMedicine.CUDOperation(medicine, EntityState.Added);
                 return(repositoryMedicine.SaveChanges());
             }
             else
             {
                 return(-103);
             }
         }
     }
     else
     {
         return(-1);
     }
 }
Example #5
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);
     }
 }
Example #6
0
 public int HospitalNewRecord(string name, decimal numberOfBed, string phoneI, string phoneII, string phoneIII, string mail, string website, string city, string county, string address)
 {
     if (!string.IsNullOrEmpty(name) && !string.IsNullOrWhiteSpace(name) && !string.IsNullOrEmpty(city) && !string.IsNullOrWhiteSpace(city) && !string.IsNullOrEmpty(county) && !string.IsNullOrWhiteSpace(county))
     {
         string tempPhoneI;
         string tempPhoneII;
         string tempPhoneIII;
         string tempMail;
         string tempWebsite;
         string tempAddress;
         if (string.IsNullOrEmpty(phoneI.Trim()))
         {
             tempPhoneI = null;
         }
         else
         {
             tempPhoneI = phoneI;
         }
         if (string.IsNullOrEmpty(phoneII.Trim()))
         {
             tempPhoneII = null;
         }
         else
         {
             tempPhoneII = phoneII;
         }
         if (string.IsNullOrEmpty(phoneIII.Trim()))
         {
             tempPhoneIII = null;
         }
         else
         {
             tempPhoneIII = phoneIII;
         }
         if (string.IsNullOrEmpty(mail.Trim()))
         {
             tempMail = null;
         }
         else
         {
             tempMail = mail;
         }
         if (string.IsNullOrEmpty(website.Trim()))
         {
             tempWebsite = null;
         }
         else
         {
             tempWebsite = website;
         }
         if (string.IsNullOrEmpty(address.Trim()))
         {
             tempAddress = null;
         }
         else
         {
             tempAddress = address;
         }
         using (RepositoryHospital repositoryHospital = new RepositoryHospital())
         {
             if (!repositoryHospital.AnyWithExplicitLoad(I => I.Name == name))
             {
                 if (!repositoryHospital.AnyWithExplicitLoad(I => I.PhoneI == phoneI))
                 {
                     if (!repositoryHospital.AnyWithExplicitLoad(I => I.PhoneII == phoneII))
                     {
                         if (!repositoryHospital.AnyWithExplicitLoad(I => I.PhoneIII == phoneIII))
                         {
                             if (!repositoryHospital.AnyWithExplicitLoad(I => I.Mail == mail))
                             {
                                 if (!repositoryHospital.AnyWithExplicitLoad(I => I.Address == address))
                                 {
                                     Hospital hospital = new Hospital()
                                     {
                                         Id          = Guid.NewGuid(),
                                         Name        = name,
                                         NumberOfBed = (int)numberOfBed,
                                         PhoneI      = tempPhoneI,
                                         PhoneII     = tempPhoneII,
                                         PhoneIII    = tempPhoneIII,
                                         Mail        = tempMail,
                                         Website     = tempWebsite,
                                         City        = city,
                                         County      = county,
                                         Address     = tempAddress,
                                         Picture     = BLLHelper.DefaultHospitalPic()
                                     };
                                     repositoryHospital.CUDOperation(hospital, EntityState.Added);
                                     return(repositoryHospital.SaveChanges());
                                 }
                                 else
                                 {
                                     return(-109);
                                 }
                             }
                             else
                             {
                                 return(-108);
                             }
                         }
                         else
                         {
                             return(-107);
                         }
                     }
                     else
                     {
                         return(-106);
                     }
                 }
                 else
                 {
                     return(-105);
                 }
             }
             else
             {
                 return(-104);
             }
         }
     }
     else
     {
         return(-1);
     }
 }
Example #7
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);
     }
 }
Example #8
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);
        }