Ejemplo n.º 1
0
        public ActionResult ModeracionContenidos()
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            List<Contenido> ListaPend = db.Contenidos.Where(c => c.Estado == "Pendiente").ToList();

            ViewBag.ListaPend = ListaPend;
            return View();
        }
Ejemplo n.º 2
0
        public ActionResult MostrarFoto()
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            string NombreUsuario = User.Identity.Name.ToString();

            string foto = db.Usuarios.Where(u => u.aspnet_User.UserName == NombreUsuario).Select(f => f.Avatar).ToArray()[0];
            if (String.IsNullOrEmpty(foto)) foto = "fotito.jpg";
            //ViewBag.f = foto;

            return File(Path.Combine(Server.MapPath("~/App_Data/Uploads/Img"),foto), "image/jpg");
        }
Ejemplo n.º 3
0
        //
        // GET: /ActualizarUsuario/
        public ActionResult Index()
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            string NombreUsuario = User.Identity.Name.ToString();
            System.Guid IdUs = db.aspnet_Users.Where(a => a.UserName == NombreUsuario).Select(a => a.UserId).ToArray()[0];

            string ce = db.aspnet_Memberships.Where(p => p.UserId == IdUs).Select(p => p.Email).ToArray()[0];
            ViewBag.ce = ce;

            Usuario usuario = db.Usuarios.Single(p => p.UserId == IdUs);
            ViewBag.usuario = usuario;

            //Resumen de actividad (Contenidos Publicados)
            //int IdUsuario = usuario.Id;
            ViewBag.Resumen = db.Contenidos.Where(q => q.IdUsuario == usuario.Id);

            return View();
        }
Ejemplo n.º 4
0
        public ActionResult Index()
        {
            //ViewBag.Message = "Welcome to ASP.NET MVC!";
            DataClasses1DataContext db = new DataClasses1DataContext();

            List<UltimoLibroPub> ListaLibros = db.Contenidos.Where(p=>p.Tipo=="Libro" && p.Estado=="Aceptado").Select(a =>
                new UltimoLibroPub {
                    //Portada = Path.Combine(Server.MapPath("~/App_Data/Uploads/Img"), db.Libros.Single( t => t.IdContenido==a.Id).Portada ),
                    Portada = db.Libros.Single(t => t.IdContenido == a.Id).Portada,
                    Nick = a.Usuario.aspnet_User.UserName,
                    Karma = (int)a.Usuario.Karma,
                    Descripcion = a.Titulo,
                    Fecha = a.FechaPublicacion,
                    IdContenido = a.Id,
                    IdUsuario = a.IdUsuario
            }).OrderByDescending(f=>f.Fecha).Take(10).ToList();

            ViewBag.ListaLibros = ListaLibros;

            return View();
        }
Ejemplo n.º 5
0
        public ActionResult Index(ActualizarUsuario model, HttpPostedFileBase file)
        {
            var fileName = "";
            if (file!=null && file.ContentLength > 0)
            {
                fileName = Path.GetFileName(file.FileName);
                var path = Path.Combine(Server.MapPath("~/App_Data/Uploads/Img"), fileName);

                file.SaveAs(path);
            }

            if (ModelState.IsValid && model!=null)
            {
                DataClasses1DataContext db = new DataClasses1DataContext();

                string NombreUsuario = User.Identity.Name.ToString();
                System.Guid IdUs = db.aspnet_Users.Where(a => a.UserName == NombreUsuario).Select(a => a.UserId).ToArray()[0];

                string ce = db.aspnet_Memberships.Where(p => p.UserId == IdUs).Select(p => p.Email).ToArray()[0];
                ViewBag.ce = ce;

                Usuario usuario = db.Usuarios.Single(p => p.UserId == IdUs);
                ViewBag.usuario = usuario;

                if (!String.IsNullOrEmpty(fileName))       usuario.Avatar = fileName;

                if ( !String.IsNullOrEmpty(model.ApPaterno) ) usuario.ApPaterno = model.ApPaterno;
                if ( !String.IsNullOrEmpty(model.ApMaterno) ) usuario.ApMaterno = model.ApMaterno;
                if ( !String.IsNullOrEmpty(model.Nombres) )   usuario.Nombres = model.Nombres;
                if ( !String.IsNullOrEmpty(model.Ubicacion))  usuario.Ubicacion = model.Ubicacion;
                if (!String.IsNullOrEmpty(model.Intereses))
                {

                }

                db.SubmitChanges();
            }
            return View();
        }
Ejemplo n.º 6
0
        public ActionResult Index(string id)
        {
            int IdCont = 0;

            if( !String.IsNullOrEmpty(id) ) IdCont = Int32.Parse(id);
            if (IdCont == 0) return Redirect("/Home/Index");

            DataClasses1DataContext db = new DataClasses1DataContext();

            int con = db.Gustas.Count(p => p.IdContenido == IdCont);
            if (con == 0) ViewBag.msg = "Sé la primera persona a quien le gusta ésto";
            //else ViewBag.msg = "";
            else if (con == 1) ViewBag.msg = "A una persona le gusta ésto";
            else ViewBag.msg = "A " + con + " personas les gusta ésto";

            Contenido cnt = db.Contenidos.Single(c => c.Id == IdCont);
            DetalleLibro Detalle = new DetalleLibro()
            {
                IdContenido = cnt.Id,
                Titulo = cnt.Titulo,
                Descripcion = cnt.Descripcion,
                Autor = cnt.Libros.Single(lb => lb.IdContenido == cnt.Id).Autor,
                Portada = cnt.Libros.Single(lb => lb.IdContenido == cnt.Id).Portada,
                Indice = "",
                AnhoPublicacion = (int)cnt.Libros.Single(lb => lb.IdContenido == cnt.Id).AnhoPublicacion,
                Pdf = cnt.UrlReal,

                Nick = cnt.Usuario.aspnet_User.UserName,
                Avatar = cnt.Usuario.Avatar,

                Categos = db.RelContenidosCategorias.Where(rc => rc.IdContenido==cnt.Id).Select(p => p.Categoria).ToList()

            };

            ViewBag.Detalle = Detalle;

            return View();
        }
Ejemplo n.º 7
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    DataClasses1DataContext db = new DataClasses1DataContext();
                    System.Guid IdUs = db.aspnet_Users.Where(a => a.UserName == model.UserName).Select(a => a.UserId).ToArray()[0];
                    System.Guid IdRol = db.aspnet_Roles.Where(a => a.RoleName == "Usuario").Select(a => a.RoleId).ToArray()[0];
                    aspnet_UsersInRole rel = new aspnet_UsersInRole() { RoleId = IdRol, UserId = IdUs };
                    db.aspnet_UsersInRoles.InsertOnSubmit(rel);

                    string email = db.aspnet_Memberships.Where(a => a.UserId == IdUs).Select(a => a.Email).ToArray()[0];
                    string pwd = db.aspnet_Memberships.Where(a => a.UserId == IdUs).Select(a => a.Password).ToArray()[0];
                    string nick = db.aspnet_Users.Where(a => a.UserId == IdUs).Select(a => a.UserName).ToArray()[0];
                    Usuario NuevoUsuario = new Usuario()
                    {
                        UserId = IdUs,
                        //Nick = nick,
                        //Password = pwd,
                        //Email = email,
                        Karma = 0
                    };
                    db.Usuarios.InsertOnSubmit(NuevoUsuario);
                    db.SubmitChanges();

                    FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Ejemplo n.º 8
0
        public ActionResult Index(CargarLibro model, HttpPostedFileBase file, HttpPostedFileBase file2)
        {
            var fileName = "";
            if (file != null && file.ContentLength > 0)
            {
                fileName = Path.GetFileName(file.FileName);
                var path = Path.Combine(Server.MapPath("~/App_Data/Uploads/Pdf"), fileName);

                file.SaveAs(path);
            }

            var fileName2 = "";
            if (file2 != null && file2.ContentLength > 0)
            {
                fileName2 = Path.GetFileName(file2.FileName);
                var path = Path.Combine(Server.MapPath("~/App_Data/Uploads/Img"), fileName2);

                file2.SaveAs(path);
            }
            model.Portada = fileName2;
            model.PdfLibro = fileName;

            if (ModelState.IsValid)
            {
                DataClasses1DataContext db = new DataClasses1DataContext();

                string NombreUsuario = User.Identity.Name.ToString();
                System.Guid IdUs = db.aspnet_Users.Where(a => a.UserName == NombreUsuario).Select(a => a.UserId).ToArray()[0];
                int IdUsuario = db.Usuarios.Where(a => a.UserId == IdUs).Select(a => a.Id).ToArray()[0];

                model.Fecha = DateTime.Now;

                Contenido contenido = new Contenido() {
                    FechaPublicacion = model.Fecha,
                    IdUsuario = IdUsuario,
                    Tipo = "Libro",
                    Titulo = model.Tema,
                    Descripcion = model.Descripcion,
                    //IdCategoria = 1,
                    UrlReal = model.PdfLibro,
                    UrlVirtual = "",
                    Estado = "Pendiente"
                };
                db.Contenidos.InsertOnSubmit(contenido);
                db.SubmitChanges();

                //Insertar en la tabla Libros
                int IdConte = db.Contenidos.Where(p => p.IdUsuario==IdUsuario).Where(q => q.FechaPublicacion==model.Fecha).Select(r => r.Id).ToArray()[0];
                Libro libro = new Libro()
                {
                    Autor = model.Autor,
                    Portada = model.Portada,
                    Indice = "",
                    AnhoPublicacion = (int)model.Anho,
                    IdContenido = IdConte
                };
                db.Libros.InsertOnSubmit(libro);
                db.SubmitChanges();

                //Categorias
                char[] separadores = { ',' };
                string[] categorias = model.Categorias.Split(separadores);
                char[] t = { ' ' };
                List<string> CatRechazadas = new List<string>();

                foreach (string str in categorias)
                {
                    string str2 = str.Trim(t);
                    int esta = db.Categorias.Count(c => c.Descripcion == str2);

                    if (esta == 0)
                    {
                        Categoria categoria = new Categoria()
                        {
                            Descripcion = str2,
                            Estado = "Pendiente"
                        };
                        db.Categorias.InsertOnSubmit(categoria);
                        db.SubmitChanges();
                    }

                    int IdCat = db.Categorias.Single(c => c.Descripcion == str2).Id;
                    string estado = db.Categorias.Single(c => c.Descripcion==str2).Estado;
                    if (estado != "Rechazado")
                    {
                        RelContenidosCategoria rel = new RelContenidosCategoria()
                        {
                            IdContenido = IdConte,
                            IdCategoria = IdCat
                        };
                        db.RelContenidosCategorias.InsertOnSubmit(rel);
                    }
                    else
                        CatRechazadas.Add(str2);

                }
                ViewBag.CatRecha = CatRechazadas;

                db.SubmitChanges();
            }
            return View();
        }