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 }); }
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 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 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 }); }