コード例 #1
0
 public int HospitalUpdateRecord(Hospital hospital, string picture)
 {
     using (RepositoryHospital repositoryHospital = new RepositoryHospital())
     {
         Image        image = Image.FromFile(picture);
         MemoryStream mem   = new MemoryStream();
         image.Save(mem, ImageFormat.Png);
         hospital.Picture = mem.ToArray();
         repositoryHospital.CUDOperation(hospital, EntityState.Modified);
         return(repositoryHospital.SaveChanges());
     }
 }
コード例 #2
0
 public int HospitalDeleteRecord(Hospital hospital)
 {
     if (hospital != null)
     {
         using (RepositoryHospital repositoryHospital = new RepositoryHospital())
         {
             hospital.DeleteTime = DateTime.Now;
             hospital.IsActive   = false;
             repositoryHospital.CUDOperation(hospital, EntityState.Modified);
             return(repositoryHospital.SaveChanges());
         }
     }
     else
     {
         return(-1);
     }
 }
コード例 #3
0
 public int ReactivateData <Entity>(Entity entity)
 {
     if (entity is Hospital)
     {
         using (RepositoryHospital repositoryHospital = new RepositoryHospital())
         {
             (entity as Hospital).IsActive = true;
             repositoryHospital.CUDOperation(entity as Hospital, EntityState.Modified);
             return(repositoryHospital.SaveChanges());
         }
     }
     else if (entity is Doctor)
     {
         using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor())
         {
             (entity as Doctor).IsActive = true;
             repositoryDoctor.CUDOperation(entity as Doctor, EntityState.Modified);
             return(repositoryDoctor.SaveChanges());
         }
     }
     else if (entity is Member)
     {
         using (RepositoryMember repositoryMember = new RepositoryMember())
         {
             (entity as Member).IsActive = true;
             repositoryMember.CUDOperation(entity as Member, EntityState.Modified);
             return(repositoryMember.SaveChanges());
         }
     }
     else if (entity is Medicine)
     {
         using (RepositoryMedicine repositoryMedicine = new RepositoryMedicine())
         {
             (entity as Medicine).IsActive = true;
             repositoryMedicine.CUDOperation(entity as Medicine, EntityState.Modified);
             return(repositoryMedicine.SaveChanges());
         }
     }
     else
     {
         return(-1);
     }
 }
コード例 #4
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);
     }
 }
コード例 #5
0
 public int HospitalUpdateRecord(Hospital hospital, 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) && hospital != null)
     {
         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.Id != hospital.Id && I.Name == name))
             {
                 if (!repositoryHospital.AnyWithExplicitLoad(I => I.Id != hospital.Id && I.PhoneI == phoneI))
                 {
                     if (!repositoryHospital.AnyWithExplicitLoad(I => I.Id != hospital.Id && I.PhoneII == phoneII))
                     {
                         if (!repositoryHospital.AnyWithExplicitLoad(I => I.Id != hospital.Id && I.PhoneIII == phoneIII))
                         {
                             if (!repositoryHospital.AnyWithExplicitLoad(I => I.Id != hospital.Id && I.Mail == mail))
                             {
                                 if (!repositoryHospital.AnyWithExplicitLoad(I => I.Id != hospital.Id && I.Address == address))
                                 {
                                     hospital.Name        = name;
                                     hospital.NumberOfBed = (int)numberOfBed;
                                     hospital.PhoneI      = tempPhoneI;
                                     hospital.PhoneII     = tempPhoneII;
                                     hospital.PhoneIII    = tempPhoneIII;
                                     hospital.Mail        = tempMail;
                                     hospital.Website     = tempWebsite;
                                     hospital.City        = city;
                                     hospital.County      = county;
                                     hospital.Address     = tempAddress;
                                     hospital.UpdateTime  = DateTime.Now;
                                     repositoryHospital.CUDOperation(hospital, EntityState.Modified);
                                     return(repositoryHospital.SaveChanges());
                                 }
                                 else
                                 {
                                     return(-109);
                                 }
                             }
                             else
                             {
                                 return(-108);
                             }
                         }
                         else
                         {
                             return(-107);
                         }
                     }
                     else
                     {
                         return(-106);
                     }
                 }
                 else
                 {
                     return(-105);
                 }
             }
             else
             {
                 return(-104);
             }
         }
     }
     else
     {
         return(-1);
     }
 }