Example #1
0
        /// <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;
            }
        }
Example #2
0
        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
            }));
        }
Example #3
0
        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()
            }));
        }
Example #4
0
        /// <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);
                }
            }
        }