コード例 #1
0
        /// <summary>
        /// get the content to bind the Categories Section (right section)
        /// </summary>
        /// <returns></returns>
        public ActionResult Categories()
        {
            var objBlogcontext     = new BlogAdmin.Contexts.BlogsContexts();                                      //Blog Context
            var objCategorycontext = new BlogAdmin.Contexts.CategoriesContexts();                                 //Categories Context
            var blog_list          = objBlogcontext.GetBlogs().ToList();                                          //Blog List
            var category_list      = objCategorycontext.GetCategories().OrderBy(x => x.CategoryNameTxt).ToList(); //Category List
            var model = new Models.ContentModel();                                                                // Content Model
            //************************************Categories section *********************************************
            List <Models.categoryList> categories = new List <Models.categoryList>();

            try
            {
                foreach (var newitem in category_list)
                {
                    var blog_count = blog_list.Where(x => x.CategoryID == newitem.CategoryID && x.IsActiveInd == true).Count();
                    var obj        = new Models.categoryList();
                    obj.CategoryID      = newitem.CategoryID;
                    obj.CategoryNameTxt = newitem.CategoryNameTxt;
                    obj.CategoryCount   = blog_count.ToString();//Category count in
                    categories.Add(obj);
                }
            }
            catch (Exception)
            {
            }
            model.categoryList = categories;
            //***************************************************************************************************
            return(View(model));
        }
コード例 #2
0
        public ActionResult Index(string search, string type_ID, int?page, FormCollection fm)
        {
            int pageSize   = Admin.Models.Common._pageSize;
            int pageNumber = (page ?? Admin.Models.Common._currentPage);

            var search_txt = string.IsNullOrEmpty(Request.QueryString["search"]) ? "" : Request.QueryString["search"].ToString();

            if (string.IsNullOrEmpty(search_txt) && !string.IsNullOrEmpty(search))
            {
                search_txt = search.Trim().ToLower();
            }

            //search = fm["search"] != null ? fm["search"].ToString() : search;
            var _BlogsContexts      = new BlogAdmin.Contexts.BlogsContexts();      //Blog Context
            var _CategoriesContexts = new BlogAdmin.Contexts.CategoriesContexts(); //Categories Context
            var _TagsContexts       = new BlogAdmin.Contexts.TagsContexts();       //Tags Context
            var _SettingContexts    = new BlogAdmin.Contexts.SettingContexts();    //Settings Context
            var model     = new Models.ContentModel();                             // Content Model
            var blog_list = new List <BlogAdmin.Models.BlogsModel>();

            try
            {                                                                                 //**********************************Setting Section****************************************
                var Setting_List = _SettingContexts.GetSettings().ToList();                   // Setting List
                pageSize          = Setting_List.Select(x => x.PostPerPage).FirstOrDefault(); // Posts per page
                model.SettingList = Setting_List;
                //-----------------------------------------------------------------------------------------

                var blogID = 0;
                if (_BlogsContexts != null)
                {
                    if (search_txt != "" && !string.IsNullOrEmpty(search_txt))
                    {
                        blog_list = _BlogsContexts.GetBlogs().Where(x => x.TitleTxt.Trim().ToLower().Contains(search_txt) && x.IsActiveInd == true).OrderByDescending(x => x.PostedDate).ToList();//Get blog list on the basis of search text
                    }
                    else
                    {
                        blog_list = _BlogsContexts.GetBlogs().Where(x => x.IsActiveInd == true).OrderByDescending(x => x.PostedDate).ToList();
                    }
                    List <Models.ContentModel> bloglist = new List <Models.ContentModel>();//Create a list of blog items

                    foreach (var a in blog_list)
                    {
                        model = new Models.ContentModel();
                        model.AuthorNameTxt       = a.AuthorNameTxt;
                        model.AuthorNameID        = a.AuthorNameID;
                        model.BlogDescription     = a.BlogDescription;
                        model.BlogDescription     = a.BlogDescription;
                        model.CategoryID          = a.CategoryID;
                        model.BlogID              = blogID = a.BlogID;
                        model.ImagePathTxt        = a.ImagePathTxt;
                        model.IsActiveInd         = a.IsActiveInd;
                        model.IsCommentEnabledInd = a.IsCommentEnabledInd;
                        model.MetaDescriptionTxt  = a.MetaDescriptionTxt;
                        model.MetaTitleTxt        = a.MetaTitleTxt;
                        model.PostedDate          = a.PostedDate;
                        model.SlagTxt             = a.SlagTxt;
                        model.SocialMediaTxt      = a.SocialMediaTxt;
                        model.TitleTxt            = a.TitleTxt;
                        model.AbstractTxt         = a.AbstractTxt;
                        model.CategoryName        = a.CategoryID != 0 ? _CategoriesContexts.GetCategories().Where(x => x.CategoryID == a.CategoryID).Select(x => x.CategoryNameTxt).FirstOrDefault() : "";

                        //************************************TagList under each blog*********************************************
                        List <Models.TagNameList> blogTaglistName = new List <Models.TagNameList>();//Create a list of tags of single blog items
                        var getTagIDList = _BlogsContexts.GetFormBlogTag(a.BlogID).ToList();
                        foreach (var b in getTagIDList)
                        {
                            var obj = new Models.TagNameList();
                            obj.TagNameTxt = _TagsContexts.GetTags().Where(x => x.TagID == Convert.ToInt32(b)).Select(x => x.TagNameTxt).FirstOrDefault();;
                            obj.TagID      = Convert.ToInt32(b);
                            obj.BlogID     = a.BlogID;
                            blogTaglistName.Add(obj);
                        }
                        model.TagNameList = blogTaglistName.OrderBy(x => x.TagNameTxt).ToList();
                        //****************************Social Media Listing*********************************************
                        List <BlogAdmin.Models.FormBlogSocialMedia> social_listName = new List <BlogAdmin.Models.FormBlogSocialMedia>();//Create a list of tags of single blog items
                        social_listName  = _BlogsContexts.GetFormBlogSocialMedia_List(blogID).ToList();
                        model.SocialList = social_listName;
                        bloglist.Add(model);
                    }
                    model.IsPagingVisible = bloglist.Count > pageSize;
                    model.PagedBlog       = bloglist.ToPagedList(pageNumber, pageSize);
                }
                var objheader   = new BlogAdmin.Contexts.ContentContexts();   //Content Context
                var header_list = objheader.GetContent(1).ToList();           //Get Header content for ContentTypeID =1 (header)
                model.HeaderList = header_list;
                var objTheme      = new BlogAdmin.Contexts.SettingContexts(); //Setting Context
                var objTheme_list = objTheme.GetSettings().ToList();          // Get Setting Theme list
                model.SettingList = objTheme_list;
            }
            catch (Exception)
            {
            }
            return(View(model));
        }
コード例 #3
0
        //
        // GET: /Blog/Home/

        public ActionResult Index(string search, string type_ID, int?page, int?type, FormCollection fm)
        {
            int pageSize   = Admin.Models.Common._pageSize;
            int pageNumber = (page ?? Admin.Models.Common._currentPage);

            #region Search Section
            //var search_type_ID = string.IsNullOrEmpty(type_ID) ? "" : type_ID;//Contains search type and ID of search, Tag
            var search_type = string.Empty;
            var typeID      = string.Empty;

            //************************************** Search Type and ID***************************
            var Type_ID = Request.QueryString["type_ID"] == null ? "" : Request.QueryString["type_ID"].ToString();

            if (!string.IsNullOrEmpty(type_ID) && type_ID != "")
            {
                var search_type_ID = type_ID.Split(new[] { '0' }, 2);//Split on first occurence of 0
                search_type = search_type_ID[0].ToString().Trim().ToLower();
                typeID      = search_type_ID[1] != null ? search_type_ID[1].ToString() : "0";
            }
            else if (!string.IsNullOrEmpty(Type_ID) && Type_ID != "")
            {
                var search_type_ID = type_ID.Split(new[] { '0' }, 2);//Split on first occurence of 0
                search_type = search_type_ID[0].ToString().Trim().ToLower();
                typeID      = search_type_ID[1] != null ? search_type_ID[1].ToString() : "0";
            }
            //*************************************************************************************

            var search_txt = string.IsNullOrEmpty(Request.QueryString["search"]) ? "" : Request.QueryString["search"].ToLower().ToString();

            if (string.IsNullOrEmpty(search_txt) && !string.IsNullOrEmpty(search))
            {
                search_txt = search;
            }
            #endregion
            var _BlogsContexts      = new BlogAdmin.Contexts.BlogsContexts();      //Blog Context
            var _CategoriesContexts = new BlogAdmin.Contexts.CategoriesContexts(); //Categories Context
            var _TagsContexts       = new BlogAdmin.Contexts.TagsContexts();       //Tags Context
            var _SettingContexts    = new BlogAdmin.Contexts.SettingContexts();    //Settings Context
            var model = new Models.ContentModel();                                 // Content Model

            try
            {
                //**********************************Setting Section****************************************
                var Setting_List = _SettingContexts.GetSettings().ToList();                   // Setting List
                pageSize          = Setting_List.Select(x => x.PostPerPage).FirstOrDefault(); // Posts per page
                model.SettingList = Setting_List;
                //------------------------------------------------------------------------------------------

                var blogID = 0;
                if (_BlogsContexts != null)
                {
                    var blog_list = new List <BlogAdmin.Models.BlogsModel>();
                    if (search_txt != "" && !string.IsNullOrEmpty(search_txt) && !string.IsNullOrEmpty(search_type))
                    {
                        switch (search_type)
                        {
                        case "blog_search":
                            blog_list = _BlogsContexts.GetBlogs().Where(x => x.TitleTxt.Trim().ToLower().Contains(search_txt) && x.IsActiveInd == true).OrderByDescending(x => x.PostedDate).ToList();    //Get blog list on the basis of search text
                            break;

                        case "tag_search":
                            blog_list = _BlogsContexts.GetBlogs().Where(x => x.IsActiveInd == true).OrderByDescending(x => x.PostedDate).ToList();
                            var objFormBlogTag = _BlogsContexts.GetAllFormBlogTags(Convert.ToInt32(typeID));
                            var list_new       = (from a in blog_list
                                                  join b in objFormBlogTag
                                                  on a.BlogID equals b.BlogID
                                                  select new { a }).ToList();
                            blog_list = list_new.Select(x => x.a).OrderByDescending(x => x.PostedDate).ToList();
                            break;

                        case "category_search":
                            blog_list = _BlogsContexts.GetBlogs().Where(x => x.CategoryID == Convert.ToInt32(typeID) && x.IsActiveInd == true).OrderByDescending(x => x.PostedDate).ToList();    //Get blog list on the basis of search text
                            break;

                        case "auther_search":
                            blog_list = _BlogsContexts.GetBlogs().Where(x => x.AuthorNameID == typeID && x.IsActiveInd == true).OrderByDescending(x => x.PostedDate).ToList();    //Get blog list on the basis of search text
                            break;

                        case "monthlist_search":
                            #region
                            var month_year = typeID.Split('_');
                            var month      = month_year[0].ToString();
                            var year       = month_year[1].ToString();
                            #endregion
                            blog_list = _BlogsContexts.GetBlogs().Where(x => x.PostedDate.Month == Convert.ToInt32(month) && x.PostedDate.Year == Convert.ToInt32(year) && x.IsActiveInd == true).OrderByDescending(x => x.PostedDate).ToList();    //Get blog list on the basis of search text
                            break;

                        default:
                            blog_list = _BlogsContexts.GetBlogs().Where(x => x.IsActiveInd == true).OrderByDescending(x => x.PostedDate).ToList();
                            break;
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(search) && string.IsNullOrEmpty(type_ID))                                                                                                            // Search for Text Box Search
                        {
                            blog_list = _BlogsContexts.GetBlogs().Where(x => x.TitleTxt.Trim().ToLower().Contains(search_txt) && x.IsActiveInd == true).OrderByDescending(x => x.PostedDate).ToList(); //Get blog list on the basis of search text
                        }
                        else
                        {
                            blog_list = _BlogsContexts.GetBlogs().Where(x => x.IsActiveInd == true).OrderByDescending(x => x.PostedDate).ToList();
                        }
                    }

                    List <Models.ContentModel> bloglist = new List <Models.ContentModel>();//Create a list of blog items

                    foreach (var a in blog_list)
                    {
                        model                     = new Models.ContentModel();
                        model.TitleTxt            = a.TitleTxt;
                        model.AuthorNameTxt       = a.AuthorNameTxt;
                        model.AuthorNameID        = a.AuthorNameID;
                        model.BlogDescription     = a.BlogDescription;
                        model.CategoryID          = a.CategoryID;
                        model.BlogID              = blogID = a.BlogID;
                        model.ImagePathTxt        = a.ImagePathTxt;
                        model.IsActiveInd         = a.IsActiveInd;
                        model.IsCommentEnabledInd = a.IsCommentEnabledInd;
                        model.MetaDescriptionTxt  = a.MetaDescriptionTxt;
                        model.MetaTitleTxt        = a.MetaTitleTxt;
                        model.PostedDate          = a.PostedDate;
                        model.SlagTxt             = a.SlagTxt;
                        model.SocialMediaTxt      = a.SocialMediaTxt;
                        model.AbstractTxt         = a.AbstractTxt;
                        model.CategoryName        = a.CategoryID != 0 ? _CategoriesContexts.GetCategories().Where(x => x.CategoryID == a.CategoryID).Select(x => x.CategoryNameTxt).FirstOrDefault() : "";

                        //************************************TagList under each blog*********************************************
                        List <Models.TagNameList> blogTaglistName = new List <Models.TagNameList>();//Create a list of tags of single blog items
                        var getTagIDList = _BlogsContexts.GetFormBlogTag(a.BlogID).ToList();
                        foreach (var b in getTagIDList)
                        {
                            var obj = new Models.TagNameList();
                            obj.TagNameTxt = _TagsContexts.GetTags().Where(x => x.TagID == Convert.ToInt32(b)).Select(x => x.TagNameTxt).FirstOrDefault();;
                            obj.TagID      = Convert.ToInt32(b);
                            obj.BlogID     = a.BlogID;
                            blogTaglistName.Add(obj);
                        }
                        model.TagNameList = blogTaglistName;
                        //****************************Social Media Listing*********************************************
                        List <BlogAdmin.Models.FormBlogSocialMedia> social_listName = new List <BlogAdmin.Models.FormBlogSocialMedia>();//Create a list of tags of single blog items
                        social_listName  = _BlogsContexts.GetFormBlogSocialMedia_List(blogID).ToList();
                        model.SocialList = social_listName;
                        bloglist.Add(model);
                    }
                    model.IsPagingVisible = bloglist.Count > pageSize;
                    model.PagedBlog       = bloglist.ToPagedList(pageNumber, pageSize);
                }
                var objheader   = new BlogAdmin.Contexts.ContentContexts(); //Content Context
                var header_list = objheader.GetContent(1).ToList();         //Get Header content for ContentTypeID =1 (header)
                model.HeaderList = header_list;

                var objTheme      = new BlogAdmin.Contexts.SettingContexts(); //Setting Context
                var objTheme_list = objTheme.GetSettings().ToList();          // Get Settings Theme list
                model.SettingList = objTheme_list;
            }
            catch (Exception)
            {
            }
            return(View(model));
        }
コード例 #4
0
        public ActionResult BlogContent(string Blogurl, Content _model, int?page, int?type, FormCollection fm)
        {
            int pageSize            = Admin.Models.Common._pageSize;
            int pageNumber          = page ?? Admin.Models.Common._currentPage;
            var comments_per_post   = 4;
            var _BlogsContexts      = new BlogAdmin.Contexts.BlogsContexts();      //Blog Context
            var _CategoriesContexts = new BlogAdmin.Contexts.CategoriesContexts(); //Categories Context
            var _TagsContexts       = new BlogAdmin.Contexts.TagsContexts();       //Tags Context
            var _SettingContexts    = new BlogAdmin.Contexts.SettingContexts();    //Settings Context
            var _EmailsContexts     = new BlogAdmin.Contexts.EmailsContexts();     //Emails Context
            var _CommentsContext    = new BlogAdmin.Contexts.CommentContexts();    // Comments Context

            var model = new Models.ContentModel();                                 // Content Model

            try
            {
                #region Blog List Section
                var blogID    = 0;
                var blog_list = _BlogsContexts.GetBlogs().Where(x => x.SlagTxt.ToLower() == Blogurl.ToLower() && x.IsActiveInd == true).OrderBy(x => x.PostedDate).FirstOrDefault();
                if (blog_list == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }

                if (_BlogsContexts != null)
                {
                    blogID = blog_list.BlogID;
                    List <Models.ContentModel> bloglist = new List <Models.ContentModel>();//Create a list of blog items
                    model = new Models.ContentModel();
                    model.AuthorNameTxt       = blog_list.AuthorNameTxt;
                    model.AuthorNameID        = blog_list.AuthorNameID;
                    model.BlogDescription     = blog_list.BlogDescription;
                    model.BlogDescription     = blog_list.BlogDescription;
                    model.CategoryID          = blog_list.CategoryID;
                    model.ImagePathTxt        = blog_list.ImagePathTxt;
                    model.IsActiveInd         = blog_list.IsActiveInd;
                    model.IsCommentEnabledInd = blog_list.IsCommentEnabledInd;
                    model.MetaDescriptionTxt  = blog_list.MetaDescriptionTxt;
                    model.MetaTitleTxt        = blog_list.MetaTitleTxt;
                    model.PostedDate          = blog_list.PostedDate;
                    model.SlagTxt             = blog_list.SlagTxt;
                    model.SocialMediaTxt      = blog_list.SocialMediaTxt;
                    model.TitleTxt            = blog_list.TitleTxt;
                    model.AbstractTxt         = blog_list.AbstractTxt;
                    model.CategoryName        = blog_list.CategoryID != 0 ? _CategoriesContexts.GetCategories().Where(x => x.CategoryID == blog_list.CategoryID).Select(x => x.CategoryNameTxt).FirstOrDefault() : "";

                    //************************************TagList under each blog*********************************************
                    List <Models.TagNameList> blogTaglistName = new List <Models.TagNameList>();//Create a list of tags of single blog items
                    var getTagIDList = _BlogsContexts.GetFormBlogTag(blog_list.BlogID).ToList();
                    foreach (var b in getTagIDList)
                    {
                        var obj = new Models.TagNameList();
                        obj.TagNameTxt = _TagsContexts.GetTags().Where(x => x.TagID == Convert.ToInt32(b)).Select(x => x.TagNameTxt).FirstOrDefault();;
                        obj.TagID      = Convert.ToInt32(b);
                        obj.BlogID     = blog_list.BlogID;
                        blogTaglistName.Add(obj);
                    }
                    model.TagNameList = blogTaglistName.OrderByDescending(x => x.TagNameTxt).ToList();
                    //****************************Social Media Listing*********************************************
                    var objSocialListing = _BlogsContexts.GetFormBlogSocialMedia_List(blogID).ToList();
                    model.SocialList = objSocialListing;
                    bloglist.Add(model);
                    model.IsPagingVisible = true;
                    model.PagedBlog       = bloglist.ToPagedList(pageNumber, pageSize);
                }
                #endregion

                #region Comment Section
                //*************************Adds Comment *********************
                var name    = fm["full-name"] != null ? fm["full-name"].ToString() : "";
                var email   = fm["email"] != null ? fm["email"].ToString() : "";
                var phone   = fm["phone"] != null ? fm["phone"].ToString() : "";
                var Comment = fm["Comment"] != null ? fm["Comment"].ToString() : "";

                var comment_model = new BlogAdmin.Models.CommentModel();
                comment_model.BlogID = blogID;
                var commentidList = _CommentsContext.GetComments().ToList();
                comment_model.CommentID             = (commentidList.Count() > 0) ? commentidList.Select(x => x.CommentID).Max() + 1 : 1;
                comment_model.FullNameTxt           = name;
                comment_model.EmailTxt              = email;
                comment_model.PhoneNoTxt            = phone;
                comment_model.CommentDescriptionTxt = Comment;
                comment_model.PostedDate            = DateTime.Now;
                comment_model.IsActiveInd           = false;
                _CommentsContext.AddComment(comment_model);

                //***********************Email Sending to client on every comment post*******************
                #region Email region
                var  Email_List       = _EmailsContexts.GetEmails().ToList();    // Emails List
                var  Setting_List     = _SettingContexts.GetSettings().ToList(); // Setting List
                bool IsSucessSendMail = false;
                var  ToEmailTxt       = Setting_List.Select(a => a.ReceivingEmail).FirstOrDefault();
                var  SendingEmalTxt   = Setting_List.Select(a => a.SendingEmail).FirstOrDefault();
                var  Toemail_array    = new string[] { };
                var  ToEmail          = string.Empty;
                if (!string.IsNullOrEmpty(ToEmailTxt) && ToEmailTxt.Contains(","))
                {
                    Toemail_array = ToEmailTxt.Split(',');
                }
                else
                {
                    Toemail_array = new string[] { ToEmailTxt };
                }
                foreach (var itememail in Toemail_array)
                {
                    ToEmail = ToEmail + "," + Email_List.Where(x => x.EmailID == Convert.ToInt32(itememail)).Select(x => x.EmailTxt).FirstOrDefault();
                }
                ToEmail = ToEmail.Trim(',');
                var fromEmail = Email_List.Where(x => x.EmailID == Convert.ToInt32(!string.IsNullOrEmpty(SendingEmalTxt) ? SendingEmalTxt : "0")).Select(x => x.EmailTxt).FirstOrDefault();

                if (ToEmail != null && fromEmail != null)
                {
                    var myMailUtilityBAL = new Common.MailUtilityBAL();
                    var body             = "";
                    #region Contact US
                    body  = "<table style=\"font-family:Arial;font-size:12px\" border=\"0\" align=\"left\" cellpadding=\"4\" cellspacing=\"0\" >";
                    body += "<tr><td colspan='2' > Dear Admin,<br/><br/>Following user has posted comment from Killeen ISD website blog with the following information:</td></tr>";
                    body += @"<tr><td colspan='2' ><div style='float:left; padding:20px; background:#F8F8F8; width:450px; font-family:Arial;font-size: 12px;'>
                                <table width='100%' cellspacing='2' cellpadding='2'
                                style='font-family:Arial;font-size: 12px;'><tbody>";
                    body += @" <tr>
                                            <td width='45%' valign='top' align='left' style='padding: 2px 0;'><b> Name:</b></td>
                                            <td width='55%' valign='top' align='left' style='padding: 2px 0;'>" + name + @"
                                            </td>
                                        </tr>
                                          <tr>
                                            <td valign='top' align='left' style='padding: 2px 0;'><b>Email:</b></td>
                                            <td valign='top' align='left' style='padding: 2px 0;'>" + (string.IsNullOrEmpty(email) ? "-" : email) + @"
                                            </td>
                                        </tr> 
                                        <tr>
                                            <td valign='top' align='left' style='padding: 2px 0;'><b>Phone:</b></td>
                                            <td valign='top' align='left' style='padding: 2px 0;'>" + (string.IsNullOrEmpty(phone) ? "-" : phone) + @"
                                            </td>
                                        </tr> 
                                        <tr>
                                            <td valign='top' align='left' style='padding: 2px 0;'><b>Comment:</b></td>
                                            <td valign='top' align='left' style='padding: 2px 0;'>" + (string.IsNullOrEmpty(Comment) ? "-" : Comment) + @"
                                            </td>
                                        </tr>
                                       ";
                    body += @"</table></div></td></tr>";
                    body  = body + "<tr><td colspan='2'><br/>Regards,<br/>Killeen ISD Team.</td></tr></table>";
                    #endregion
                    try
                    {
                        if (ToEmail.Contains(","))
                        {
                            var ToEmailArray = ToEmail.Split(',');
                            foreach (var item in ToEmailArray)
                            {
                                if (myMailUtilityBAL.SendEmail(fromEmail, item, body, ("Blog comment posting")).ToLower().Trim() == "ok")
                                {
                                    IsSucessSendMail = true;
                                }
                            }
                        }
                        else
                        {
                            if (myMailUtilityBAL.SendEmail(fromEmail, ToEmail, body, ("Blog comment posting")).ToLower().Trim() == "ok")
                            {
                                IsSucessSendMail = true;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        IsSucessSendMail = false;
                    }
                    var str = IsSucessSendMail ? "Comment posted successfully." : "There is an error while sending email. Please try again.";
                    TempData["AlertMessage"] = str;
                    #endregion
                }
                else
                {
                    TempData["AlertMessage"] = "Comment posted successfully.";
                }
                //**********************************Setting Section****************************************
                comments_per_post = Setting_List.Select(x => x.CommentPerPost).FirstOrDefault();// Comments per post
                model.SettingList = Setting_List;

                // ********************Gets updated Commnet List **********************
                var _CommentContexts_Updated = new BlogAdmin.Contexts.CommentContexts();                                                      //Setting Context
                var objComments_list         = _CommentContexts_Updated.GetComments().OrderByDescending(x => x.PostedDate).ToList();
                objComments_list = objComments_list.Where(x => x.BlogID == blogID && x.IsActiveInd == true).Take(comments_per_post).ToList(); // Comment Listing
                foreach (var item in objComments_list)
                {
                    var date_of_comment = Convert.ToDateTime(item.PostedDate);
                    var today           = DateTime.Now;
                    item.No_of_days = model.Get_Year_month_days(date_of_comment, today);
                }

                model.CommentList = objComments_list;// Comment List
                #endregion
            }
            catch (Exception)
            {
            }
            return(View(model));
        }
コード例 #5
0
        public ActionResult BlogContent(string Blogurl, int?BlogID, int?page, int?type, FormCollection fm)
        {
            int pageSize            = Admin.Models.Common._pageSize;
            int pageNumber          = (page ?? Admin.Models.Common._currentPage);
            var comments_per_post   = 4;
            var _Blogcontext        = new BlogAdmin.Contexts.BlogsContexts();      //Blog Context
            var _CategoriesContexts = new BlogAdmin.Contexts.CategoriesContexts(); //Categories Context
            var _TagsContexts       = new BlogAdmin.Contexts.TagsContexts();       //Tags Context
            var _SettingContexts    = new BlogAdmin.Contexts.SettingContexts();    //Setting Context
            var _ContextsComments   = new BlogAdmin.Contexts.CommentContexts();    // Comments Context

            var model = new Models.ContentModel();                                 // Content Model

            try
            {
                var blog_list = _Blogcontext.GetBlogs().Where(x => x.SlagTxt.ToLower() == Blogurl.ToLower() && x.IsActiveInd == true).OrderBy(x => x.PostedDate).FirstOrDefault();
                if (blog_list == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                #region BLog Listing Section
                var blogID = 0;
                if (_Blogcontext != null)
                {
                    blogID = blog_list.BlogID;
                    List <Models.ContentModel> bloglist = new List <Models.ContentModel>();//Create a list of blog items
                    model = new Models.ContentModel();
                    model.AuthorNameTxt       = blog_list.AuthorNameTxt;
                    model.AuthorNameID        = blog_list.AuthorNameID;
                    model.BlogDescription     = blog_list.BlogDescription;
                    model.BlogDescription     = blog_list.BlogDescription;
                    model.CategoryID          = blog_list.CategoryID;
                    model.ImagePathTxt        = blog_list.ImagePathTxt;
                    model.IsActiveInd         = blog_list.IsActiveInd;
                    model.IsCommentEnabledInd = blog_list.IsCommentEnabledInd;
                    model.MetaDescriptionTxt  = blog_list.MetaDescriptionTxt;
                    model.MetaTitleTxt        = blog_list.MetaTitleTxt;
                    model.PostedDate          = blog_list.PostedDate;
                    model.SlagTxt             = blog_list.SlagTxt;
                    model.SocialMediaTxt      = blog_list.SocialMediaTxt;
                    model.TitleTxt            = blog_list.TitleTxt;
                    model.AbstractTxt         = blog_list.AbstractTxt;
                    model.CategoryName        = blog_list.CategoryID != 0 ? _CategoriesContexts.GetCategories().Where(x => x.CategoryID == blog_list.CategoryID).Select(x => x.CategoryNameTxt).FirstOrDefault() : "";

                    //************************************TagList under each blog*********************************************
                    List <Models.TagNameList> blogTaglistName = new List <Models.TagNameList>();//Create a list of tags of single blog items
                    var getTagIDList = _Blogcontext.GetFormBlogTag(blog_list.BlogID).ToList();
                    foreach (var b in getTagIDList)
                    {
                        var obj = new Models.TagNameList();
                        obj.TagNameTxt = _TagsContexts.GetTags().Where(x => x.TagID == Convert.ToInt32(b)).Select(x => x.TagNameTxt).FirstOrDefault();;
                        obj.TagID      = Convert.ToInt32(b);
                        obj.BlogID     = blog_list.BlogID;
                        blogTaglistName.Add(obj);
                    }
                    model.TagNameList = blogTaglistName.OrderByDescending(x => x.TagNameTxt).ToList();
                    //****************************Social Media Listing*********************************************
                    var objSocialListing = _Blogcontext.GetFormBlogSocialMedia_List(blogID).ToList();
                    model.SocialList = objSocialListing;
                    bloglist.Add(model);
                    model.IsPagingVisible = true;
                    model.PagedBlog       = bloglist.ToPagedList(pageNumber, pageSize);
                }
                #endregion

                #region Seeting Section region
                var objSetting_List = _SettingContexts.GetSettings().ToList();                      // Get Setting Theme list
                comments_per_post = objSetting_List.Select(x => x.CommentPerPost).FirstOrDefault(); // Comments per post
                model.SettingList = objSetting_List;
                #endregion

                #region  Comment Section
                var objComments_list = _ContextsComments.GetComments().ToList();
                objComments_list = objComments_list.Where(x => x.BlogID == blogID && x.IsActiveInd == true).Take(comments_per_post).ToList();// Comment Listing
                foreach (var item in objComments_list)
                {
                    var date_of_comment = Convert.ToDateTime(item.PostedDate);
                    var today           = DateTime.Now;
                    item.No_of_days = model.Get_Year_month_days(date_of_comment, today);
                }

                model.CommentList = objComments_list;
                #endregion
            }
            catch (Exception)
            { }

            return(View(model));
        }