/// <summary> /// Deletes a file /// </summary> /// <param name="id">identifier of file</param> /// <returns>returns true if the operation is successful</returns> public bool DeleteFileAttach(int id) { try { FileattachRepository fileattach = new FileattachRepository(this.session); fileattach.Entity.FileattachId = id; fileattach.LoadByKey(); if (fileattach.Entity.Filename != null) { string path = Path.Combine(this.context.Server.MapPath("~"), @"files\" + fileattach.Entity.ContentId + @"\"); if (File.Exists(path + fileattach.Entity.Filename)) { File.Delete(path + fileattach.Entity.Filename); } if (File.Exists(path + "thumb_" + fileattach.Entity.Filename)) { File.Delete(path + "thumb_" + fileattach.Entity.Filename); } fileattach.Delete(); } return(true); } catch (Exception ex) { Utils.InsertLog(this.session, "Error Delete", ex.ToString()); return(false); } }
/// <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; } }
/// <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); NewsRepository newsrepository = new NewsRepository(session); FileattachRepository file = new FileattachRepository(session); if (contentrepository.Entity != null) { contentrepository.Entity.ContentId = id; contentrepository.LoadByKey(); if (contentrepository.Entity.Frienlyname != null) { file.Entity.ContentId = newsrepository.Entity.ContentId = contentrepository.Entity.ContentId; newsrepository.LoadByKey(); this.ObjContent = contentrepository.Entity; this.ObjNews = newsrepository.Entity; this.CollFiles = file.GetAll(); } contentrepository.Entity = new Content(); contentrepository.Entity.ContentId = this.ObjContent.ContentId; contentrepository.Entity.SectionId = this.ObjContent.SectionId; } this.CollContent = contentrepository.GetNewsRelationFrontEnd(); }
/// <summary> /// obtains the idea 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) { QuestionRepository objquestion = new QuestionRepository(SessionCustom); ContentManagement objcontentman = new ContentManagement(SessionCustom, HttpContext); ContentRepository objcontent = new ContentRepository(SessionCustom); IdeaRepository objidea = new IdeaRepository(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; objidea.Entity.IdeaId = objcomment.Entity.IdeaId = id; objidea.LoadByKey(); objquestion.Entity.ContentId = objcontent.Entity.ContentId = objidea.Entity.ContentId; objcontent.LoadByKey(); objquestion.LoadByKey(); if (objquestion.Entity != null && objquestion.Entity.Type.Equals(Domain.Entities.Question.TypeQuestion.Ubicacion)) { ViewBag.Location = true; } else { ViewBag.Location = false; } int totalComments = 0; List <CommentsPaging> comments = objcomment.CommentsPaging(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( "Detail", new IdeaModel() { UserPrincipal = this.CustomUser, ColModul = CustomMemberShipProvider.GetModuls(this.CustomUser.UserId, this.SessionCustom, HttpContext), Module = this.Module, ListFiles = objfiles.GetAllReadOnly(), Idea = objidea.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 })); }
/// <summary> /// obtains the challenge detail /// </summary> /// <param name="mod">identifier of module</param> /// <param name="id">identifier of section</param> /// <param name="sectionId">seccion del molulo</param> /// <returns>returns the result to action</returns> public ActionResult Detail(int mod, int id, int?sectionId) { ContentManagement objcontentman = new ContentManagement(SessionCustom, HttpContext); ContentRepository objcontent = new ContentRepository(SessionCustom); SuccessStoryRepository objSuccessStory = new SuccessStoryRepository(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); TagFacade tagFacade = new TagFacade(); objtemplate.Entity.Type = 0; objSuccessStory.Entity.ContentId = objfiles.Entity.ContentId = objcomment.Entity.ContentId = objcontent.Entity.ContentId = id; objSuccessStory.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 SuccessStoryModel() { UserPrincipal = this.CustomUser, ColModul = CustomMemberShipProvider.GetModuls(this.CustomUser.UserId, this.SessionCustom, HttpContext), Module = this.Module, ListFiles = objfiles.GetAllReadOnly(), SuccessStory = objSuccessStory.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, Tags = tagFacade.GetAll().Select(t => new SelectListItem { Text = t.Name, Value = t.TagId.ToString() }) })); }
/// <summary> /// Changes a order of files /// </summary> /// <param name="fileattachId">identifier of file</param> /// <param name="prevId">identifier of previous file</param> /// <param name="limit">if the content is limit</param> /// <returns>returns true if the operation is successful</returns> public bool ChangeOrderFile(int fileattachId, int prevId, bool limit) { try { FileattachRepository objfileattach = new FileattachRepository(this.session); objfileattach.ChangeOrder(fileattachId, prevId, limit); return(true); } catch (Exception) { return(false); } }
/// <summary> /// Updates a file /// </summary> /// <param name="fileattachId">identifier of file</param> /// <param name="name">name of file</param> /// <returns>returns true if the operations is success</returns> public bool UpdateFile(int fileattachId, string name) { try { FileattachRepository fileattachrepo = new FileattachRepository(this.session); fileattachrepo.Entity.FileattachId = fileattachId; fileattachrepo.Entity.Name = name; fileattachrepo.Update(); return(true); } catch (Exception) { return(false); } }
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(); }
/// <summary> /// fills the object's fields /// </summary> /// <param name="context">HTTP context</param> /// <param name="session">framework that establishes communication between the application and the database</param> /// <param name="id">identifier of section</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); NewsRepository newsrepository = new NewsRepository(session); FileattachRepository file = new FileattachRepository(session); contentrepository.Entity.Private = true; contentrepository.Entity.SectionId = id; contentrepository.GetContentBySection(); if (contentrepository.Entity.Frienlyname != null) { file.Entity.ContentId = newsrepository.Entity.ContentId = contentrepository.Entity.ContentId; newsrepository.LoadByKey(); this.Content = contentrepository.Entity; this.News = newsrepository.Entity; this.Files = file.GetAll(); } }
/// <summary> /// Inserts the files associated with the content /// </summary> private void InsertAttachFiles() { FileattachRepository objfiles = new FileattachRepository(this.session); objfiles.Entity.ContentId = this.ObjContent.ContentId; for (int i = 0; i < this.context.Request.Files.Count; i++) { if (this.context.Request.Files.GetKey(i).Contains("upload")) { HttpPostedFileBase httpfile = this.context.Request.Files[i]; string ipnputname = "NP" + this.context.Request.Files.GetKey(i); if (httpfile.ContentLength > 0) { objfiles.Entity.Filename = Utils.UploadFile( httpfile, this.context.Server.MapPath("~"), @"files\" + this.ObjContent.ContentId + @"\", i.ToString()); string valueinput = this.context.Request.Form[ipnputname]; objfiles.Entity.Type = this.GetTypeFile(objfiles.Entity.Filename); objfiles.Entity.Name = !string.IsNullOrEmpty(valueinput) ? valueinput : null; objfiles.Entity.Joindate = DateTime.Now; objfiles.Insert(); if (objfiles.Entity.Type.Value == Fileattach.TypeFile.Image) { string fileroute = @"files\" + this.ObjContent.ContentId + @"\" + objfiles.Entity.Filename; this.objimagerez.Resize( fileroute, ImageResize.TypeResize.PartialProportional); this.objimagerez.Width = 170; this.objimagerez.Height = 105; this.objimagerez.Prefix = "170x105-"; this.objimagerez.Resize(fileroute, ImageResize.TypeResize.CropProportional); this.objimagerez.Width = 683; this.objimagerez.Height = 320; this.objimagerez.Prefix = "683x320-"; this.objimagerez.Resize(fileroute, ImageResize.TypeResize.CropProportional); } } } } if (this.CollVideos != null) { foreach (string item in this.CollVideos) { string codyoutube = Utils.CodeYoutube(item); if (!string.IsNullOrEmpty(codyoutube)) { objfiles.Entity.Filename = codyoutube; objfiles.Entity.Type = Fileattach.TypeFile.Video; objfiles.Entity.Name = item; objfiles.Entity.Joindate = DateTime.Now; objfiles.Insert(); } } } }
/// <summary> /// Copy a content from the other content /// </summary> /// <param name="contentId">identifier of content</param> /// <param name="languageId">identifier of language</param> /// <param name="sectionId">identifier of section</param> /// <returns>returns true if the operation is successful</returns> public bool Clone(int contentId, int languageId, int sectionId) { try { this.session.Begin(); ContentRepository contentrepo = new ContentRepository(this.session); FileattachRepository fileattachrepo = new FileattachRepository(this.session); FriendlyurlRepository friendlyrepo = new FriendlyurlRepository(this.session); fileattachrepo.Entity.ContentId = friendlyrepo.Entity.Id = contentrepo.Entity.ContentId = contentId; contentrepo.LoadByKey(); friendlyrepo.Entity.Type = Friendlyurl.FriendlyType.Content; friendlyrepo.Load(); List <Fileattach> collfiles = fileattachrepo.GetAll(); contentrepo.Entity.SectionId = sectionId; contentrepo.Entity.Name = "Copy of " + contentrepo.Entity.Name; contentrepo.Entity.Orderliness = contentrepo.GetMaxOrder(); int newid = Convert.ToInt32(contentrepo.Insert()); friendlyrepo.Entity.Id = newid; friendlyrepo.Entity.Friendlyurlid = "copy_of_" + friendlyrepo.Entity.Friendlyurlid; friendlyrepo.Entity.LanguageId = languageId; friendlyrepo.Insert(); foreach (Fileattach item in collfiles) { fileattachrepo.Entity = item; fileattachrepo.Entity.ContentId = newid; fileattachrepo.Insert(); } this.CompleteClone(contentId, newid, contentrepo.Entity.ModulId.Value); string originpath = Path.Combine(this.context.Server.MapPath("~"), @"Files\" + contentId + @"\"); string newpath = Path.Combine(this.context.Server.MapPath("~"), @"Files\" + newid + @"\"); if (Directory.Exists(originpath)) { DirectoryInfo dir = new DirectoryInfo(originpath); FileInfo[] files = dir.GetFiles(); if (!Directory.Exists(newpath)) { Directory.CreateDirectory(newpath); } foreach (FileInfo item in files) { File.Copy(item.FullName, newpath + item.Name); } } this.session.Commit(); return(true); } catch (Exception ex) { this.session.RollBack(); Utils.InsertLog(this.session, "Clone Content ", ex.ToString()); return(false); } }
/// <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(); }
/// <summary> /// obtains the news 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); NewsRepository objnews = new NewsRepository(SessionCustom); FileattachRepository objfiles = new FileattachRepository(SessionCustom); TagRepository objtag = new TagRepository(SessionCustom); SectionRepository objsection = new SectionRepository(SessionCustom); TemplateRepository objtemplate = new TemplateRepository(SessionCustom); MoldRepository objMold = new MoldRepository(SessionCustom); XmlNodeList collXmlNode = null; TagFacade tagFacade = new TagFacade(); List <Domain.Entities.Mold> collMold = objMold.GetAll(); collMold.Insert( 0, new Domain.Entities.Mold() { Name = Resources.Global.Messages.SELECT }); objtemplate.Entity.Type = 0; objnews.Entity.ContentId = objfiles.Entity.ContentId = objcontent.Entity.ContentId = id; objnews.LoadByKey(); objcontent.LoadByKey(); if (objnews.Entity.MoldId != null) { XmlDocument objXmlDocument = new XmlDocument(); objXmlDocument.LoadXml(objnews.Entity.Xmlcontent); collXmlNode = objXmlDocument.GetElementsByTagName("node"); } 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 NewsModel() { UserPrincipal = this.CustomUser, ColModul = CustomMemberShipProvider.GetModuls(this.CustomUser.UserId, this.SessionCustom, HttpContext), Module = this.Module, ListFiles = objfiles.GetAllReadOnly(), News = objnews.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, CollMold = collMold, CollXmlNode = collXmlNode, Categories = objcontent.Categories(), Tags = tagFacade.GetAll().Select(t => new SelectListItem { Text = t.Name, Value = t.TagId.ToString() }) })); }
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() })); }
/// <summary> /// Fill a front end information /// </summary> /// <param name="key">search criteria</param> /// <param name="userId">current user ID</param> public void BindInfo(int key, int?userId) { ContentRepository objcont = new ContentRepository(this.session); this.Metatags = new List <KeyValuePair <KeyValue, KeyValue> >(); if (this.type == Type.Content) { objcont.Entity.ContentId = key; objcont.LoadByKey(); if (objcont.Entity.ContentId == null) { this.Outcome = Result.NotFound; } else { this.Section = this.sections.Find(t => t.SectionId == objcont.Entity.SectionId); if (Section != null) { this.Content = objcont.Entity; this.Layout = this.Section.Layout; this.Template = objcont.Entity.Template; this.Metatags.Add( new KeyValuePair <Domain.Entities.KeyValue, Domain.Entities.KeyValue>( new Domain.Entities.KeyValue("name", "title"), new Domain.Entities.KeyValue("content", objcont.Entity.Name))); this.Metatags.Add( new KeyValuePair <Domain.Entities.KeyValue, Domain.Entities.KeyValue>( new Domain.Entities.KeyValue("name", "description"), new Domain.Entities.KeyValue("content", objcont.Entity.Shortdescription))); this.Metatags.Add( new KeyValuePair <Domain.Entities.KeyValue, Domain.Entities.KeyValue>( new Domain.Entities.KeyValue("property", "og:title"), new Domain.Entities.KeyValue("content", objcont.Entity.Name))); this.Metatags.Add( new KeyValuePair <Domain.Entities.KeyValue, Domain.Entities.KeyValue>( new Domain.Entities.KeyValue("property", "og:description"), new Domain.Entities.KeyValue("content", objcont.Entity.Shortdescription))); if (HttpContext.Current != null) { FileattachRepository fileRepository = new FileattachRepository(new SqlSession()); fileRepository.Entity.ContentId = objcont.Entity.ContentId; Fileattach file = fileRepository.GetAll().FirstOrDefault(t => t.Type == Domain.Entities.Fileattach.TypeFile.Video); string fileName = string.Empty; if (file != null) { fileName = string.Concat(file.Name, "v=", file.Filename); } string siteUrlRoot = ("http://" + HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.ApplicationPath).TrimEnd('/'); Domain.Entities.FrontEnd.Video video = Business.Utils.GetVideoFromUrl(fileName); string picture = siteUrlRoot + "/1024.png"; if (!string.IsNullOrEmpty(objcont.Entity.Image)) { picture = siteUrlRoot + "/files/" + objcont.Entity.ContentId + "/" + objcont.Entity.Image; } else if (video != null && video.Type == "youtube") { picture = "http://img.youtube.com/vi/" + video.ID + "/default.jpg"; } this.Metatags.Add( new KeyValuePair <Domain.Entities.KeyValue, Domain.Entities.KeyValue>( new Domain.Entities.KeyValue("property", "og:image"), new Domain.Entities.KeyValue("content", picture))); this.Metatags.Add( new KeyValuePair <Domain.Entities.KeyValue, Domain.Entities.KeyValue>( new Domain.Entities.KeyValue("property", "og:url"), new Domain.Entities.KeyValue("content", ("http://" + HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.ApplicationPath).TrimEnd('/') + "/" + objcont.Entity.Frienlyname))); } this.Outcome = Result.Ok; this.Detail = this.GetDetail(this.GetNameType(objcont.Entity.Template), objcont.Entity.ContentId, userId, this.language.LanguageId); this.DeepFollower = Utils.GetDeepFollowerFrontEnd(this.sections, this.Section.SectionId.Value, this.Content, this.language); objcont.Entity.Views++; objcont.Update(); } else { this.Outcome = Result.NotFound; } } } else if (this.type == Type.Idea) { IdeaRepository objidea = new IdeaRepository(this.session); objidea.Entity.IdeaId = key; objidea.LoadByKey(); if (objidea.Entity.ContentId == null) { this.Outcome = Result.NotFound; } else { objcont.Entity.ContentId = objidea.Entity.ContentId; objcont.LoadByKey(); this.Section = this.sections.Find(t => t.SectionId == objcont.Entity.SectionId); if (Section != null) { this.Idea = objidea.Entity; this.Layout = this.Section.Layout; this.Metatags.Add( new KeyValuePair <Domain.Entities.KeyValue, Domain.Entities.KeyValue>( new Domain.Entities.KeyValue("name", "title"), new Domain.Entities.KeyValue("content", objcont.Entity.Name))); this.Metatags.Add( new KeyValuePair <Domain.Entities.KeyValue, Domain.Entities.KeyValue>( new Domain.Entities.KeyValue("name", "description"), new Domain.Entities.KeyValue("content", objcont.Entity.Shortdescription))); this.Metatags.Add( new KeyValuePair <Domain.Entities.KeyValue, Domain.Entities.KeyValue>( new Domain.Entities.KeyValue("property", "og:title"), new Domain.Entities.KeyValue("content", objcont.Entity.Name))); this.Metatags.Add( new KeyValuePair <Domain.Entities.KeyValue, Domain.Entities.KeyValue>( new Domain.Entities.KeyValue("property", "og:description"), new Domain.Entities.KeyValue("content", objcont.Entity.Shortdescription))); string siteUrlRoot = ("http://" + HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.ApplicationPath).TrimEnd('/'); Domain.Entities.FrontEnd.Video video = Business.Utils.GetVideoFromUrl(objidea.Entity.Video); string picture = siteUrlRoot + "/1024.png"; if (!string.IsNullOrEmpty(objidea.Entity.Image)) { picture = siteUrlRoot + "/files/ideas/" + objidea.Entity.Image; } else if (video != null && video.Type == "youtube") { picture = "http://img.youtube.com/vi/" + video.ID + "/default.jpg"; } this.Metatags.Add( new KeyValuePair <Domain.Entities.KeyValue, Domain.Entities.KeyValue>( new Domain.Entities.KeyValue("property", "og:image"), new Domain.Entities.KeyValue("content", picture))); FriendlyurlRepository url = new FriendlyurlRepository(this.session); url.Entity.Id = key; url.Entity.Type = Friendlyurl.FriendlyType.Idea; url.Load(); this.Metatags.Add( new KeyValuePair <Domain.Entities.KeyValue, Domain.Entities.KeyValue>( new Domain.Entities.KeyValue("property", "og:url"), new Domain.Entities.KeyValue("content", ("http://" + HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.ApplicationPath).TrimEnd('/') + "/" + url.Entity.Friendlyurlid))); this.Outcome = Result.Ok; this.Detail = this.GetDetail(this.GetNameType(objcont.Entity.Template), objcont.Entity.ContentId, userId, this.language.LanguageId); this.DeepFollower = Utils.GetDeepFollowerFrontEnd(this.sections, this.Section.SectionId.Value, this.Content, this.language); objidea.Entity.Views++; objidea.Update(); if (objidea.IsIdeaInTop10(objidea.Entity.IdeaId.Value)) { SystemNotificationRepository notification = new SystemNotificationRepository(this.session); int count = notification.SystemNotificationCount(objidea.Entity.UserId.Value, (int)Domain.Entities.Basic.SystemNotificationType.IDEA_TOP_10, objidea.Entity.IdeaId.Value); if (count == 0) { Business.Utilities.Notification.NewNotification(objidea.Entity.UserId.Value, null, Domain.Entities.Basic.SystemNotificationType.IDEA_TOP_10, null, string.Concat("/", objidea.Entity.Friendlyurlid), objidea.Entity.ContentId, objidea.Entity.IdeaId.Value, null, null, null, this.session, this.context, this.language); } } if (objidea.IsIdeaInTop5Home(objidea.Entity.IdeaId.Value)) { SystemNotificationRepository notification = new SystemNotificationRepository(this.session); int count = notification.SystemNotificationCount(objidea.Entity.UserId.Value, (int)Domain.Entities.Basic.SystemNotificationType.POPULAR_IDEA_TOP_5, objidea.Entity.IdeaId.Value); if (count == 0) { Business.Utilities.Notification.NewNotification(objidea.Entity.UserId.Value, null, Domain.Entities.Basic.SystemNotificationType.POPULAR_IDEA_TOP_5, null, string.Concat("/", objidea.Entity.Friendlyurlid), objidea.Entity.ContentId, objidea.Entity.IdeaId.Value, null, null, null, this.session, this.context, this.language); } } } else { this.Outcome = Result.NotFound; } } } else { this.Section = this.sections.Find(t => t.SectionId == key); if (this.Section == null) { this.Outcome = Result.NotFound; } else { this.Layout = this.Section.Layout; this.Template = this.Section.Template; this.Metatags.Add( new KeyValuePair <Domain.Entities.KeyValue, Domain.Entities.KeyValue>( new Domain.Entities.KeyValue("name", "title"), new Domain.Entities.KeyValue("content", this.Section.Name))); this.Metatags.Add( new KeyValuePair <Domain.Entities.KeyValue, Domain.Entities.KeyValue>( new Domain.Entities.KeyValue("name", "description"), new Domain.Entities.KeyValue("content", this.Section.Description))); this.Metatags.Add( new KeyValuePair <Domain.Entities.KeyValue, Domain.Entities.KeyValue>( new Domain.Entities.KeyValue("property", "og:title"), new Domain.Entities.KeyValue("content", this.Section.Name))); this.Metatags.Add( new KeyValuePair <Domain.Entities.KeyValue, Domain.Entities.KeyValue>( new Domain.Entities.KeyValue("property", "og:description"), new Domain.Entities.KeyValue("content", this.Section.Description))); this.Outcome = Result.Ok; this.Detail = this.GetDetail(this.GetNameType(this.Section.Template), this.Section.SectionId, userId, this.language.LanguageId); this.DeepFollower = Utils.GetDeepFollowerFrontEnd(this.sections, this.Section.SectionId.Value, null, this.language); } } }