Exemplo n.º 1
0
 public static void addPost(DTO.Post post)
 {
     using (ReloadEntities db = new ReloadEntities())
     {
         db.TBL_POSTS.Add(new TBL_POSTS
         {
             POST_TITULO           = post.titulo,
             POST_CATEGORIA        = post.categoria.id,
             POST_CANT_COMENTARIOS = 0,
             POST_CONTENIDO_EDIT   = post.contenido,
             POST_COTENIDO         = post.contenido,
             POST_DEBAJA           = false,
             POST_FAVORITOS        = 0,
             POST_FECALT           = DateTime.Now,
             POST_FECMOD           = DateTime.Now,
             POST_PROPIETARIO      = post.propietario.id,
             POST_IMAGEN           = post.imagen,
             POST_PUNTOS           = 0,
             POST_SEGUIDORES       = 0,
             POST_SE_COMENTA       = post.seComenta,
             POST_STICKY           = post.sticky,
             POST_TAGS             = post.etiquetas,
             POST_VISITAS          = 0
         });
         db.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public static void deletePost(Post post)
 {
     using (ReloadEntities db = new ReloadEntities())
     {
         db.TBL_POSTS.Single(x => x.POST_ID == post.id).POST_DEBAJA = true;
         db.SaveChanges();
     }
 }
Exemplo n.º 3
0
 public static void grabarMail(string usuarioCodigo, string mail)
 {
     using (ReloadEntities db = new ReloadEntities())
     {
         db.TBL_USUARIOS.Single(x => x.USUARIO_CODIGO == usuarioCodigo).USUARIO_MAIL = mail;
         db.SaveChanges();
     }
 }
Exemplo n.º 4
0
 public static void grabarClave(string codigo, string claveNueva)
 {
     using (ReloadEntities db = new ReloadEntities())
     {
         db.TBL_USUARIOS.Single(x => x.USUARIO_CODIGO == codigo).USUARIO_PASSWORD = claveNueva;
         db.SaveChanges();
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// busca un usuario por su mail, y lo pone como activo.
 /// </summary>
 public static void actualizarActivoPorMail(string mail)
 {
     using (ReloadEntities db = new ReloadEntities())
     {
         db.TBL_USUARIOS.Single(x => x.USUARIO_MAIL == mail).USUARIO_ACTIVO = true;
         db.SaveChanges();
     }
 }
Exemplo n.º 6
0
 public static void visit(int idPost)
 {
     using (ReloadEntities db = new ReloadEntities())
     {
         db.TBL_POSTS.Single(x => x.POST_ID == idPost).POST_VISITAS++;
         db.SaveChanges();
     }
 }
Exemplo n.º 7
0
 public static void addPoints(Punto contenido)
 {
     using (ReloadEntities db = new ReloadEntities())
     {
         db.TBL_POSTS.Single(x => x.POST_ID == contenido.idPost).POST_PUNTOS += contenido.cuantos;
         db.SaveChanges();
     }
 }
Exemplo n.º 8
0
 public static Pais[] getPaises()
 {
     using (ReloadEntities db = new ReloadEntities())
     {
         return((from a in db.TBL_PAISES select new Pais {
             codigo = a.PAIS_CODIGO, nombre = a.PAIS_NOMBRE, id = a.PAIS_ID
         }).ToArray());
     }
 }
Exemplo n.º 9
0
 public static Usuario obtenerUsuarioPorMail(string mail)
 {
     using (ReloadEntities db = new ReloadEntities()) {
         return((from a in db.TBL_USUARIOS
                 where a.USUARIO_MAIL == mail
                 select new Usuario
         {
             codigo = a.USUARIO_CODIGO
         }).FirstOrDefault());
     }
 }
Exemplo n.º 10
0
 public static Categoria[] getCategorias()
 {
     using (ReloadEntities db = new ReloadEntities())
     {
         return((from a in db.TBL_CATEGORIAS select new Categoria
         {
             id = a.CATEGORIA_ID,
             nombre = a.CATEGORIA_NOMBRE,
             logo = a.CATEGORIA_LOGO
         }).ToArray());
     }
 }
Exemplo n.º 11
0
        public static List <PostDestacado> obtenerPostPorPuntos(int cuantos)
        {
            using (ReloadEntities db = new ReloadEntities())
            {
                return((from a in (from post in db.TBL_POSTS
                                   where !post.POST_DEBAJA
                                   select new Post
                {
                    activo = post.POST_DEBAJA,
                    categoria = new Categoria
                    {
                        id = post.TBL_CATEGORIAS.CATEGORIA_ID,
                        logo = post.TBL_CATEGORIAS.CATEGORIA_LOGO,
                        nombre = post.TBL_CATEGORIAS.CATEGORIA_NOMBRE
                    },
                    id = post.POST_ID,
                    contenido = post.POST_COTENIDO,
                    contenidoEditor = post.POST_CONTENIDO_EDIT,
                    etiquetas = post.POST_TAGS,
                    favoritos = post.POST_FAVORITOS,
                    propietario = new Sujeto
                    {
                        alias = post.TBL_USUARIOS.USUARIO_CODIGO,
                        codigo = post.TBL_USUARIOS.USUARIO_CODIGO,
                        id = post.TBL_USUARIOS.USUARIO_ID,
                        rango = new Rango
                        {
                            id = post.TBL_USUARIOS.TBL_RANGOS.RANGO_ID,
                            descripcion = post.TBL_USUARIOS.TBL_RANGOS.RANGO_DESCRP,
                            nombre = post.TBL_USUARIOS.TBL_RANGOS.RANGO_NOMBRE,
                            imagen = post.TBL_USUARIOS.TBL_RANGOS.RANGO_IMAGEN,
                            puntosDar = post.TBL_USUARIOS.TBL_RANGOS.RANGO_PUNTOS_DAR,
                            puntosRequeridos = post.TBL_USUARIOS.TBL_RANGOS.RANGO_PUNTOS_REQ
                        }
                    },
                    puntos = post.POST_PUNTOS,
                    seComenta = post.POST_SE_COMENTA,
                    seguidores = post.POST_SEGUIDORES,
                    sticky = post.POST_STICKY,
                    titulo = post.POST_TITULO,
                    visitas = post.POST_VISITAS
                }).OrderByDescending(x => x.puntos).Take(cuantos).ToList()
                        select new PostDestacado
                {
                    destaque = PostDestacado.TIPO_DESTAQUE.PUNTOS,
                    post = a
                }).ToList());
            }

            //return (from p in colPost.AsQueryable<Post>().Where(x => x.activo).OrderByDescending(x => x.puntos).Take(cuantos).ToList()
            //        select new PostDestacado { destaque = PostDestacado.TIPO_DESTAQUE.PUNTOS, post = p }).ToList();
        }
Exemplo n.º 12
0
        public static Post editPost(Post post)
        {
            using (ReloadEntities db = new ReloadEntities())
            {
                TBL_POSTS postDB = db.TBL_POSTS.Single(x => x.POST_ID == post.id);

                postDB.POST_TITULO         = post.titulo;
                postDB.POST_CONTENIDO_EDIT = post.contenidoEditor;
                postDB.POST_COTENIDO       = post.contenido;
                postDB.POST_CATEGORIA      = post.categoria.id;
                db.SaveChanges();
            }

            return(post);
        }
Exemplo n.º 13
0
 public static void grabar(Usuario usuario)
 {
     using (ReloadEntities db = new ReloadEntities())
     {
         db.TBL_USUARIOS.Add(new TBL_USUARIOS
         {
             USUARIO_CODIGO   = usuario.codigo,
             USUARIO_PASSWORD = usuario.password,
             USUARIO_MAIL     = usuario.mail,
             USUARIO_FECALT   = DateTime.Now,
             USUARIO_RANGO    = usuario.rango.id
         });
         db.SaveChanges();
     }
 }
Exemplo n.º 14
0
 public static Rango[] GetAll()
 {
     using (ReloadEntities db = new ReloadEntities())
     {
         return((from a in db.TBL_RANGOS
                 select new Rango
         {
             descripcion = a.RANGO_DESCRP,
             id = a.RANGO_ID,
             imagen = a.RANGO_IMAGEN,
             nombre = a.RANGO_NOMBRE,
             puntosDar = a.RANGO_PUNTOS_DAR,
             puntosRequeridos = a.RANGO_PUNTOS_REQ
         }).ToArray());
     }
 }
Exemplo n.º 15
0
 public static void grabarInfo(string username, UsuarioInfo info)
 {
     using (ReloadEntities db = new ReloadEntities())
     {
         TBL_USUARIOS UsuarioDB = db.TBL_USUARIOS.Single(x => x.USUARIO_CODIGO == username);
         UsuarioDB.USUARIO_NOMBRE   = info.nombre;
         UsuarioDB.USUARIO_APELLIDO = info.apellido;
         UsuarioDB.USUARIO_IMAGEN   = info.imagen;
         // UsuarioDB.USUARIO_FECHANAC =  DateTime.Parse(info.fechaNac);
         UsuarioDB.USUARIO_DATOS_PROF = info.datosProfes;
         UsuarioDB.USUARIO_HABITOS    = info.habitos;
         UsuarioDB.USUARIO_SEXO       = info.sexo;
         UsuarioDB.USUARIO_PAIS_ID    = info.pais.id;
         db.SaveChanges();
     }
 }
Exemplo n.º 16
0
 public static void comment(Comentario commentary)
 {
     using (ReloadEntities db = new ReloadEntities())
     {
         db.TBL_POST_COMENTARIOS.Add(new TBL_POST_COMENTARIOS
         {
             POST_COMENTARIO_CONTENIDO  = commentary.contenido,
             POST_COMENTARIO_DEBAJA     = false,
             POST_COMENTARIO_FECALT     = DateTime.Now,
             POST_COMENTARIO_NEG        = 0,
             POST_COMENTARIO_POS        = 0,
             POST_COMENTARIO_POST_ID    = commentary.postid,
             POST_COMENTARIO_USUARIO_ID = commentary.emisor.id
         });
         db.SaveChanges();
     }
 }
Exemplo n.º 17
0
        public static Usuario obtenerUsuario(string codigo)
        {
            using (ReloadEntities db = new ReloadEntities())
            {
                TBL_USUARIOS UsuarioDB = (from a in db.TBL_USUARIOS
                                          where a.USUARIO_CODIGO == codigo
                                          select a).FirstOrDefault();

                if (UsuarioDB == null)
                {
                    return(null);
                }

                Usuario Usuario = new Usuario
                {
                    codigo   = UsuarioDB.USUARIO_CODIGO,
                    activo   = UsuarioDB.USUARIO_ACTIVO,
                    password = UsuarioDB.USUARIO_PASSWORD,
                    info     = new UsuarioInfo
                    {
                        apellido    = UsuarioDB.USUARIO_APELLIDO,
                        datosProfes = UsuarioDB.USUARIO_DATOS_PROF,
                        fechaNac    = ((DateTime)(UsuarioDB.USUARIO_FECHANAC == null ? DateTime.Now : UsuarioDB.USUARIO_FECHANAC)).ToShortDateString(),
                        habitos     = UsuarioDB.USUARIO_HABITOS,
                        fechaAlta   = UsuarioDB.USUARIO_FECALT.ToShortDateString(),
                        idiomas     = UsuarioDB.USUARIO_IDIOMAS,
                        imagen      = UsuarioDB.USUARIO_IMAGEN,
                        nombre      = UsuarioDB.USUARIO_NOMBRE,
                        sexo        = UsuarioDB.USUARIO_SEXO
                    },
                    mail   = UsuarioDB.USUARIO_MAIL,
                    puntos = UsuarioDB.USUARIO_PUNTOS,
                    id     = UsuarioDB.USUARIO_ID
                };

                if (UsuarioDB.TBL_PAISES != null)
                {
                    Usuario.info.pais = new Pais
                    {
                        nombre = UsuarioDB.TBL_PAISES.PAIS_NOMBRE,
                        codigo = UsuarioDB.TBL_PAISES.PAIS_CODIGO,
                        id     = UsuarioDB.TBL_PAISES.PAIS_ID
                    };
                }

                if (UsuarioDB.TBL_RANGOS != null)
                {
                    Usuario.rango = new Rango
                    {
                        descripcion      = UsuarioDB.TBL_RANGOS.RANGO_DESCRP,
                        id               = UsuarioDB.TBL_RANGOS.RANGO_ID,
                        imagen           = UsuarioDB.TBL_RANGOS.RANGO_IMAGEN,
                        nombre           = UsuarioDB.TBL_RANGOS.RANGO_NOMBRE,
                        puntosDar        = UsuarioDB.TBL_RANGOS.RANGO_PUNTOS_DAR,
                        puntosRequeridos = UsuarioDB.TBL_RANGOS.RANGO_PUNTOS_REQ
                    };
                }

                foreach (var post in UsuarioDB.TBL_POSTS)
                {
                    Post postTemp = new Post();
                    postTemp.activo = post.POST_DEBAJA;

                    postTemp.categoria = new Categoria
                    {
                        nombre = post.TBL_CATEGORIAS.CATEGORIA_NOMBRE,
                        id     = post.TBL_CATEGORIAS.CATEGORIA_ID,
                        logo   = post.TBL_CATEGORIAS.CATEGORIA_LOGO
                    };

                    postTemp.imagen = post.POST_IMAGEN;

                    postTemp.puntos          = post.POST_PUNTOS;
                    postTemp.seComenta       = post.POST_SE_COMENTA;
                    postTemp.seguidores      = post.POST_SEGUIDORES;
                    postTemp.sticky          = post.POST_STICKY;
                    postTemp.tags            = post.POST_TAGS.Split(',').ToList();
                    postTemp.titulo          = post.POST_TITULO;
                    postTemp.visitas         = post.POST_VISITAS;
                    postTemp.fechaAlta       = post.POST_FECALT.ToShortDateString();
                    postTemp.id              = post.POST_ID;
                    postTemp.contenido       = post.POST_COTENIDO;
                    postTemp.contenidoEditor = post.POST_CONTENIDO_EDIT;
                    postTemp.favoritos       = post.POST_FAVORITOS;

                    Usuario.posts.Add(postTemp);
                }

                return(Usuario);
            }
        }
Exemplo n.º 18
0
        public static DTO.Post getPost(int idPost)
        {
            using (ReloadEntities db = new ReloadEntities())
            {
                var post = (from p in db.TBL_POSTS
                            where !p.POST_DEBAJA && p.POST_ID == idPost select p).FirstOrDefault();

                Post po = new Post
                {
                    activo    = post.POST_DEBAJA,
                    categoria = new Categoria
                    {
                        id     = post.TBL_CATEGORIAS.CATEGORIA_ID,
                        logo   = post.TBL_CATEGORIAS.CATEGORIA_LOGO,
                        nombre = post.TBL_CATEGORIAS.CATEGORIA_NOMBRE
                    },
                    id              = post.POST_ID,
                    contenido       = post.POST_COTENIDO,
                    contenidoEditor = post.POST_CONTENIDO_EDIT,
                    etiquetas       = post.POST_TAGS,
                    favoritos       = post.POST_FAVORITOS,
                    propietario     = new Sujeto
                    {
                        alias  = post.TBL_USUARIOS.USUARIO_CODIGO,
                        codigo = post.TBL_USUARIOS.USUARIO_CODIGO,
                        id     = post.TBL_USUARIOS.USUARIO_ID,
                        rango  = new Rango
                        {
                            id               = post.TBL_USUARIOS.TBL_RANGOS.RANGO_ID,
                            descripcion      = post.TBL_USUARIOS.TBL_RANGOS.RANGO_DESCRP,
                            nombre           = post.TBL_USUARIOS.TBL_RANGOS.RANGO_NOMBRE,
                            imagen           = post.TBL_USUARIOS.TBL_RANGOS.RANGO_IMAGEN,
                            puntosDar        = post.TBL_USUARIOS.TBL_RANGOS.RANGO_PUNTOS_DAR,
                            puntosRequeridos = post.TBL_USUARIOS.TBL_RANGOS.RANGO_PUNTOS_REQ
                        }
                    },
                    puntos     = post.POST_PUNTOS,
                    seComenta  = post.POST_SE_COMENTA,
                    seguidores = post.POST_SEGUIDORES,
                    sticky     = post.POST_STICKY,
                    titulo     = post.POST_TITULO,
                    visitas    = post.POST_VISITAS,
                    imagen     = post.POST_IMAGEN
                };
                po.fechaAlta         = post.POST_FECALT.ToShortDateString();
                po.fechaModificacion = post.POST_FECMOD.ToShortDateString();

                foreach (var comentarioDB in post.TBL_POST_COMENTARIOS)
                {
                    po.comentarios.Add(new Comentario
                    {
                        contenido = comentarioDB.POST_COMENTARIO_CONTENIDO,
                        debaja    = comentarioDB.POST_COMENTARIO_DEBAJA,
                        dislikes  = comentarioDB.POST_COMENTARIO_NEG,
                        emisor    = new Sujeto
                        {
                            alias  = comentarioDB.TBL_USUARIOS.USUARIO_CODIGO,
                            imagen = comentarioDB.TBL_USUARIOS.USUARIO_IMAGEN,
                            //pais = new Pais
                            //{
                            //    codigo = comentarioDB.TBL_USUARIOS.TBL_PAISES.PAIS_CODIGO,
                            //    id = comentarioDB.TBL_USUARIOS.TBL_PAISES.PAIS_ID,
                            //    nombre = comentarioDB.TBL_USUARIOS.TBL_PAISES.PAIS_NOMBRE
                            //},
                            codigo = comentarioDB.TBL_USUARIOS.USUARIO_CODIGO,
                            id     = comentarioDB.TBL_USUARIOS.USUARIO_ID,
                            rango  = new Rango
                            {
                                id          = comentarioDB.TBL_USUARIOS.TBL_RANGOS.RANGO_ID,
                                descripcion = comentarioDB.TBL_USUARIOS.TBL_RANGOS.RANGO_DESCRP,
                                imagen      = comentarioDB.TBL_USUARIOS.TBL_RANGOS.RANGO_IMAGEN,
                                nombre      = comentarioDB.TBL_USUARIOS.TBL_RANGOS.RANGO_NOMBRE
                            }
                        },
                        esMensajePrivado = false,
                        likes            = comentarioDB.POST_COMENTARIO_POS,
                        postid           = comentarioDB.POST_COMENTARIO_POST_ID,
                        id = comentarioDB.POST_COMENTARIO_ID
                    });
                }

                return(po);
            }
        }