Esempio n. 1
0
        /// <summary>
        /// Retorna  HealthInstitutionList del profecional donde el profecional es ouner
        /// </summary>
        /// <param name="pPrefesionalId"></param>
        /// <returns></returns>
        public static Health.BE.HealthInstitutionList Retrive_HealthInstitution(int pPrefesionalId, Boolean asOwner, Boolean asAdmin)
        {
            using (Health.Back.BE.HealthEntities dc = new Health.Back.BE.HealthEntities(Common.CnnString_Entities))
            {
                List <Health.Back.BE.HealthInstitution> list2 = null;
                if (asOwner)
                {
                    list2 = (from s in dc.HealthInstitutions
                             from p in dc.HealthInstitution_Profesional
                             where
                             s.HealthInstitutionId.Equals(p.HealthInstitutionId) &&
                             p.ProfesionalId.Equals(pPrefesionalId) &&
                             asOwner && p.IsOwner.Equals(true)
                             select s).ToList <Health.Back.BE.HealthInstitution>();
                }

                if (asAdmin)
                {
                    list2 = (from s in dc.HealthInstitutions
                             from p in dc.HealthInstitution_Profesional
                             where
                             s.HealthInstitutionId.Equals(p.HealthInstitutionId) &&
                             p.ProfesionalId.Equals(pPrefesionalId) &&
                             p.IsAdmin.Equals(true)
                             select s).ToList <Health.Back.BE.HealthInstitution>();
                }

                HealthInstitutionList wHealthInstitutionList = new HealthInstitutionList();
                HealthInstitutionBE   wHealthInstitutionBE;

                foreach (Health.Back.BE.HealthInstitution i in list2)
                {
                    wHealthInstitutionBE = (HealthInstitutionBE)i;
                    //Si es argentina rellenar nombres
                    if (wHealthInstitutionBE.CountryId == 11000)
                    {
                        wHealthInstitutionBE.Province = i.Parametro2.Nombre;
                        wHealthInstitutionBE.City     = i.Parametro1.Nombre;
                        wHealthInstitutionBE.Country  = i.Parametro.Nombre;//FK_HealthInstitution_Parametros_Country
                    }
                    wHealthInstitutionList.Add(wHealthInstitutionBE);
                }

                return(wHealthInstitutionList);
            }
        }
        /// <summary>
        /// Retorna los Guid hijos
        /// </summary>
        /// <param name="healttInstId"></param>
        /// <returns></returns>
        public static List <Guid> RetriveHealthInstitution_Childs_Ids(Guid healttInstId)
        {
            HealthInstitutionList wHealthInstitutionList = new HealthInstitutionList();

            using (Health.Back.BE.HealthEntities dc = new Health.Back.BE.HealthEntities(Common.CnnString_Entities))
            {
                var childs = from s in dc.HealthInstitutions where s.HealthInstitutionIdParent.Equals(healttInstId) select s.HealthInstitutionId;
                if (childs.Count() != 0)
                {
                    return(childs.ToList <Guid>());
                }
                else
                {
                    return(null);
                }
            }
        }
        /// <summary>
        /// Retorna HealthInstitutionList filtrando por RazonSocial
        /// </summary>
        /// <param name="textToSearh">Filtro</param>
        /// <returns></returns>
        public static HealthInstitutionList RetriveHealthInstitutionByParams(string textToSearh)
        {
            HealthInstitutionList wHealthInstitutionList = null;

            using (Health.Back.BE.HealthEntities dc = new Health.Back.BE.HealthEntities(Common.CnnString_Entities))
            {
                var list = dc.HealthInstitutions.Where(s => s.RazonSocial.Contains(textToSearh));

                wHealthInstitutionList = new HealthInstitutionList();
                foreach (Health.Back.BE.HealthInstitution p in list)
                {
                    wHealthInstitutionList.Add((HealthInstitutionBE)p);
                }


                return(wHealthInstitutionList);
            }
        }
        /// <summary>
        /// Retorna HealthInstitutionList filtrando por healttInstId
        ///
        /// obtiene la institucion por id mas sus hermanas y padre
        /// </summary>
        /// <param name="textToSearh">Filtro</param>
        /// <returns></returns>
        public static HealthInstitutionList RetriveHealthInstitution_Relateds(Guid healttInstId)
        {
            HealthInstitutionList wHealthInstitutionList = new HealthInstitutionList();

            using (Health.Back.BE.HealthEntities dc = new Health.Back.BE.HealthEntities(Common.CnnString_Entities))
            {
                Health.Back.BE.HealthInstitution inst = dc.HealthInstitutions.Where(s => s.HealthInstitutionId.Equals(healttInstId)).FirstOrDefault();
                if (inst != null)
                {
                    wHealthInstitutionList.Add((HealthInstitutionBE)inst);
                }


                //Si es padre buscar hijas.. Si no tiene valor es por q es padre
                if (!inst.HealthInstitutionIdParent.HasValue)
                {
                    var childs = dc.HealthInstitutions.Where(s => s.HealthInstitutionIdParent.Equals(healttInstId));
                    foreach (Health.Back.BE.HealthInstitution p in childs)
                    {
                        wHealthInstitutionList.Add((HealthInstitutionBE)p);
                    }
                }
                //Buscar hermanas
                else
                {
                    var subyasents = dc.HealthInstitutions.Where(s => s.HealthInstitutionIdParent.Equals(inst.HealthInstitutionIdParent));
                    foreach (Health.Back.BE.HealthInstitution p in subyasents)
                    {
                        wHealthInstitutionList.Add((HealthInstitutionBE)p);
                    }
                }
                //Agregar el padre
                inst = dc.HealthInstitutions.Where(s => s.HealthInstitutionId.Equals(inst.HealthInstitutionIdParent)).FirstOrDefault();
                if (inst != null)
                {
                    wHealthInstitutionList.Add((HealthInstitutionBE)inst);
                }



                return(wHealthInstitutionList);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Retorna  HealthInstitutionList del profecional donde el profecional es ouner
        /// </summary>
        /// <param name="pPrefesionalId"></param>
        /// <returns></returns>
        public static Health.BE.HealthInstitutionList Retrive_HealthInstitution(int pPrefesionalId, Boolean asOwner, Boolean asAdmin)
        {
            using (Health.Back.BE.HealthEntities dc = new Health.Back.BE.HealthEntities(Common.CnnString_Entities))
            {
                List<Health.Back.BE.HealthInstitution> list2 = null;
                if (asOwner)
                    list2 = (from s in dc.HealthInstitutions
                            from p in dc.HealthInstitution_Profesional
                            where
                             s.HealthInstitutionId.Equals(p.HealthInstitutionId) &&
                             p.ProfesionalId.Equals(pPrefesionalId) &&
                            asOwner && p.IsOwner.Equals(true)
                             select s).ToList < Health.Back.BE.HealthInstitution>();

                if (asAdmin)
                    list2 = (from s in dc.HealthInstitutions
                            from p in dc.HealthInstitution_Profesional
                            where
                             s.HealthInstitutionId.Equals(p.HealthInstitutionId) &&
                             p.ProfesionalId.Equals(pPrefesionalId) &&
                                p.IsAdmin.Equals(true)
                            select s).ToList < Health.Back.BE.HealthInstitution>();

                HealthInstitutionList wHealthInstitutionList = new HealthInstitutionList();
                HealthInstitutionBE wHealthInstitutionBE;

                foreach (Health.Back.BE.HealthInstitution i in list2)
                {
                    wHealthInstitutionBE = (HealthInstitutionBE)i;
                    //Si es argentina rellenar nombres
                    if (wHealthInstitutionBE.CountryId == 11000)
                    {
                        wHealthInstitutionBE.Province = i.Parametro2.Nombre;
                        wHealthInstitutionBE.City = i.Parametro1.Nombre;
                        wHealthInstitutionBE.Country = i.Parametro.Nombre;//FK_HealthInstitution_Parametros_Country

                    }
                    wHealthInstitutionList.Add(wHealthInstitutionBE);
                }

                return wHealthInstitutionList;
            }

        }
        /// <summary>
        /// Retorna los Guid hijos
        /// </summary>
        /// <param name="healttInstId"></param>
        /// <returns></returns>
        public static List<Guid> RetriveHealthInstitution_Childs_Ids(Guid healttInstId)
        {
            HealthInstitutionList wHealthInstitutionList = new HealthInstitutionList();
            using (Health.Back.BE.HealthEntities dc = new Health.Back.BE.HealthEntities(Common.CnnString_Entities))
            {


                var childs = from s in dc.HealthInstitutions where s.HealthInstitutionIdParent.Equals(healttInstId) select s.HealthInstitutionId;
                if (childs.Count() != 0)
                    return childs.ToList<Guid>();
                else
                    return null;


            }
        }
        /// <summary>
        /// Retorna HealthInstitutionList filtrando por healttInstId
        /// 
        /// obtiene la institucion por id mas sus hermanas y padre
        /// </summary>
        /// <param name="textToSearh">Filtro</param>
        /// <returns></returns>
        public static HealthInstitutionList RetriveHealthInstitution_Relateds(Guid healttInstId)
        {
            HealthInstitutionList wHealthInstitutionList = new HealthInstitutionList ();
            using (Health.Back.BE.HealthEntities dc = new Health.Back.BE.HealthEntities(Common.CnnString_Entities))
            {

                Health.Back.BE.HealthInstitution inst = dc.HealthInstitutions.Where(s => s.HealthInstitutionId.Equals(healttInstId)).FirstOrDefault();
                if (inst != null)
                    wHealthInstitutionList.Add((HealthInstitutionBE)inst);
               

                //Si es padre buscar hijas.. Si no tiene valor es por q es padre
                if (!inst.HealthInstitutionIdParent.HasValue)
                {
                    var childs = dc.HealthInstitutions.Where(s => s.HealthInstitutionIdParent.Equals(healttInstId));
                    foreach (Health.Back.BE.HealthInstitution p in childs)
                    {
                        wHealthInstitutionList.Add((HealthInstitutionBE)p);
                    }
                }
                //Buscar hermanas
                else
                {
                    var subyasents = dc.HealthInstitutions.Where(s => s.HealthInstitutionIdParent.Equals(inst.HealthInstitutionIdParent));
                    foreach (Health.Back.BE.HealthInstitution p in subyasents)
                    {
                        wHealthInstitutionList.Add((HealthInstitutionBE)p);
                    }
                }
                //Agregar el padre
                inst = dc.HealthInstitutions.Where(s => s.HealthInstitutionId.Equals(inst.HealthInstitutionIdParent)).FirstOrDefault();
                if (inst != null)
                    wHealthInstitutionList.Add((HealthInstitutionBE)inst);
               


                return wHealthInstitutionList;
            }
        }
        /// <summary>
        /// Retorna HealthInstitutionList filtrando por RazonSocial
        /// </summary>
        /// <param name="textToSearh">Filtro</param>
        /// <returns></returns>
        public static HealthInstitutionList RetriveHealthInstitutionByParams(string textToSearh)
        {
            HealthInstitutionList wHealthInstitutionList = null;
            using (Health.Back.BE.HealthEntities dc = new Health.Back.BE.HealthEntities(Common.CnnString_Entities))
            {

                var list = dc.HealthInstitutions.Where(s => s.RazonSocial.Contains(textToSearh));

                wHealthInstitutionList = new HealthInstitutionList();
                foreach (Health.Back.BE.HealthInstitution p in list)
                {
                    wHealthInstitutionList.Add((HealthInstitutionBE)p);
                }


                return wHealthInstitutionList;
            }
        }