Пример #1
0
        public ActionResult Galeria(string ID)
        {
            gafest2014Entities ctx = new gafest2014Entities();

            IMAG imag = null;
            if (ID == null)
            {

                imag = ctx.IMAG.OrderByDescending(i => i.ID).Where(i => i.VALID == "Y").First<IMAG>();
                ViewBag.user = imag.USER;
                ViewBag.comments = imag.COMMENT.OrderBy(c => c.DATE).ToList<COMMENT>();
            }

            else
            {

                int FotoID = int.Parse(ID);
                imag = ctx.IMAG.SingleOrDefault<IMAG>(i => i.ID == FotoID);
                ViewBag.user = imag.USER;
                //No tenia el where
                ViewBag.comments = imag.COMMENT.Where(c => c.IMAGID == FotoID).OrderBy(c => c.DATE).ToList<COMMENT>();
                if (imag == null || imag.VALID != "Y")
                {
                    return RedirectToAction("Galeria");
                }

            }

            return View(imag);
        }
        //
        // GET: /PostFiesta/
        public ActionResult Index(string Page)
        {
            if (ContextHelper.LoggedUser.FOTO != null)
            {
                ViewBag.Foto = String.Format("data:image/gif;base64,{0}", Convert.ToBase64String(ContextHelper.LoggedUser.FOTO));
            }

            if (Page == null)
            {
                return RedirectToAction("Index", new { @Page = "1" });
            }
            else
            {
                gafest2014Entities ctx = new gafest2014Entities();

                List<FotosSocialMedia> ToShow = null;

                int NumberOfPages = (ctx.FotosSocialMedia.Count() - 1) / 12 + 1;
                ViewBag.NumberOfPages = NumberOfPages;
                int PageNumber = int.Parse(Page);
                ViewBag.ActivePage = PageNumber;
                int ImagesToSkip = (PageNumber - 1) * 12;

                ToShow = ctx.FotosSocialMedia.Where(f => (f.REDSOCIAL == "Twitter" || f.REDSOCIAL == "Facebook" || f.REDSOCIAL == "Instagram") && f.MOSTRAR == true).OrderByDescending(i => i.IDFOTO).Skip(ImagesToSkip).Take(12).ToList<FotosSocialMedia>(); ;
                for (var cont = 0; cont < ToShow.Count; cont++)
                {
                    ToShow[cont].URL = "https://gafest.grupoassa.com" + ToShow[cont].URL;
                }
                ViewBag.ImagesToShow = ToShow;
                return View();
            }
        }
Пример #3
0
        public ActionResult Comment(string ID, string Content)
        {
            gafest2014Entities ctx = new gafest2014Entities();

            int FotoID = int.Parse(ID);

            COMMENT comment = new COMMENT();
            comment.DATE = DateTime.Now;
            comment.USERNAME = ContextHelper.LoggedUser.USERNAME;
            comment.IMAGID = FotoID;
            comment.TEXT = Content;
            comment.COMMENTID = PostFiestaHelper.GetCOMMENTNextNumber();

            ctx.COMMENT.Add(comment);
            ctx.SaveChanges();

            return RedirectToAction("Galeria", "Fotos", new { @ID = ID });
        }
Пример #4
0
        public ActionResult FiltroFotoPerfil(string Page)
        {
            if (Page == null)
            {
                return RedirectToAction("FiltroFotoPerfil", new { @Page = "1" });
            }
            else
            {
                gafest2014Entities ctx = new gafest2014Entities();

                List<USER> ToShow = null;

                int NumberOfPages = (ctx.USER.Where(u => u.FOTO != null).Count() - 1) / 16 + 1;
                ViewBag.NumberOfPages = NumberOfPages;
                int PageNumber = int.Parse(Page);
                ViewBag.ActivePage = PageNumber;
                int ImagesToSkip = (PageNumber - 1) * 16;

                ToShow = ctx.USER.Where(u => u.FOTO != null).OrderByDescending(i => i.LEGAJO).Skip(ImagesToSkip).Take(16).ToList<USER>(); ;
                ViewBag.ImagesToShow = ToShow;
                return View();
            }
        }
Пример #5
0
        public ActionResult Carga(PreviaModel model)
        {
            if (ModelState.IsValid)
            {

                gafest2014Entities ctx = new gafest2014Entities();

                IQueryable<PREVIA> test = ctx.PREVIA.Where(previa => previa.USERNAME == ContextHelper.LoggedUser.USERNAME);
                if (test == null || test.Count<PREVIA>() == 0)
                {

                    PREVIA p = new PREVIA();
                    p.FOTO = ImageHelper.PostedFileToByteArray(model.Imagen);
                    p.TITULO = model.Titulo;
                    p.ID = ImageHelper.GetPreviaNextNumber();
                    p.USERNAME = ContextHelper.LoggedUser.USERNAME;
                    p.VALID = "Y";

                    ctx.PREVIA.Add(p);
                    ctx.SaveChanges();

                    ctx.Dispose();

                    return RedirectToAction("Index");
                }
                else
                {
                    throw new ApplicationException("Solo se permite la carga de una previa por usuario");
                }

            }
            else
            {
                return RedirectToAction("Index", model);
            }
        }
        public ActionResult Sorteo()
        {
            if (ContextHelper.LoggedUser.FOTO != null)
            {
                ViewBag.Foto = String.Format("data:image/gif;base64,{0}", Convert.ToBase64String(ContextHelper.LoggedUser.FOTO));
            }

                gafest2014Entities ctx = new gafest2014Entities();

                List<GanadoresSorteo> ToShow = null;

                ToShow = ctx.GanadoresSorteo.OrderBy(i => i.PUESTO).ToList<GanadoresSorteo>();

                ViewBag.UsersToShow = ToShow;
                return View();
        }
        public ActionResult Comment(string ID, string Content)
        {
            gafest2014Entities ctx = new gafest2014Entities();

            try
            {
                int momentID = int.Parse(ID);

                COMMENT comment = new COMMENT();
                comment.DATE = DateTime.Now;
                comment.USERNAME = ContextHelper.LoggedUser.USERNAME;
                comment.IMAGID = 0;
                comment.TEXT = Content;
                comment.COMMENTID = PostFiestaHelper.GetCOMMENTNextNumber();
                comment.MOMENTOGAID = momentID;

                if (comment.TEXT != null && comment.TEXT != String.Empty)
                {
                    ctx.COMMENT.Add(comment);
                    ctx.SaveChanges();

                    string commenterName = (ctx.USER.FirstOrDefault(u => u.USERNAME == comment.USERNAME)).NOMBRE + " " + (ctx.USER.FirstOrDefault(u => u.USERNAME == comment.USERNAME)).APELLIDO;
                    string originalPosterName = (ctx.USER.FirstOrDefault(u => u.USERNAME == (ctx.MOMENTOGA.FirstOrDefault(m => m.ID == momentID)).USERNAME)).NOMBRE + " " + (ctx.USER.FirstOrDefault(u => u.USERNAME == (ctx.MOMENTOGA.FirstOrDefault(m => m.ID == momentID)).USERNAME)).APELLIDO;
                    string originalPosterFirstName = (ctx.USER.FirstOrDefault(u => u.USERNAME == (ctx.MOMENTOGA.FirstOrDefault(m => m.ID == momentID)).USERNAME)).NOMBRE;

                    EmailHelper.sendEmailNotificationToOriginalPoster(momentID, comment, commenterName, originalPosterFirstName);
                    EmailHelper.sendEmailNotificationToCommenters(momentID, comment, originalPosterName, commenterName);
                }
                ctx.Dispose();
            }
            catch (Exception ex)
            {
                string[] listaMailSoporte = {"*****@*****.**","*****@*****.**","*****@*****.**","*****@*****.**"};
                EmailHelper.sendEmail(listaMailSoporte, null, "Error en 'Comment' - 'MomentogAController'", "Error:" + ex.Message);
            }
            return new EmptyResult();
        }
        public ActionResult GaleriaPrev(string Id)
        {
            gafest2014Entities ctx = new gafest2014Entities();

            MOMENTOGA moment = null;
            int momentId = int.Parse(Id);
            try
            {
                moment = ctx.MOMENTOGA.Where(m => m.VALID == "Y").OrderByDescending(m => m.ID).Where(m => m.ID < momentId).First();
                if (moment == null)
                {
                    return RedirectToAction("Galeria");
                }
            }
            catch (Exception)
            {
                return RedirectToAction("Galeria");
            }

            return RedirectToAction("Galeria", "MomentogA", new { @Id = moment.ID.ToString() });
        }
        public ActionResult GaleriaNext(string Id)
        {
            gafest2014Entities ctx = new gafest2014Entities();

            MOMENTOGA moment = null;
            int momentId = int.Parse(Id);
            try
            {
                if (momentId == ImageHelper.GetMomentogAActualNumber())
                {
                    return RedirectToAction("Galeria", "MomentogA", new { @Id = 1 });
                }
                else
                {
                    moment = ctx.MOMENTOGA.Where(m => m.VALID == "Y").OrderBy(m => m.ID).Where(m => m.ID > momentId).First();
                    if (moment == null)
                    {
                        return RedirectToAction("Galeria");
                    }
                }
            }
            catch (Exception)
            {
                return RedirectToAction("Galeria");
            }

            return RedirectToAction("Galeria", "MomentogA", new { @Id = moment.ID.ToString() });
        }
        public ActionResult Galeria(string Id)
        {
            gafest2014Entities ctx = new gafest2014Entities();

            if (ContextHelper.LoggedUser.FOTO != null)
            {
                ViewBag.Foto = String.Format("data:image/gif;base64,{0}", Convert.ToBase64String(ContextHelper.LoggedUser.FOTO));
            }

            MOMENTOGA moment = new MOMENTOGA();
            if (Id == null){
                return RedirectToAction("Galeria", "MomentogA", new { @Id = ImageHelper.GetMomentogAActualNumber() });
            }
            else
            {
                int momentId = int.Parse(Id);
                moment = ctx.MOMENTOGA.SingleOrDefault<MOMENTOGA>(m => m.ID == momentId);
                ViewBag.user = moment.USER;
                ViewBag.comments = ctx.COMMENT.OrderBy(c => c.DATE).Where(c => c.MOMENTOGAID == moment.ID).ToList();
                if (moment == null || moment.VALID != "Y" || moment.FOTO == null)
                {
                    return RedirectToAction("Galeria");
                }
            }

            return View(moment);
        }
Пример #11
0
        public ActionResult FiltroSocialMedia(string Page)
        {
            if (Page == null)
            {
                return RedirectToAction("FiltroSocialMedia", new { @Page = "1" });
            }
            else
            {
                gafest2014Entities ctx = new gafest2014Entities();

                List<FotosSocialMedia> ToShow = null;

                int NumberOfPages = (ctx.FotosSocialMedia.Count() - 1) / 12 + 1;
                ViewBag.NumberOfPages = NumberOfPages;
                int PageNumber = int.Parse(Page);
                ViewBag.ActivePage = PageNumber;
                int ImagesToSkip = (PageNumber - 1) * 12;

                ToShow = ctx.FotosSocialMedia.OrderByDescending(i => i.IDFOTO).Skip(ImagesToSkip).Take(12).ToList<FotosSocialMedia>(); ;
                for (var cont = 0; cont < ToShow.Count; cont++)
                {
                    ToShow[cont].URL = "https://gafest.grupoassa.com" + ToShow[cont].URL;
                }
                ViewBag.ImagesToShow = ToShow;
                return View();
            }
        }
Пример #12
0
        public ActionResult Votar(string Id)
        {
            gafest2014Entities ctx = new gafest2014Entities();

            int ID = int.Parse(Id);

            if (ctx.VOTOPREVIA.Where(v => v.PREVIAID == ID).Where(v => v.USERNAME == ContextHelper.LoggedUser.USERNAME).Count() == 0)
                {
                    VOTOPREVIA v = new VOTOPREVIA();
                    v.PREVIAID = ID;
                    v.USERNAME = ContextHelper.LoggedUser.USERNAME;
                    v.ID = ImageHelper.GetVotopreviaNextNumber();

                    ctx.VOTOPREVIA.Add(v);
                    ctx.SaveChanges();
                }
                else
                {
                    throw new ApplicationException("Un solo voto por usuario para cada Previa es permitido");
                }

            ctx.Dispose();

            return RedirectToAction("Galeria", "Previa", new { @Id = Id });
        }