public JsonResult JoinChallenge(int contentId) { bool result = true; SessionCustom.Begin(); ChaellengeFollowerRepository follower = new ChaellengeFollowerRepository(SessionCustom); follower.Entity.ChallengeId = contentId; follower.Entity.UserId = ((CustomPrincipal)User).UserId; follower.Entity.Date = DateTime.Now; follower.Insert(); follower.Entity = new Domain.Entities.ChaellengeFollower(); follower.Entity.ChallengeId = contentId; int total = follower.GetAll().Count; ChallengeRepository challenge = new ChallengeRepository(SessionCustom); challenge.Entity.ContentId = contentId; challenge.Entity.Followers = total; challenge.Update(); SessionCustom.Commit(); Business.UserRelation.SaveRelationAction(((CustomPrincipal)User).UserId, null, contentId, "follow", this.SessionCustom); return(this.Json(new { result = result })); }
public JsonResult Editar(int commentId, string text) { bool result = false; int userId = ((CustomPrincipal)User).UserId; CommentRepository comment = new CommentRepository(SessionCustom); comment.Entity.CommentId = commentId; comment.LoadByKey(); if (userId == comment.Entity.UserId || ((CustomPrincipal)User).IsFrontEndAdmin) { SessionCustom.Begin(); comment.Entity.Text = text; comment.Update(); result = true; SessionCustom.Commit(); } return(this.Json(new { result = result })); }
public ActionResult Detail(int?id, Modulos model) { ModulRepository objmod = new ModulRepository(SessionCustom); ModullanguageRepository modullang = new ModullanguageRepository(SessionCustom); objmod.Entity = model.Modul; try { SessionCustom.Begin(); if (id != null) { objmod.Entity.ModulId = id; objmod.Update(); modullang.Entity.ModulId = id; modullang.Entity.LanguageId = CurrentLanguage.LanguageId; modullang.Load(); if (modullang.Entity.Name != null) { modullang.Entity.Name = model.Modul.Name; modullang.Update(); } else { modullang.Entity.Name = model.Modul.Name; modullang.Insert(); } this.InsertAudit("Update", this.Module.Name + " -> " + objmod.Entity.Name); } else { objmod.Entity.IsBasic = false; int modulId = Convert.ToInt32(objmod.Insert()); modullang.Entity.ModulId = modulId; modullang.Entity.LanguageId = CurrentLanguage.LanguageId; modullang.Entity.Name = model.Modul.Name; modullang.Insert(); this.InsertAudit("Insert", this.Module.Name + " -> " + objmod.Entity.Name); } this.SessionCustom.Commit(); } catch (Exception ex) { this.SessionCustom.RollBack(); Utils.InsertLog(this.SessionCustom, "Error " + this.Module.Name, ex.ToString()); } return(this.RedirectToAction("Index", "Modulos")); }
public JsonResult Respuesta(int answerId) { bool result = false; int userId = ((CustomPrincipal)User).UserId; int error = 0; SessionCustom.Begin(); UserAnswerRepository userAnswer = new UserAnswerRepository(SessionCustom); if (userAnswer.CheckUserVoted(userId, null, answerId)) { SessionCustom.RollBack(); error = 102; } else { userAnswer.Entity.UserId = userId; userAnswer.Entity.AnswerId = answerId; userAnswer.Entity.IP = Request.UserHostAddress; userAnswer.Entity.Date = DateTime.Now; userAnswer.Insert(); userAnswer.Entity = new Domain.Entities.UserAnswer(); userAnswer.Entity.AnswerId = answerId; int total = userAnswer.GetAll().Count; AnswerRepository answer = new AnswerRepository(SessionCustom); answer.Entity.AnswerId = answerId; answer.Load(); answer.Entity.Count = total; answer.Update(); result = true; SessionCustom.Commit(); Business.UserRelation.SaveRelationAction(((CustomPrincipal)User).UserId, null, answer.Entity.AnswerId.Value, "vote", this.SessionCustom); } return(this.Json(new { result = result, error = error })); }
public ActionResult Detail(int?id, Lenguaje model) { LanguageRepository objlang = new LanguageRepository(SessionCustom); objlang.Entity = model.EntityLanguage; try { SessionCustom.Begin(); if (objlang.Entity.IsDefault.Value) { objlang.UpdateLanguage(); } if (id != null) { objlang.Entity.LanguageId = id; objlang.Update(); this.InsertAudit("Update", this.Module.Name + " -> " + objlang.Entity.Name); } else { objlang.Entity.IsDefault = false; objlang.Insert(); this.InsertAudit("Insert", this.Module.Name + " -> " + objlang.Entity.Name); } this.SessionCustom.Commit(); } catch (Exception ex) { this.SessionCustom.RollBack(); Utils.InsertLog(this.SessionCustom, "Error " + this.Module.Name, ex.ToString()); } HttpContext.Cache.Remove("languages"); return(this.RedirectToAction("Index", "Lenguaje")); }
public ActionResult Create(IdeaModel model, string deleteIdeaImage) { IdeaRepository objidea = new IdeaRepository(this.SessionCustom); try { this.SessionCustom.Begin(); objidea.Entity = model.Idea; if (!string.IsNullOrEmpty(deleteIdeaImage)) { objidea.Entity.Image = null; } objidea.Update(); this.InsertAudit("Update", this.Module.Name + " -> " + model.Idea.IdeaId); this.SessionCustom.Commit(); } catch (Exception ex) { SessionCustom.RollBack(); Utils.InsertLog( this.SessionCustom, "Error" + this.Module.Name, ex.Message + " " + ex.StackTrace); } if (Request.Form["GetOut"] == "0") { return(this.RedirectToAction("Index", "Idea")); } else { return(this.RedirectToAction("Detail", "Idea", new { mod = Module.ModulId, id = objidea.Entity.IdeaId })); } }
public ActionResult Create(ChallengeModel model, HttpPostedFileBase contentImage, HttpPostedFileBase contentCoverImage, List <string> videoyoutube, string existingTags, string newTags) { ChallengeRepository objchallenge = new ChallengeRepository(this.SessionCustom); ContentManagement objcontent = new ContentManagement(this.SessionCustom, HttpContext); try { DateTime?currentEndDate = null; if (model.IContent.ContentId.HasValue) { objchallenge.Entity.ContentId = model.IContent.ContentId; objchallenge.LoadByKey(); currentEndDate = objchallenge.Entity.EndDate; objchallenge.Entity = new Domain.Entities.Challenge(); } objcontent.ContentImage = contentImage; objcontent.ContentCoverImage = contentCoverImage; objcontent.CollVideos = videoyoutube; this.SessionCustom.Begin(); model.IContent.LanguageId = CurrentLanguage.LanguageId; objcontent.ContentInsert(model.IContent); objchallenge.Entity = model.Challenge; objchallenge.Entity.ExistingTags = !string.Empty.Equals(existingTags) ? existingTags : null; objchallenge.Entity.NewTags = !string.Empty.Equals(newTags) ? newTags : null; if (objchallenge.Entity.ContentId != null) { objchallenge.Update(); bool reactivated = false; if (currentEndDate < DateTime.Now.Date && model.Challenge.EndDate >= DateTime.Now.Date) { reactivated = true; } if (reactivated) { ContentRepository content = new ContentRepository(SessionCustom); content.Entity.ContentId = model.Challenge.ContentId; content.LoadByKey(); Business.Utilities.Notification.StartReActivateProcess(content.Entity.Frienlyname, content.Entity.ContentId.Value, this.HttpContext, this.CurrentLanguage); } this.InsertAudit("Update", this.Module.Name + " -> " + model.IContent.Name); } else { if (!string.IsNullOrEmpty(Request.Form["TempFiles"])) { string[] files = Request.Form["TempFiles"].Split(','); if (files.Length > 0) { if (!Directory.Exists(Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\"))) { Directory.CreateDirectory(Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\")); } } foreach (var item in files) { string filep = Path.Combine(Server.MapPath("~"), @"Files\Images\" + Path.GetFileName(item)); if (System.IO.File.Exists(filep)) { string filedestin = Path.Combine(Server.MapPath("~"), @"Files\Images\" + Path.GetFileName(item)); System.IO.File.Move(filep, Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\" + Path.GetFileName(item))); } } } objchallenge.Entity.ContentId = objcontent.ObjContent.ContentId; objchallenge.Entity.Followers = 0; objchallenge.Insert(); ContentRepository content = new ContentRepository(SessionCustom); content.Entity.ContentId = model.Challenge.ContentId; content.LoadByKey(); ////EmailNotificationRepository emailNotification = new EmailNotificationRepository(SessionCustom); ////List<int> users = emailNotification.SendNewProcessNotification(); ////foreach (int userId in users) ////{ //// Business.Utilities.Notification.NewNotification(userId, Domain.Entities.Basic.EmailNotificationType.NEW_PROCESS, null, null, string.Concat("/", content.Entity.Frienlyname), content.Entity.ContentId, content.Entity.ContentId.Value, null, null, null, this.SessionCustom, this.HttpContext, this.CurrentLanguage); ////} Business.Utilities.Notification.StartNewProcess(content.Entity.Frienlyname, content.Entity.ContentId.Value, this.HttpContext, this.CurrentLanguage); this.InsertAudit("Insert", this.Module.Name + " -> " + model.IContent.Name); } this.SessionCustom.Commit(); } catch (Exception ex) { SessionCustom.RollBack(); Utils.InsertLog( this.SessionCustom, "Error" + this.Module.Name, ex.Message + " " + ex.StackTrace); } if (Request.Form["GetOut"] == "0") { return(this.RedirectToAction("Index", "Content", new { mod = Module.ModulId })); } else { return(this.RedirectToAction("Detail", "Challenge", new { mod = Module.ModulId, id = objchallenge.Entity.ContentId })); } }
public ActionResult Create(EmailNotificationTemplateModel model, HttpPostedFileBase contentImage, List <string> videoyoutube, string existingTags, string newTags) { EmailNotificationTemplateRepository objnotification = new EmailNotificationTemplateRepository(this.SessionCustom); ContentManagement objcontent = new ContentManagement(this.SessionCustom, HttpContext); try { objcontent.ContentImage = contentImage; objcontent.CollVideos = videoyoutube; this.SessionCustom.Begin(); model.IContent.LanguageId = CurrentLanguage.LanguageId; objcontent.ContentInsert(model.IContent); objnotification.Entity = model.EmailNotificationTemplate; objnotification.Entity.ExistingTags = !string.Empty.Equals(existingTags) ? existingTags : null; objnotification.Entity.NewTags = !string.Empty.Equals(newTags) ? newTags : null; if (objnotification.Entity.ContentId != null) { objnotification.Update(); this.InsertAudit("Update", this.Module.Name + " -> " + model.IContent.Name); } else { if (!string.IsNullOrEmpty(Request.Form["TempFiles"])) { string[] files = Request.Form["TempFiles"].Split(','); if (files.Length > 0) { if (!Directory.Exists(Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\"))) { Directory.CreateDirectory(Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\")); } } foreach (var item in files) { string filep = Path.Combine(Server.MapPath("~"), @"Files\Images\" + Path.GetFileName(item)); if (System.IO.File.Exists(filep)) { string filedestin = Path.Combine(Server.MapPath("~"), @"Files\Images\" + Path.GetFileName(item)); System.IO.File.Move(filep, Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\" + Path.GetFileName(item))); } } } objnotification.Entity.ContentId = objcontent.ObjContent.ContentId; objnotification.Insert(); this.InsertAudit("Insert", this.Module.Name + " -> " + model.IContent.Name); } this.SessionCustom.Commit(); } catch (Exception ex) { SessionCustom.RollBack(); Utils.InsertLog( this.SessionCustom, "Error" + this.Module.Name, ex.Message + " " + ex.StackTrace); } if (Request.Form["GetOut"] == "0") { return(this.RedirectToAction("Index", "Content", new { mod = Module.ModulId })); } else { return(this.RedirectToAction("Detail", "EmailNotification", new { mod = Module.ModulId, id = objnotification.Entity.ContentId })); } }
public ActionResult Create(SuccessStoryModel model, HttpPostedFileBase contentImage, HttpPostedFileBase contentCoverImage, List <string> videoyoutube, string existingTags, string newTags) { SuccessStoryRepository objSuccessStory = new SuccessStoryRepository(this.SessionCustom); ContentManagement objcontent = new ContentManagement(this.SessionCustom, HttpContext); try { objcontent.ContentImage = contentImage; objcontent.ContentCoverImage = contentCoverImage; objcontent.CollVideos = videoyoutube; this.SessionCustom.Begin(); model.IContent.LanguageId = CurrentLanguage.LanguageId; objcontent.ContentInsert(model.IContent, 4); objSuccessStory.Entity = model.SuccessStory; objSuccessStory.Entity.ExistingTags = !string.Empty.Equals(existingTags) ? existingTags : null; objSuccessStory.Entity.NewTags = !string.Empty.Equals(newTags) ? newTags : null; if (objSuccessStory.Entity.ContentId != null) { objSuccessStory.Update(); this.InsertAudit("Update", this.Module.Name + " -> " + model.IContent.Name); } else { if (!string.IsNullOrEmpty(Request.Form["TempFiles"])) { string[] files = Request.Form["TempFiles"].Split(','); if (files.Length > 0) { if (!Directory.Exists(Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\"))) { Directory.CreateDirectory(Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\")); } } foreach (var item in files) { string filep = Path.Combine(Server.MapPath("~"), @"Files\Images\" + Path.GetFileName(item)); if (System.IO.File.Exists(filep)) { string filedestin = Path.Combine(Server.MapPath("~"), @"Files\Images\" + Path.GetFileName(item)); System.IO.File.Move(filep, Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\" + Path.GetFileName(item))); } } } objSuccessStory.Entity.ContentId = objcontent.ObjContent.ContentId; objSuccessStory.Insert(); this.InsertAudit("Insert", this.Module.Name + " -> " + model.IContent.Name); } this.SessionCustom.Commit(); if (model.PostulateId != null) { SuccessStoryPostulateFacade dbpostulate = new SuccessStoryPostulateFacade(); Domain.Entities.Generic.SuccessStoryPostulate postulate = dbpostulate.GetById(model.PostulateId.Value, this.CurrentLanguage.LanguageId.Value); postulate.SuccessStoryId = objcontent.ObjContent.ContentId; postulate.State = (int)Domain.Entities.Enums.SuccessStoryPostulateStateEnum.Published; if (dbpostulate.Update(postulate)) { string domainUrl = string.Format("/SuccessStory/Story/{0}", objcontent.ObjContent.ContentId.Value); this.SendUserNotification(postulate.UserId, domainUrl, objcontent.ObjContent.ContentId.Value); } this.InsertAudit("Update Postulate", this.Module.Name + " -> " + model.IContent.Name); } } catch (Exception ex) { SessionCustom.RollBack(); Utils.InsertLog( this.SessionCustom, "Error" + this.Module.Name, ex.Message + " " + ex.StackTrace); } if (Request.Form["GetOut"] == "0") { return(this.RedirectToAction("Index", "Content", new { mod = Module.ModulId })); } else { return(this.RedirectToAction("Detail", "SuccessStory", new { mod = Module.ModulId, id = objSuccessStory.Entity.ContentId })); } }
public ActionResult Create(BlogEntryModel model, string contentImage, List <string> videoyoutube) { Business.Services.CustomPrincipal currentUserInfo = (Business.Services.CustomPrincipal)User; if (Utils.IsBlogAdmin(currentUserInfo.UserId)) { BlogEntryRepository objblogentry = new BlogEntryRepository(this.SessionCustom); ContentManagement objcontent = new ContentManagement(this.SessionCustom, HttpContext); try { model.IContent.Template = "BlogEntry"; model.IContent.Widget = false; model.IContent.Private = false; model.IContent.Active = true; model.IContent.Image = contentImage; objcontent.CollVideos = videoyoutube; this.SessionCustom.Begin(); model.IContent.LanguageId = 2; objcontent.ContentInsert(model.IContent, 4); objblogentry.Entity = model.BlogEntry; if (objblogentry.Entity.ContentId != null) { objblogentry.Update(); this.InsertAudit("Update", this.Module.Name + " -> " + model.IContent.Name); } else { objblogentry.Entity.ContentId = objcontent.ObjContent.ContentId; objblogentry.Insert(); this.InsertAudit("Insert", this.Module.Name + " -> " + model.IContent.Name); } string serverMap = Server.MapPath("~"); string origin = serverMap + @"\resources\temporal\blog\" + contentImage; if (System.IO.File.Exists(origin)) { if (!System.IO.Directory.Exists(serverMap + @"\files\" + objblogentry.Entity.ContentId)) { System.IO.Directory.CreateDirectory(serverMap + @"\files\" + objblogentry.Entity.ContentId); } System.IO.File.Move(origin, serverMap + @"\files\" + objblogentry.Entity.ContentId + @"\" + contentImage); } this.SessionCustom.Commit(); ViewBag.Result = true; } catch (Exception ex) { SessionCustom.RollBack(); Utils.InsertLog( this.SessionCustom, "Error" + this.Module.Name, ex.Message + " " + ex.StackTrace); ViewBag.Result = false; } return(this.View("index", model)); } return(null); }
public ActionResult Create(QuestionModel model, HttpPostedFileBase contentImage, HttpPostedFileBase contentCoverImage, List <string> videoyoutube, List <string> txtanswer, List <HttpPostedFileBase> fileanswer, string existingTags, string newTags) { QuestionRepository objquestion = new QuestionRepository(this.SessionCustom); ContentManagement objcontent = new ContentManagement(this.SessionCustom, HttpContext); try { DateTime?currentEndDate = null; if (model.IContent.ContentId.HasValue) { objquestion.Entity.ContentId = model.IContent.ContentId; objquestion.LoadByKey(); currentEndDate = objquestion.Entity.EndDate; objquestion.Entity = new Domain.Entities.Question(); } objcontent.ContentImage = contentImage; objcontent.ContentCoverImage = contentCoverImage; objcontent.CollVideos = videoyoutube; this.SessionCustom.Begin(); model.IContent.LanguageId = CurrentLanguage.LanguageId; objcontent.ContentInsert(model.IContent); objquestion.Entity = model.Question; objquestion.Entity.ExistingTags = !string.Empty.Equals(existingTags) ? existingTags : null; objquestion.Entity.NewTags = !string.Empty.Equals(newTags) ? newTags : null; if (objquestion.Entity.ContentId != null) { objquestion.Update(); bool reactivated = false; if (currentEndDate < DateTime.Now.Date && model.Question.EndDate >= DateTime.Now.Date) { reactivated = true; } if (reactivated) { ContentRepository content = new ContentRepository(SessionCustom); content.Entity.ContentId = model.Question.ContentId; content.LoadByKey(); Business.Utilities.Notification.StartReActivateProcess(content.Entity.Frienlyname, content.Entity.ContentId.Value, this.HttpContext, this.CurrentLanguage); } this.InsertAudit("Update", this.Module.Name + " -> " + model.IContent.Name); } else { if (!string.IsNullOrEmpty(Request.Form["TempFiles"])) { string[] files = Request.Form["TempFiles"].Split(','); if (files.Length > 0) { if (!Directory.Exists(Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\"))) { Directory.CreateDirectory(Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\")); } } foreach (var item in files) { string filep = Path.Combine(Server.MapPath("~"), @"Files\Images\" + Path.GetFileName(item)); if (System.IO.File.Exists(filep)) { ////string filedestin = Path.Combine(Server.MapPath("~"), @"Files\Images\" + Path.GetFileName(item)); string filedestin = Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\" + Path.GetFileName(item)); string fileroute = @"Files\" + objcontent.ObjContent.ContentId + @"\" + Path.GetFileName(item); System.IO.File.Move(filep, filedestin); } } } objquestion.Entity.ContentId = objcontent.ObjContent.ContentId; objquestion.Insert(); ContentRepository content = new ContentRepository(SessionCustom); content.Entity.ContentId = model.Question.ContentId; content.LoadByKey(); ////EmailNotificationRepository emailNotification = new EmailNotificationRepository(SessionCustom); ////List<int> users = emailNotification.SendNewProcessNotification(); ////foreach (int userId in users) ////{ //// Business.Utilities.Notification.NewNotification(userId, Domain.Entities.Basic.EmailNotificationType.NEW_PROCESS, null, null, string.Concat("/", content.Entity.Frienlyname), content.Entity.ContentId, content.Entity.ContentId.Value, null, null, null, this.SessionCustom, this.HttpContext, this.CurrentLanguage); ////} Business.Utilities.Notification.StartNewProcess(content.Entity.Frienlyname, content.Entity.ContentId.Value, this.HttpContext, this.CurrentLanguage); this.InsertAudit("Insert", this.Module.Name + " -> " + model.IContent.Name); } if (objquestion.Entity.Type.Equals(Domain.Entities.Question.TypeQuestion.Seleccion_Multiple) && txtanswer != null) { AnswerRepository objanswer = new AnswerRepository(this.SessionCustom); for (int i = 0; i < txtanswer.Count; i++) { string strfile = null; string strvideo = null; if (fileanswer[i] != null) { strfile = DateTime.Now.ToString("ddmmyyyyhhmmssFFF") + Path.GetExtension(fileanswer[i].FileName); string filePath = @"Files/" + objquestion.Entity.ContentId.ToString() + "/" + strfile; string fullPath = Path.Combine(Server.MapPath("~"), filePath); fileanswer[i].SaveAs(fullPath); ImageResize objimage = new ImageResize(Server.MapPath("~")); objimage.Prefix = "_"; objimage.Width = 255; objimage.Height = 130; bool resized = objimage.Resize(filePath, ImageResize.TypeResize.CropProportional); if (resized) { System.IO.File.Delete(fullPath); System.IO.File.Move(Path.Combine(Server.MapPath("~"), @"Files/" + objquestion.Entity.ContentId.ToString() + "/_" + strfile), fullPath); } } objanswer.Entity = new Domain.Entities.Answer() { ContentId = objquestion.Entity.ContentId, Count = 0, Text = txtanswer[i], Image = strfile, Video = strvideo }; objanswer.Insert(); } } this.SessionCustom.Commit(); } catch (Exception ex) { SessionCustom.RollBack(); Utils.InsertLog( this.SessionCustom, "Error" + this.Module.Name, ex.Message + " " + ex.StackTrace); } if (Request.Form["GetOut"] == "0") { return(this.RedirectToAction("Index", "Content", new { mod = Module.ModulId })); } else { return(this.RedirectToAction("Detail", "Question", new { mod = Module.ModulId, id = objquestion.Entity.ContentId })); } }