Exemple #1
0
 public List <Hospital> GetDeletedHospital()
 {
     using (RepositoryHospital repositoryHospital = new RepositoryHospital())
     {
         return(repositoryHospital.WhereWithExplicitLoad(I => I.IsActive == false).ToList());
     }
 }
Exemple #2
0
 public List <Hospital> GetSelectedCityHospitals(City city)
 {
     using (RepositoryHospital repositoryHospital = new RepositoryHospital())
     {
         return(repositoryHospital.WhereWithExplicitLoad(I => I.IsActive == true && I.City == city.Name, I => I.OrderBy(J => J.Name), paths: new string[] { "Doctors", "Appointments" }).ToList());
     }
 }
Exemple #3
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());
     }
 }
Exemple #4
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);
     }
 }
Exemple #5
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);
     }
 }
Exemple #6
0
        public List <City> GetHospitalCities()
        {
            using (RepositoryCity repositoryCity = new RepositoryCity())
            {
                List <Hospital> hospitals = new List <Hospital>();
                using (RepositoryHospital repositoryHospital = new RepositoryHospital())
                {
                    hospitals = repositoryHospital.WhereWithExplicitLoad(I => I.IsActive == true).ToList();
                }

                List <City> cities = new List <City>();
                foreach (var item in hospitals)
                {
                    cities.AddRange(repositoryCity.WhereWithExplicitLoad(I => I.Name == item.City, I => I.OrderBy(J => J.Name)).ToList());
                }

                return(cities.Distinct().ToList());
            }
        }
        public void OnException(ExceptionContext filterContext)
        {
            if (filterContext.ExceptionHandled == false)
            {
                String             mensaje     = filterContext.Exception.Message;
                String             controlador = filterContext.RouteData.Values["controller"].ToString();
                RepositoryHospital repo        = new RepositoryHospital();
                repo.InsertarExcepcion(mensaje, controlador, DateTime.Now);
                //MANEJAMOS LA EXCEPCION
                filterContext.ExceptionHandled = true;

                //En algun momento nos llevaremos los datos a una vista de errores en doctor
                RouteValueDictionary rutaerror = new RouteValueDictionary(new  {
                    controller = "Doctores", action = "ErrorSalarios"
                });
                RedirectToRouteResult direccion = new RedirectToRouteResult(rutaerror);
                filterContext.Result = direccion;
            }
        }
 public EnfermosController()
 {
     this.repo = new RepositoryHospital();
 }
 public HospitalController(RepositoryHospital repo)
 {
     this.repo = repo;
 }
Exemple #10
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);
     }
 }
Exemple #11
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);
     }
 }
Exemple #12
0
 public EnfermosController(RepositoryHospital repo)
 {
     this.repo = repo;
 }
Exemple #13
0
 public AjaxController()
 {
     this.repo = new RepositoryHospital();
 }
 public DoctoresController()
 {
     this.repo = new RepositoryHospital();
 }
Exemple #15
0
 public HospitalController(RepositoryHospital repository)
 {
     this.repository = repository;
 }