Esempio n. 1
0
 public Users Get(int personaId)
 {
     using (var context = new QuirofanoEntities())
     {
         return (from p in context.Users where p.PersonaId == personaId select p).FirstOrDefault();
     }
 }
Esempio n. 2
0
        public void Update(Personas oPersona)
        {
            using (var context = new QuirofanoEntities())
            {
                //Personas per = context.Personas.First(i => i.PersonaId == oPersona.PersonaId);

                //per.ApellidoNombre = oPersona.ApellidoNombre;
                //per.Domicilio = oPersona.Domicilio;
                //per.Telefono = oPersona.Telefono;
                //per.Email = oPersona.Email;
                //per.FechaFallecimiento = oPersona.FechaFallecimiento;
                //per.FechaNacimiento = oPersona.FechaNacimiento;
                //per.NacionalidadId = oPersona.NacionalidadId;
                //per.Sexo = oPersona.Sexo;
                //per.NroDoc = oPersona.NroDoc;
                //per.LocaResidenciaId = oPersona.LocaResidenciaId;
                //per.Importado = false;

                //int inte = context.SaveChanges();

                context.Personas.Attach(context.Personas.Single(i => i.PersonaId == oPersona.PersonaId));

                context.Personas.ApplyCurrentValues(oPersona);

                int inte = context.SaveChanges(System.Data.Objects.SaveOptions.DetectChangesBeforeSave);
            }
        }
Esempio n. 3
0
 public List<Personas> GetList(string apeNom, int? nroDoc)
 {
     using (var context = new QuirofanoEntities())
     {
         return (from p in context.Personas where (p.ApellidoNombre.Contains(apeNom.ToUpper()) || apeNom == "") && (p.NroDoc == nroDoc || nroDoc == null) select p).ToList();
     }
 }
Esempio n. 4
0
 public Personas Get(int personaId)
 {
     using (var context = new QuirofanoEntities())
     {
         return (from p in context.Personas.Include("Localidad").Include("Localidad.Provincia").Include("Pais") where p.PersonaId == personaId select p).FirstOrDefault();
     }
 }
Esempio n. 5
0
        public int Insert(Personas persona)
        {
            using (var context = new QuirofanoEntities())
            {
                context.Personas.AddObject(persona);

                context.SaveChanges();

                return persona.PersonaId;
            }
        }
Esempio n. 6
0
        public void Insert(Users user)
        {
            try
            {
                using (var context = new QuirofanoEntities())
                {
                    context.Users.AddObject(user);

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Message.Contains("23505"))
                    throw new Exception("Error: no puede asignar dos formas de pago con la misma descripción.");
            }
        }
Esempio n. 7
0
File: Admin.cs Progetto: GeraElem/VS
        public void AddPais(Pais pais)
        {
            try
            {
                using (var context = new QuirofanoEntities())
                {
                    context.Pais.AddObject(pais);

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Message.Contains("23505"))
                    throw new Exception("Error: no puede asignar dos paises con el mismo nombre.");
            }
        }
Esempio n. 8
0
File: Admin.cs Progetto: GeraElem/VS
        public void AddMenuRoles(MenusRoles menuRol)
        {
            try
            {
                using (var context = new QuirofanoEntities())
                {
                    context.MenusRoles.AddObject(menuRol);

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Message.Contains("23505"))
                    throw new Exception("Error: no puede asignar dos menu con el mismo rol.");
            }
        }
Esempio n. 9
0
File: Admin.cs Progetto: GeraElem/VS
        public void AddFavorito(Favoritos fav)
        {
            try
            {
                using (var context = new QuirofanoEntities())
                {
                    context.Favoritos.AddObject(fav);

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Message.Contains("23505"))
                    throw new Exception("Error: no puede asignar dos veces el mismo favorito.");
            }
        }
Esempio n. 10
0
File: Web.cs Progetto: GeraElem/VS
        public void AddDisciplinasList(List<WebDisciplinas> list)
        {
            try
            {
                using (var context = new QuirofanoEntities())
                {
                    foreach (WebDisciplinas item in list)
                    {
                        context.WebDisciplinas.AddObject(item);
                    }

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 11
0
        public void Update(Users user)
        {
            using (var context = new QuirofanoEntities())
            {
                //Users user2 = context.Users.First(i => i.PersonaId == user.PersonaId);

                //user2.Password = user.Password;
                //user2.Activo = user.Activo;
                //user2.RolId = user.RolId;

                //context.SaveChanges();

                context.Users.Attach(context.Users.Single(i => i.UserId == user.UserId));

                context.Users.ApplyCurrentValues(user);

                int inte = context.SaveChanges(System.Data.Objects.SaveOptions.DetectChangesBeforeSave);
            }
        }
Esempio n. 12
0
File: Web.cs Progetto: GeraElem/VS
        public void AddMenu(WebMenu menu)
        {
            try
            {
                using (var context = new QuirofanoEntities())
                {
                    context.WebMenu.AddObject(menu);

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Message.Contains("23505"))
                    throw new Exception("Error: no puede asignar dos menus con el mismo nombre.");
                else
                    throw new Exception(ex.Message);
            }
        }
Esempio n. 13
0
        public void Delete(int personaId)
        {
            try
            {
                using (var context = new QuirofanoEntities())
                {

                    Personas valor = (from p in context.Personas where p.PersonaId == personaId select p).FirstOrDefault();

                    context.Personas.DeleteObject(valor);

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Message.Contains("23503"))
                    throw new Exception("Error: no puede eliminar el registro ya que tiene relación con otras tablas.");
            }
        }
Esempio n. 14
0
File: Web.cs Progetto: GeraElem/VS
        public void AddTablasDatosList(List<WebTorneosDatos> list)
        {
            try
            {
                using (var context = new QuirofanoEntities())
                {
                    foreach (WebTorneosDatos item in list)
                    {
                        context.WebTorneosDatos.AddObject(item);
                    }

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Message.Contains("unique index"))
                    throw new Exception("Error: Hay datos del excel que ya se encuentran importados.");
                else
                    throw ex;
            }
        }
Esempio n. 15
0
File: Web.cs Progetto: GeraElem/VS
        public int UpdateNoticia(WebNoticias noticia)
        {
            using (var context = new QuirofanoEntities())
            {
                //WebNoticias noticiaUp = context.WebNoticias.First(i => i.WebNoticiasId == noticia.WebNoticiasId);

                //noticiaUp.Fecha = noticia.Fecha;
                //noticiaUp.Titulo = noticia.Titulo;
                //noticiaUp.Resumen = noticia.Resumen;
                //noticiaUp.Estado = noticia.Estado;
                //noticiaUp.Contenido = noticia.Contenido;
                //noticiaUp.Autor = noticia.Autor;
                //noticiaUp.WebMenuId = noticia.WebMenuId;

                //context.SaveChanges();

                context.WebNoticias.Attach(context.WebNoticias.Single(i => i.WebNoticiasId == noticia.WebNoticiasId));

                context.WebNoticias.ApplyCurrentValues(noticia);

                int inte = context.SaveChanges(SaveOptions.DetectChangesBeforeSave);

                return noticia.WebNoticiasId;
            }
        }
Esempio n. 16
0
File: Web.cs Progetto: GeraElem/VS
        public void UpdateMenu(WebMenu menu)
        {
            using (var context = new QuirofanoEntities())
            {
                //WebMenu menu2 = context.WebMenu.First(i => i.WebMenuId == menu.WebMenuId);

                //menu2.Descripcion = menu.Descripcion;
                //menu2.Orden = menu.Orden;
                //menu2.Url = menu.Url;
                //menu2.Estado = menu.Estado;

                context.WebMenu.Attach(context.WebMenu.Single(i => i.WebMenuId == menu.WebMenuId));

                context.WebMenu.ApplyCurrentValues(menu);

                int inte = context.SaveChanges(SaveOptions.DetectChangesBeforeSave);

                context.SaveChanges();
            }
        }
Esempio n. 17
0
File: Web.cs Progetto: GeraElem/VS
 public IList<WebNoticias> SearchNoticias(string palabra, int? seccion, bool titulo, bool resumen, bool contenido, bool autor, DateTime? fechaDesde, DateTime? fechaHasta, bool? estadoId, Int32 max)
 {
     using (var context = new QuirofanoEntities())
     {
         return (from p in context.WebNoticias.Include("WebMenu")
                 where ((titulo && p.Titulo.Contains(palabra)) || !titulo) &&
                         ((resumen && p.Resumen.Contains(palabra)) || !resumen) &&
                         ((contenido && p.Contenido.Contains(palabra)) || !contenido) &&
                         ((autor && p.Autor.Contains(palabra)) || !autor) &&
                         ((seccion != 0 && p.WebMenuId == seccion) || seccion==0) &&
                         ((estadoId != null && p.Estado == estadoId) || estadoId == null) &&
                         ((fechaDesde != null && p.Fecha >= fechaDesde) || fechaDesde == null) &&
                         ((fechaHasta != null && p.Fecha <= fechaHasta) || fechaHasta == null)
                 select p).OrderByDescending(m => m.Fecha).Take(max).ToList();
     }
 }
Esempio n. 18
0
File: Web.cs Progetto: GeraElem/VS
 public IList<WebNoticias> SearchNoticias(string palabra, bool titulo, bool resumen, bool contenido, bool autor, Int32 max)
 {
     using (var context = new QuirofanoEntities())
     {
         return (from p in context.WebNoticias
                 where (titulo && p.Titulo.Contains(palabra)) ||
                         (resumen && p.Resumen.Contains(palabra)) ||
                         (contenido && p.Contenido.Contains(palabra)) ||
                         (autor && p.Autor.Contains(palabra))
                 select p).OrderByDescending(m => m.Fecha).Take(max).ToList();
     }
 }
Esempio n. 19
0
File: Web.cs Progetto: GeraElem/VS
 public WebMenu GetMenu(int menuId)
 {
     using (var context = new QuirofanoEntities())
     {
         return (from p in context.WebMenu where p.WebMenuId == menuId select p).FirstOrDefault();
     }
 }
Esempio n. 20
0
File: Web.cs Progetto: GeraElem/VS
 public List<Aux> GetHistorial(int tablaId)
 {
     using (var context = new QuirofanoEntities())
     {
         var q = (from n in context.WebTorneosDatos
                 where n.WebTorneosTablaId==tablaId
                 group n by n.FechaCarga into g
                 select new Aux { value = g.Max(t => t.FechaCarga) }).OrderByDescending(t => t.value).ToList();
         return q;
     }
 }
Esempio n. 21
0
File: Web.cs Progetto: GeraElem/VS
 public List<WebTorneos> GetTorneos(int? disciplinaId)
 {
     using (var context = new QuirofanoEntities())
     {
         if (disciplinaId != null)
             return (from p in context.WebTorneos.Include("WebDisciplinas") where p.WebDisciplinaId == disciplinaId select p).ToList();
         else
             return (from p in context.WebTorneos.Include("WebDisciplinas") select p).OrderBy(m => m.WebDisciplinas.Descripcion).ThenBy(m => m.FechaInicio).ToList();
     }
 }
Esempio n. 22
0
File: Web.cs Progetto: GeraElem/VS
 public List<WebTorneosDatos> GetTablasDatos(int tablaId)
 {
     using (var context = new QuirofanoEntities())
     {
         return (from p in context.WebTorneosDatos where p.WebTorneosTablaId == tablaId select p).ToList();
     }
 }
Esempio n. 23
0
File: Web.cs Progetto: GeraElem/VS
 public WebTorneosDatos GetTablaHeader(int tablaId, DateTime fecha)
 {
     using (var context = new QuirofanoEntities())
     {
         return (from p in context.WebTorneosDatos.Include("WebTorneosTablas").Include("WebTorneosTablas.WebTorneos")
                 where
                     p.WebTorneosTablaId == tablaId &&
                     p.FechaCarga == fecha
                 select p).FirstOrDefault();
     }
 }
Esempio n. 24
0
File: Web.cs Progetto: GeraElem/VS
 public IList<WebNoticias> GetListNoticias(int? seccionId, Int32 max)
 {
     using (var context = new QuirofanoEntities())
     {
         return (from p in context.WebNoticias where
                     p.WebMenuId == seccionId || seccionId == null
                 select p).OrderByDescending(m => m.Fecha).Take(max).ToList();
     }
 }
Esempio n. 25
0
File: Web.cs Progetto: GeraElem/VS
 public WebNoticias GetNoticia(int? noticiaId)
 {
     using (var context = new QuirofanoEntities())
     {
         return (from p in context.WebNoticias.Include("WebMenu") where p.WebNoticiasId == noticiaId select p).FirstOrDefault();
     }
 }
Esempio n. 26
0
File: Web.cs Progetto: GeraElem/VS
 public List<WebDisciplinas> GetMenuDisciplinas()
 {
     using (var context = new QuirofanoEntities())
     {
         return (from p in context.WebDisciplinas.Include("WebTorneos").Include("WebTorneos.WebTorneosTablas").Include("WebTorneos.WebTorneosTablas.WebTorneosDatos") select p).ToList();
     }
 }
Esempio n. 27
0
File: Web.cs Progetto: GeraElem/VS
 public List<WebMenu> GetListMenu()
 {
     using (var context = new QuirofanoEntities())
     {
         return (from p in context.WebMenu where p.Url == "/News.aspx" select p).OrderBy(m => m.Orden).ToList();
     }
 }
Esempio n. 28
0
File: Web.cs Progetto: GeraElem/VS
 public List<WebMenu> Menus()
 {
     using (var context = new QuirofanoEntities())
     {
         return (from p in context.WebMenu where p.Estado == true select p).OrderBy(m => m.Orden).ToList();
     }
 }
Esempio n. 29
0
File: Web.cs Progetto: GeraElem/VS
        public int SaveNoticia(WebNoticias noticia)
        {
            using (var context = new QuirofanoEntities())
            {
                context.WebNoticias.AddObject(noticia);

                context.SaveChanges();

                return noticia.WebNoticiasId;
            }
        }
Esempio n. 30
0
File: Web.cs Progetto: GeraElem/VS
        public IList<WebTorneosDatos> GetListTablaDatos(int tablaId, DateTime? fecha)
        {
            using (var context = new QuirofanoEntities())
            {
                //var q = (from n in context.WebTorneosDatos
                //        where n.WebTorneosTablaId==tablaId
                //        group n by n.FechaCarga into g
                //        select new { Date = g.Max(t => t.FechaCarga) }).OrderByDescending(t => t.Date).First();

                return (from p in context.WebTorneosDatos
                        where
                            p.WebTorneosTablaId == tablaId && p.FechaCarga == fecha
                        select p).OrderBy(m => m.Orden).ToList();
            }
        }