/// <summary> /// obtains the challenge detail /// </summary> /// <param name="mod">identifier of module</param> /// <param name="id">identifier of section</param> /// <returns>returns the result to action</returns> public ActionResult Detail(int mod, int id) { ContentManagement objcontentman = new ContentManagement(SessionCustom, HttpContext); ContentRepository objcontent = new ContentRepository(SessionCustom); ChallengeRepository objchallenge = new ChallengeRepository(SessionCustom); FileattachRepository objfiles = new FileattachRepository(SessionCustom); TagRepository objtag = new TagRepository(SessionCustom); SectionRepository objsection = new SectionRepository(SessionCustom); TemplateRepository objtemplate = new TemplateRepository(SessionCustom); TagFacade tagFacade = new TagFacade(); objtemplate.Entity.Type = 0; objchallenge.Entity.ContentId = objfiles.Entity.ContentId = objcontent.Entity.ContentId = id; objchallenge.LoadByKey(); objcontent.LoadByKey(); IEnumerable <Tag> SelectedTags = objtag.GetTagbycontent(id); this.ViewBag.SelectedTags = string.Join("|", SelectedTags.Select(t => t.TagId)); this.ViewBag.NewsTags = string.Empty; return(this.View( "Index", new ChallengeModel() { UserPrincipal = this.CustomUser, ColModul = CustomMemberShipProvider.GetModuls(this.CustomUser.UserId, this.SessionCustom, HttpContext), Module = this.Module, ListFiles = objfiles.GetAllReadOnly(), Challenge = objchallenge.Entity, IContent = objcontent.Entity, Templates = objtemplate.GetAll().Select(t => t.TemplateId), ListContent = objcontent.GetContentRelation(CurrentLanguage.LanguageId.Value), ListTags = SelectedTags, DeepFollower = Business.Utils.GetDeepFollower(objsection.GetAll(), objcontent.Entity.SectionId.Value), CurrentLanguage = this.CurrentLanguage, Categories = objcontent.Categories(), Tags = tagFacade.GetAll().Select(t => new SelectListItem { Text = t.Name, Value = t.TagId.ToString() }) })); }
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 })); } }
/// <summary> /// Bind the context and the session with the content /// </summary> /// <param name="context">Context page</param> /// <param name="session">Session object</param> /// <param name="id">Content ID</param> /// <param name="userId">current user ID</param> public void Bind(HttpContextBase context, ISession session, int?id, int?userId, int?LanguageId) { ContentRepository contentrepository = new ContentRepository(session); if (contentrepository.Entity != null) { ChallengeRepository challengepository = new ChallengeRepository(session); FileattachRepository file = new FileattachRepository(session); IdeaRepository idea = new IdeaRepository(session); contentrepository.Entity.ContentId = id; contentrepository.LoadByKey(); if (contentrepository.Entity.Frienlyname != null) { file.Entity.ContentId = challengepository.Entity.ContentId = contentrepository.Entity.ContentId; challengepository.LoadByKey(); this.ObjContent = contentrepository.Entity; this.ObjChallenge = challengepository.Entity; this.CollFiles = file.GetAll(); } contentrepository.Entity = new Content(); contentrepository.Entity.ContentId = this.ObjContent.ContentId; contentrepository.Entity.SectionId = this.ObjContent.SectionId; if (userId.HasValue) { ChaellengeFollowerRepository follower = new ChaellengeFollowerRepository(session); follower.Entity.UserId = userId; follower.Entity.ChallengeId = id; if (follower.GetAll().Count > 0) { this.JoinedChallenge = true; } } if (id.HasValue) { int totalCount = 0; CommentRepository comment = new CommentRepository(session); BlogEntryRepository blog = new BlogEntryRepository(session); idea.Entity.ContentId = blog.Entity.ContentId = id.Value; this.CollIdeas = idea.IdeasPaging(1, 6, out totalCount, id.Value, userId); this.IdeasCount = totalCount; foreach (IdeasPaging item in this.CollIdeas) { item.CollComment = comment.CommentsPaging(1, 3, out totalCount, item.IdeaId.Value); this.CommentsCount = totalCount; } this.BlogEntries = blog.BlogContentEntriesPaging(1, 6, out totalCount); this.BlogEntriesCount = totalCount; foreach (BlogEntriesPaging blogEntry in this.BlogEntries) { blogEntry.CollComment = comment.CommentsPagingContent(1, 3, out totalCount, blogEntry.ContentId.Value); this.CommentsCount = totalCount; } this.TopIdeas = idea.TopIdeas(10); this.Statistics = contentrepository.GetContentStatistics(id.Value); } } this.CollContent = contentrepository.GetNewsRelationFrontEnd(); }