public ActionResult EntradasBlog(int pageIndex, int pageSize, int contentId, string view) { int total = 0; int?currentUserId = null; if (User.Identity.IsAuthenticated) { currentUserId = ((CustomPrincipal)User).UserId; } BlogEntryRepository blog = new BlogEntryRepository(SessionCustom); CommentRepository comment = new CommentRepository(SessionCustom); blog.Entity.ContentId = contentId; List <BlogEntriesPaging> blogContentEntries = blog.BlogContentEntriesPaging(pageIndex, pageSize, out total); foreach (BlogEntriesPaging content in blogContentEntries) { content.CollComment = comment.CommentsPagingContent(1, 3, out total, contentId); } if (string.IsNullOrEmpty(view)) { view = "_ContentBlogEntriesList"; } return(this.View(view, blogContentEntries)); }
/// <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) { int total = 0; BlogEntryRepository blogEntryRepository = new BlogEntryRepository(session); FileattachRepository fileRepository = new FileattachRepository(session); CommentRepository comment = new CommentRepository(session); this.CollBlogEntries = blogEntryRepository.BlogEntriesPaging(1, 6, out total, true, LanguageId); this.TotalCount = total; int totalCount = 0; foreach (BlogEntriesPaging blogEntry in this.CollBlogEntries) { blogEntry.CollComment = comment.CommentsPagingContent(1, 3, out totalCount, blogEntry.ContentId.Value); if (blogEntry.CollComment.Count > 0) { blogEntry.CollComment[0].CommentContentOwnerId = blogEntry.UserId.Value; } fileRepository.Entity.ContentId = blogEntry.ContentId; Fileattach file = fileRepository.GetAll().FirstOrDefault(t => t.Type == Domain.Entities.Fileattach.TypeFile.Video); if (file != null) { blogEntry.Video = file.Filename; } this.CommentsCount = totalCount; } }
public BlogController(BlogEntryRepository blogEntryRepository, BlogResponseRepository blogResponseRepository, databaseContext context, ILogger <HomeController> logger) { _blogEntryRepository = blogEntryRepository; _blogResponseRepository = blogResponseRepository; _context = context; _logger = logger; }
/// <summary> /// gets the blog archive /// </summary> /// <returns>returns the result to action</returns> public ActionResult ArchiveEntries() { BlogEntryRepository blogEntries = new BlogEntryRepository(SessionCustom); List <ArchiveEntry> archiveEntries = blogEntries.ArchiveEntries(CurrentLanguage.LanguageId); return(this.View(archiveEntries)); }
public WebAPIController() { blogRep = new BlogEntryRepository(); cb_rep = new Category_BlogRepository(); fileRep = new FileRepository(); userRep = new UserRepository(); meetRep = new MeetingRepository(); }
/// <summary> /// obtains the challenge detail /// </summary> /// <param name="id">identifier of section</param> /// <returns>returns the result to action</returns> public ActionResult Detail(int id) { Business.Services.CustomPrincipal currentUserInfo = (Business.Services.CustomPrincipal)User; if (Utils.IsBlogAdmin(currentUserInfo.UserId)) { ContentManagement objcontentman = new ContentManagement(SessionCustom, HttpContext); ContentRepository objcontent = new ContentRepository(SessionCustom); BlogEntryRepository objblogentry = new BlogEntryRepository(SessionCustom); FileattachRepository objfiles = new FileattachRepository(SessionCustom); TagRepository objtag = new TagRepository(SessionCustom); SectionRepository objsection = new SectionRepository(SessionCustom); TemplateRepository objtemplate = new TemplateRepository(SessionCustom); CommentRepository objcomment = new CommentRepository(SessionCustom); objtemplate.Entity.Type = 0; objblogentry.Entity.ContentId = objfiles.Entity.ContentId = objcomment.Entity.ContentId = objcontent.Entity.ContentId = id; objblogentry.LoadByKey(); objcontent.LoadByKey(); int totalComments = 0; List <CommentsPaging> comments = objcomment.CommentsPagingContent(0, 50, out totalComments, id); ViewBag.TotalComments = totalComments; 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 BlogEntryModel() { UserPrincipal = this.CustomUser, ColModul = CustomMemberShipProvider.GetModuls(this.CustomUser.UserId, this.SessionCustom, HttpContext), Module = this.Module, ListFiles = objfiles.GetAllReadOnly(), BlogEntry = objblogentry.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, ListComments = comments })); } return(null); }
public ActionResult Index(int id, bool layer) { BlogEntryRepository blog = new BlogEntryRepository(SessionCustom); blog.Entity.ContentId = id; blog.LoadByKey(); ContentRepository content = new ContentRepository(SessionCustom); content.Entity.ContentId = blog.Entity.ContentId; content.LoadByKey(); if (User.Identity.IsAuthenticated) { ViewBag.CurrentUserId = ((CustomPrincipal)User).UserId; } if (content.Entity.UserId.HasValue) { // blog owner ViewBag.IdeaOwner = content.Entity.UserId.Value == ViewBag.CurrentUserId; } int total = 0; CommentRepository comment = new CommentRepository(SessionCustom); List <Domain.Entities.FrontEnd.CommentsPaging> comments = comment.CommentsPagingContent(1, 6, out total, id); FileattachRepository fileRepository = new FileattachRepository(SessionCustom); fileRepository.Entity.ContentId = content.Entity.ContentId; Fileattach file = fileRepository.GetAll().FirstOrDefault(t => t.Type == Domain.Entities.Fileattach.TypeFile.Video); if (file != null) { content.Entity.Video = file.Filename; } return(this.View(new Models.FEBlogEntry() { Entity = blog.Entity, CollComments = comments, ObjContent = content.Entity, CurrentLanguage = CurrentLanguage, CommentCount = total })); }
/// <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) { BlogEntryRepository blogentryrepository = new BlogEntryRepository(session); FileattachRepository file = new FileattachRepository(session); CommentRepository comment = new CommentRepository(session); contentrepository.Entity.ContentId = id; contentrepository.LoadByKey(); if (contentrepository.Entity.Frienlyname != null) { file.Entity.ContentId = blogentryrepository.Entity.ContentId = contentrepository.Entity.ContentId; blogentryrepository.LoadByKey(); this.ObjContent = contentrepository.Entity; this.ObjBlogEntry = blogentryrepository.Entity; this.CollFiles = file.GetAll(); } contentrepository.Entity = new Content(); contentrepository.Entity.ContentId = this.ObjContent.ContentId; contentrepository.Entity.SectionId = this.ObjContent.SectionId; if (id.HasValue) { CommentRepository commentRepository = new CommentRepository(session); int totalCount; this.CollComments = commentRepository.CommentsPagingContent(1, 3, out totalCount, id.Value); } } this.CollContent = contentrepository.GetNewsRelationFrontEnd(); }
public BlogController() { _blogRepository = new BlogEntryRepository(); }
public BlogController(BlogEntryRepository blogEntryRepository, BlogResponseRepository blogResponseRepository, NorthwindContext context) { _blogEntryRepository = blogEntryRepository; _blogResponseRepository = blogResponseRepository; }
/// <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(); }
public FeedController() { blogEntryRepository = new BlogEntryRepository(); categoryRepository = new CategoryRepository(); userRep = new UserRepository(); }
public ActionResult Index(int id) { SetLabel(); FrontEndManagement objman = new FrontEndManagement(SessionCustom, HttpContext, FrontEndManagement.Type.Content, CurrentLanguage); int?currentUserId = null; if (User.Identity.IsAuthenticated) { currentUserId = ((CustomPrincipal)User).UserId; objman.BindInfo(id, currentUserId); ViewBag.CurrentUserId = currentUserId; } else { objman.BindInfo(id, null); } IdeaRepository idea = new IdeaRepository(SessionCustom); BlogEntryRepository blog = new BlogEntryRepository(SessionCustom); blog.Entity.ContentId = id; blog.LoadByKey(); ContentRepository content = new ContentRepository(SessionCustom); content.Entity.ContentId = blog.Entity.ContentId; content.LoadByKey(); if (content.Entity.UserId.HasValue) { // blog owner ViewBag.IdeaOwner = content.Entity.UserId.Value == currentUserId; } int total = 0; CommentRepository comment = new CommentRepository(SessionCustom); List <Domain.Entities.FrontEnd.CommentsPaging> comments = comment.CommentsPagingContent(1, 6, out total, id); FileattachRepository fileRepository = new FileattachRepository(SessionCustom); fileRepository.Entity.ContentId = content.Entity.ContentId; Fileattach file = fileRepository.GetAll().FirstOrDefault(t => t.Type == Domain.Entities.Fileattach.TypeFile.Video); if (file != null) { content.Entity.Video = file.Filename; } return(this.View( "IndexNivel3", new Models.FEBlogEntry() { UserPrincipal = CustomUser, Entity = blog.Entity, CollComments = comments, ObjContent = content.Entity, MetaTags = objman.Metatags, CurrentLanguage = CurrentLanguage, CommentCount = total, IdeasCountAll = idea.IdeasCountAll() })); }
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(BlogEntryModel model, HttpPostedFileBase contentImage, HttpPostedFileBase contentCoverImage, List <string> videoyoutube, string existingTags, string newTags) { BlogEntryRepository objblogentry = new BlogEntryRepository(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); objblogentry.Entity = model.BlogEntry; objblogentry.Entity.ExistingTags = !string.Empty.Equals(existingTags) ? existingTags : null; objblogentry.Entity.NewTags = !string.Empty.Equals(newTags) ? newTags : null; if (objblogentry.Entity.ContentId != null) { objblogentry.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))); } } } objblogentry.Entity.ContentId = objcontent.ObjContent.ContentId; objblogentry.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", "BlogEntry", new { mod = Module.ModulId, id = objblogentry.Entity.ContentId })); } }