public ActionResult Index(Login login)
 {
     if (ModelState.IsValid)
     {
         if (!(String.IsNullOrEmpty(login.Usuario) || String.IsNullOrEmpty(login.Contra)))
         {
             UserPosterClient posterClient = new UserPosterClient();
             login.Usuario = login.Usuario.ToLower();
             var elemento = posterClient.FindCorreoContra(login.Usuario, login.Contra);
             if (elemento != null)
             {
                 FormsAuthentication.SetAuthCookie(elemento.Email, true);
                 return(RedirectToAction("ProfileAcc", "UserPoster"));
             }
             else
             {
                 return(Index("Usuario no encontrado, o contraseña no coincide."));
             }
         }
         else
         {
             return(Index("Favor de llenar todos los campos."));
         }
     }
     else
     {
         return(View(login));
     }
 }
        public ActionResult ProfileAcc()
        {
            UserPosterClient poster    = new UserPosterClient();
            CategoriaClient  categoria = new CategoriaClient();
            PostClient       post      = new PostClient();
            PaisClient       pais      = new PaisClient();
            CiudadClient     ciudad    = new CiudadClient();
            var elementoPais           = pais.GetAll();
            var elementoCiudad         = ciudad.GetAll();
            var elementoPoster         = poster.GetAll();
            var elementoCategoria      = categoria.GetAll();
            var elementov     = elementoPoster.Single(x => x.Email == User.Identity.Name);
            var elementoposts = post.GetAll().Where(c => c.Poster == elementov.Id);

            ViewBag.Cuenta     = elementov;
            ViewBag.CountPosts = elementoposts.Count();

            elementoCategoria = elementoCategoria.OrderByDescending(x => x.Cantidad);
            var e = new List <Post>();

            foreach (var i in elementoposts)
            {
                i.Categorias = elementoCategoria.Single(x => x.Id == i.NombreCategoria).Nombre;
            }

            elementov.Paises   = elementoPais.Single(x => x.Id == elementov.NombrePais).Nombre;
            elementov.Ciudades = elementoCiudad.Single(x => x.Id == elementov.NombreCiudad).Nombre;

            ViewBag.ListPosts = elementoposts;
            ViewBag.Country   = elementov.Paises;
            ViewBag.City      = elementov.Ciudades;
            return(View());
        }
        public ActionResult Index()
        {
            PostClient        postClient        = new PostClient();
            UserPosterClient  userPoster        = new UserPosterClient();
            CategoriaClient   categoriaClient   = new CategoriaClient();
            CiudadClient      ciudadClient      = new CiudadClient();
            PaisClient        paisClient        = new PaisClient();
            TipoTrabajoClient tipoTrabajoClient = new TipoTrabajoClient();
            var elementos = postClient.GetAll();
            var i         = new List <Post>();

            if (elementos != null)
            {
                foreach (var e in elementos)
                {
                    e.Posters      = userPoster.FindPost(e.Poster);
                    e.Categorias   = categoriaClient.FindCategory(e.NombreCategoria);
                    e.Ciudades     = ciudadClient.FindCiudad(e.NombreCiudad);
                    e.Paises       = paisClient.FindPais(e.NombrePais);
                    e.TipoTrabajos = tipoTrabajoClient.FindTipoTrabajo(e.NombreTipoTrabajo);
                    i.Add(e);
                }
                var v = (from a in i

                         select a);


                ViewBag.ListCategories = categoriaClient.GetAll().OrderBy(p => p.Nombre);
                v = v.OrderBy(p => p.Categorias);
                return(View(v));
            }

            return(View());
        }
        public ActionResult Delete(int id)
        {
            UserPosterClient userPosterClient = new UserPosterClient();

            userPosterClient.Delete(id);
            return(RedirectToAction("ProfileAcc"));
        }
        public ActionResult Edit(int id)
        {
            UserPosterClient userPosterClient = new UserPosterClient();
            UserPoster       c = new UserPoster();

            c = userPosterClient.Get(id);

            return(View("Edit", c));
        }
        public ActionResult CrearPost(string message)
        {
            Post             post         = new Post();
            UserPosterClient posterClient = new UserPosterClient();
            var elemento = posterClient.FindByCorreo(User.Identity.Name);

            post.Posters    = elemento.NombreEmpresa;
            post.Poster     = elemento.Id;
            ViewBag.Message = message;
            ViewBag.Correo  = elemento.Email;
            return(View(post));
        }
        public ActionResult Busqueda(string buscar, string sortOrder, string sortBy, int pageNumber = 1)
        {
            PostClient        postClient        = new PostClient();
            CategoriaClient   categoriaClient   = new CategoriaClient();
            UserPosterClient  userPoster        = new UserPosterClient();
            CiudadClient      ciudad            = new CiudadClient();
            PaisClient        pais              = new PaisClient();
            TipoTrabajoClient tipoTrabajoClient = new TipoTrabajoClient();
            var elementos = postClient.GetAll();
            var e         = new List <Post>();
            var j         = new Post();
            var lista     = e;

            if (elementos != null)
            {
                foreach (var i in elementos)
                {
                    i.Posters      = userPoster.FindPost(i.Poster);
                    i.Categorias   = categoriaClient.FindCategory(i.NombreCategoria);
                    i.Ciudades     = ciudad.FindCiudad(i.NombreCiudad);
                    i.Paises       = pais.FindPais(i.NombrePais);
                    i.TipoTrabajos = tipoTrabajoClient.FindTipoTrabajo(i.NombreTipoTrabajo);
                    e.Add(i);
                }



                if (buscar != null)
                {
                    buscar = buscar.ToUpper();
                    var v = (from a in e
                             where a.Categorias.ToUpper().Contains(buscar) ||
                             a.Posters.ToUpper().Contains(buscar) ||
                             a.NombrePosicion.ToUpper().Contains(buscar) ||
                             a.Paises.ToUpper().Contains(buscar) ||
                             a.Ciudades.ToUpper().Contains(buscar)
                             select a);
                    lista = v.ToList();
                    lista = ApplySorting(sortOrder, sortBy, lista);
                    lista = ApplyPagination(pageNumber, lista);
                }
                else
                {
                    lista = ApplySorting(sortOrder, sortBy, lista);
                    lista = ApplyPagination(pageNumber, lista);
                }
            }


            ViewBag.Buscar = buscar;

            return(View(lista));
        }
        public ActionResult EliminarPoster(int id)
        {
            UserPosterClient posterClient = new UserPosterClient();

            posterClient.Delete(id);
            if (User.IsInRole("Admin"))
            {
                return(RedirectToAction("BusquedaUserPoster", "UserAdmin"));
            }
            else
            {
                return(RedirectToAction("LogOut"));
            }
        }
        public ActionResult Edit(UserPoster c)
        {
            UserPosterClient userPosterClient = new UserPosterClient();

            if (ModelState.IsValid)
            {
                c.Email = c.Email.ToLower();
                userPosterClient.Update(c);
                return(RedirectToAction("ProfileAcc"));
            }
            else
            {
                return(View(c));
            }
        }
        public ActionResult RegistrarPoster(UserPoster c)
        {
            UserPosterClient posterClient = new UserPosterClient();

            if (ModelState.IsValid)
            {
                c.Email          = c.Email.ToLower();
                c.ConfirmarEmail = c.ConfirmarEmail.ToLower();
                if (c.Email == c.ConfirmarEmail)
                {
                    if (c.Contra == c.ConfirmarContra)
                    {
                        if (c.NombreCiudad == 0 || c.NombrePais == 0)
                        {
                            return(RegistrarPoster("Debes seleccionar un pais y su ciudad correspondiente."));
                        }
                        else
                        {
                            if (posterClient.FindCorreo(c))
                            {
                                return(RegistrarPoster("Ya existe una cuenta registrada con ese correo"));
                            }
                            else
                            {
                                posterClient.Add(c);
                                return(RedirectToAction("Index"));
                            }
                        }
                    }
                    else
                    {
                        return(RegistrarPoster("Las Contraseñas no coinciden"));
                    }
                }
                else
                {
                    return(RegistrarPoster("Los Emails no coinciden"));
                }
            }
            else
            {
                return(View(c));
            }
        }
        public ActionResult CrearPost(Post c, HttpPostedFileBase imagenSisi)
        {
            UserPosterClient posterClient = new UserPosterClient();
            var elemento = posterClient.FindByCorreo(User.Identity.Name);

            c.Poster = elemento.Id;
            PostClient postClient = new PostClient();

            if (imagenSisi != null && imagenSisi.ContentLength > 0)
            {
                byte[] imagenData = null;
                using (var bynaryImage = new BinaryReader(imagenSisi.InputStream))
                {
                    imagenData = bynaryImage.ReadBytes(imagenSisi.ContentLength);
                }
                c.Logo = imagenData;
            }

            if (c.NombreCategoria == 0)
            {
                return(CrearPost("Debes seleccionar una Categoria."));
            }
            else if (c.NombrePais == 0 || c.NombreCiudad == 0)
            {
                return(CrearPost("Debes seleccionar un pais y su ciudad correspondiente."));
            }
            else if (c.NombreTipoTrabajo == 0)
            {
                return(CrearPost("Debes seleccionar un tipo de Trabajo."));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    postClient.Add(c);
                    return(RedirectToAction("ProfileAcc"));
                }
                else
                {
                    return(View(c));
                }
            }
        }
Ejemplo n.º 12
0
        public ActionResult BusquedaUserPoster(string buscar, string sortOrder, string sortBy, int pageNumber = 1)
        {
            UserPosterClient userposterClient = new UserPosterClient();
            CategoriaClient  categoriaClient  = new CategoriaClient();
            UserPosterClient userPoster       = new UserPosterClient();
            CiudadClient     ciudad           = new CiudadClient();
            PaisClient       pais             = new PaisClient();
            var elementos = userposterClient.GetAll();
            var e         = new List <UserPoster>();
            var j         = new Post();

            foreach (var i in elementos)
            {
                i.Ciudades = ciudad.FindCiudad(i.NombreCiudad);
                i.Paises   = pais.FindPais(i.NombrePais);
                e.Add(i);
            }

            var lista = e;

            if (buscar != null)
            {
                var v = (from a in e
                         where a.Ciudades.Contains(buscar) ||
                         a.Email.Contains(buscar) ||
                         a.NombreEmpresa.Contains(buscar) ||
                         a.Id.ToString().Equals(buscar)
                         select a);
                lista = v.ToList();
                lista = ApplySorting(sortOrder, sortBy, lista);
                lista = ApplyPagination(pageNumber, lista);
            }
            else
            {
                lista = ApplySorting(sortOrder, sortBy, lista);
                lista = ApplyPagination(pageNumber, lista);
            }

            ViewBag.Buscar = buscar;

            return(View(lista));
        }
Ejemplo n.º 13
0
        public ActionResult ProfileAcc()
        {
            UserPosterClient poster    = new UserPosterClient();
            UserAdminClient  admin     = new UserAdminClient();
            CategoriaClient  categoria = new CategoriaClient();
            PostClient       post      = new PostClient();
            CiudadClient     ciudad    = new CiudadClient();
            var elementoCiudad         = ciudad.GetAll();
            var elementoPoster         = poster.GetAll();
            var elementoCategoria      = categoria.GetAll();
            var elementoAdmin          = admin.GetAll();

            ViewBag.Cuenta = elementoAdmin.Single(x => x.Usuario == User.Identity.Name);

            ViewBag.CountPosters    = elementoPoster.Count();
            ViewBag.CountAdmins     = admin.GetAll().Count();
            ViewBag.CountCategorias = elementoCategoria.Count();
            ViewBag.CountPosts      = post.GetAll().Count();

            elementoCategoria      = elementoCategoria.OrderByDescending(x => x.Cantidad);
            ViewBag.ListCategorias = elementoCategoria;
            ViewBag.MaxCategoria   = elementoCategoria.First().Nombre;

            var v = (from a in elementoPoster
                     where a.FechaCreacion.Day == DateTime.Now.Day
                     select a
                     );

            ViewBag.CountRPostersT = v.Count();
            elementoCiudad         = elementoCiudad.OrderByDescending(x => x.Cantidad);
            ViewBag.MaxCityPosters = elementoCiudad.First().Nombre;



            return(View());
        }
        public ActionResult Postularme(int id, int ciudadId, int paisId, int trabajoId, int categoriaId, string pais, string ciudad, string posicion, string tipoTrabajo, string descripcion, string calle, int idPoster, string dUrl)
        {
            UserPosterClient poster = new UserPosterClient();
            var  elementoPoster     = poster.Get(idPoster);
            Post post = new Post();

            post.NombreCiudad      = ciudadId;
            post.NombrePais        = paisId;
            post.NombreTipoTrabajo = trabajoId;
            post.NombreCategoria   = categoriaId;
            ViewBag.Empresa        = elementoPoster.NombreEmpresa;
            post.Paises            = pais;
            post.Ciudades          = ciudad;
            post.TipoTrabajos      = tipoTrabajo;
            post.Descripcion       = descripcion;
            post.Id             = id;
            ViewBag.Correo      = elementoPoster.Email;
            post.NombrePosicion = posicion;
            ViewBag.Foto        = GetImagePost(id);
            post.NombreCalle    = calle;
            post.DireccionUrl   = dUrl;
            post.Poster         = idPoster;
            return(View(post));
        }
        public ActionResult EditarPoster(UserPoster c)
        {
            UserPosterClient posterClient = new UserPosterClient();
            var elemento = posterClient.Get(c.Id);

            if (ModelState.IsValid)
            {
                c.Email          = c.Email.ToLower();
                c.ConfirmarEmail = c.ConfirmarEmail.ToLower();
                if (c.Email == c.ConfirmarEmail)
                {
                    if (elemento.Contra == c.Contra)
                    {
                        if (c.NombreCiudad == 0 || c.NombrePais == 0)
                        {
                            return(EditarPoster("Debes seleccionar un pais y su ciudad correspondiente."));
                        }
                        else
                        {
                            if (elemento.Email == c.Email)
                            {
                                posterClient.Update(c);
                                if (User.IsInRole("Poster"))
                                {
                                    return(RedirectToAction("Logout"));
                                }
                                else
                                {
                                    return(RedirectToAction("GestionUserPoster", "UserAdmin"));
                                }
                            }
                            else
                            {
                                if (posterClient.FindCorreo(c))
                                {
                                    return(EditarPoster("Ya existe una cuenta registrada con ese correo"));
                                }
                                else
                                {
                                    posterClient.Update(c);
                                    if (User.IsInRole("Poster"))
                                    {
                                        return(RedirectToAction("Logout"));
                                    }
                                    else
                                    {
                                        return(RedirectToAction("GestionUserPoster", "UserAdmin"));
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        return(EditarPoster("Las Contraseñas no coinciden"));
                    }
                }
                else
                {
                    return(EditarPoster("Los Emails no coinciden"));
                }
            }
            else
            {
                return(View(c));
            }
        }