예제 #1
0
        protected override async Task OnParametersSetAsync()
        {
            Blogs = new BlogsModel(NodeService)
            {
                NodeSearch = new NodeSearch()
                {
                    Module  = Constants.BlogsModule,
                    Type    = Constants.BlogType,
                    OrderBy = new string[]
                    {
                        OrderBy.Title
                    }
                }
            };
            await Blogs.InitAsync();

            var loggedInUserId = (await AuthenticationStateTask).LoggedInUserId();

            CanAddBlog = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.BlogsModule,
                Constants.BlogType,
                Actions.Add
                );
        }
예제 #2
0
 private void OnDataRequested(DataTransferManager sender, DataRequestedEventArgs args)
 {
     if (BlogsModel != null)
     {
         BlogsModel.GetShareContent(args.Request);
     }
 }
예제 #3
0
 public BlogsDetailsPage(BlogsModel blogsmdl)
 {
     InitializeComponent();
     BindingContext = App.Locator.BlogsDetailsPage;
     _blogsmdl      = blogsmdl;
     App.Locator.BlogsDetailsPage.Init(_blogsmdl);
 }
예제 #4
0
 /// <summary>
 /// 加载右侧档案与分类列表数据
 /// </summary>
 /// <param name="userId">用户id</param>
 /// <returns>文章详情页模型</returns>
 private T LoadRightMenusData <T>(long userId) where T : class, new()
 {
     if (typeof(T) == typeof(DetailModel))
     {
         var model = new DetailModel();
         // 随笔档案
         model.Archives = articleService.GetArchivesByUserId <Archives>(userId);
         // 随笔分类
         model.CustomCategories = articleService.GetCustomCategoriesByUserId <CustomCategories>(userId);
         return(model as T);
     }
     else if (typeof(T) == typeof(BlogsModel))
     {
         var model = new BlogsModel();
         // 随笔档案
         model.Archives = articleService.GetArchivesByUserId <Archives>(userId);
         // 随笔分类
         model.CustomCategories = articleService.GetCustomCategoriesByUserId <CustomCategories>(userId);
         return(model as T);
     }
     else
     {
         return(null);
     }
 }
예제 #5
0
 /// <summary>
 /// Refresh ViewModel items asynchronous
 /// </summary>
 public async Task RefreshData(bool isNetworkAvailable)
 {
     var refreshTasks = new Task[]
     {
         HowStuffWorksModel.RefreshItems(isNetworkAvailable),
         VideosModel.RefreshItems(isNetworkAvailable),
         BlogsModel.RefreshItems(isNetworkAvailable),
     };
     await Task.WhenAll(refreshTasks);
 }
예제 #6
0
 /// <summary>
 /// Load ViewModel items asynchronous
 /// </summary>
 public async Task LoadData(bool isNetworkAvailable)
 {
     var loadTasks = new Task[]
     {
         HowStuffWorksModel.LoadItems(isNetworkAvailable),
         VideosModel.LoadItems(isNetworkAvailable),
         BlogsModel.LoadItems(isNetworkAvailable),
     };
     await Task.WhenAll(loadTasks);
 }
 internal void Init(BlogsModel blogsmdl)
 {
     Title          = blogsmdl.Title;
     Image          = blogsmdl.Images;
     Descreptions   = blogsmdl.Descreptions;
     Date           = blogsmdl.Date;
     DateImage      = blogsmdl.DateImage;
     Comment        = blogsmdl.Comment;
     CommentImage   = blogsmdl.CommentImage;
     PublishComment = "Take note, comments must be approved before publishing.";
 }
예제 #8
0
        public BaseController()
        {
            ViewData["all_products"]         = new ProductsModel();
            ViewData["blogs"]                = new BlogsModel();
            ViewData["collections"]          = new CollectionsModel();
            ViewData["linklists"]            = new LinklistsModel();
            ViewData["pages"]                = new PagesModel();
            ViewData["settings"]             = new SettingsModel();
            ViewData["theme"]                = new ThemeModel();
            ViewData[ContextKey.SITE_CONFIG] = InitSiteConfiguration();
            var contentForHeaderBuilder = new ContentForHeaderBuilder();

            ViewData["content_for_header"] = contentForHeaderBuilder.Render();
            //ViewData["request.host"] = Request.Url.Host;
        }
        public IActionResult detail(BlogsModel model)
        {
            var setupValues = _setupRepo.getQueryable().ToList();

            ViewBag.setup = setupValues;
            var notice = _noticeRepo.getQueryable().Where(n => n.notice_expiry_date >= DateTime.Now && n.is_closed == false).Take(5).ToList();

            ViewBag.notices = notice;
            try
            {
                var blogDetails = _blogRepo.getBySlug(model.slug);

                //Blog
                model.blog_id     = blogDetails.blog_id;
                model.artical_by  = blogDetails.artical_by;
                model.description = blogDetails.description;
                model.image_name  = blogDetails.image_name;
                model.posted_on   = blogDetails.posted_on;;
                model.title       = blogDetails.title;
                model.is_enabled  = blogDetails.is_enabled;
                model.slug        = blogDetails.slug;

                var blogcomments = _blogCommentRepo.getQueryable().Where(a => a.blog_id == model.blog_id).ToList();

                List <BlogComments> blogComments = new List <BlogComments>();
                foreach (var comment in blogcomments)
                {
                    BlogComments blogcomment = new BlogComments();
                    blogcomment.comments     = comment.comments;
                    blogcomment.comment_by   = comment.comment_by;
                    blogcomment.comment_date = comment.comment_date;
                    blogcomment.email        = comment.email;
                    blogComments.Add(blogcomment);
                }
                model.blog_comments = blogComments;
            }
            catch (Exception ex)
            {
                AlertHelper.setMessage(this, ex.Message, messageType.error);
            }

            return(View(model));
        }
예제 #10
0
        protected override async Task OnParametersSetAsync()
        {
            var configSearch = new NodeSearch()
            {
                Module = Constants.BlogsModule,
                Type   = Constants.ConfigType
            };
            var configNodes = (await NodeService.GetAsync(configSearch, 0));

            if (configNodes.Length > 0)
            {
                Config = configNodes[0];
            }
            Blogs = new BlogsModel(NodeService)
            {
                NodeSearch = new NodeSearch()
                {
                    Module          = Constants.BlogsModule,
                    Type            = Constants.BlogType,
                    OrderBy         = $"{OrderBy.Title}",
                    TruncateContent = 140
                }
            };
            await Blogs.InitAsync();

            var loggedInUserId = (await AuthenticationStateTask).LoggedInUserId();

            CanEditConfig = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.BlogsModule,
                Constants.ConfigType,
                Actions.Edit
                );

            CanAddBlog = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.BlogsModule,
                Constants.BlogType,
                Actions.Add
                );
        }
예제 #11
0
        public ActionResult Index()
        {
            // Doing top on a join query is not supported ATM since it makes no sense for
            // one to many joins. However, it does make sense the other way around. So
            // maybe add support for it? Could be very confusing for those who do not
            // undestand the generated SQL though...

            // Since top is not supported for joins, simply use TOP to find the ids of the
            // posts we want and then fetch the posts and their relatives in a separate
            // query.

            var top10PostIds = _repository.Find <BlogPost>()
                               .Select(x => x.Id)
                               .Top(10)
                               .OrderByDescending(x => x.PublishDate)
                               .ExecuteScalarList <int>();

            IList <BlogPost> posts = new List <BlogPost>();

            if (top10PostIds.Any())
            {
                posts = _repository
                        .Find <BlogPost>()
                        .OrderByDescending(x => x.PublishDate)
                        .Where(x => top10PostIds.Contains(x.Id))
                        .Join <User, BlogPost>(x => x.BlogPosts, x => x.Author)
                        .ExecuteList();
            }

            var blogs = _repository.Find <Blog>().ExecuteList();

            var model = new BlogsModel
            {
                Posts = posts,
                Blogs = blogs
            };

            return(View(model));
        }
예제 #12
0
        public ActionResult CreateBlog(BlogsModel _Blogsmodel, string command, FormCollection fm)
        {
            Session["Edit/Delete"] = "Edit";
            var file = Request.Files.Count > 0 ? Request.Files[0] : null;

            ViewBag.Title  = (_Blogsmodel.BlogID > 0 ? "Edit " : "Add ") + " Post Details ";
            ViewBag.Submit = _Blogsmodel.BlogID > 0 ? "Update" : "Save";
            bool isActive = true, allowComments = true;

            _Blogsmodel.TagList = GetAllTags();
            var _UsersContexts      = new Contexts.UsersContexts();
            var _CategoriesContexts = new Contexts.CategoriesContexts();
            var BlogsContext        = new Contexts.BlogsContexts();
            var TagContext          = new Contexts.TagsContexts();

            ViewBag.AuthorName = new SelectList(_UsersContexts.GetUserList(_Blogsmodel.AuthorNameID), "UserID", "UserNameTxt");//Author drop down listing
            ViewBag.Category   = new SelectList(_CategoriesContexts.GetSelectedCategories(string.Empty), "CategoryID", "CategoryNameTxt");

            if (string.IsNullOrEmpty(command))
            {
                isActive      = _Blogsmodel.IsActiveInd;
                allowComments = _Blogsmodel.IsCommentEnabledInd;
                ViewBag.IsCommentEnabledInd = Models.Common.GetStatusListBoolean(allowComments ? "true" : "false");
                ViewBag.IsActiveInd         = Models.Common.GetStatusListBoolean(isActive ? "true" : "false");
                _Blogsmodel.SocialMediaList = GetAllSocialMedia();
                _Blogsmodel.strCategoryid   = Convert.ToString(_Blogsmodel.strCategoryid);
                if (BlogsContext.GetBlogs().Where(x => x.TitleTxt == _Blogsmodel.TitleTxt && _Blogsmodel.BlogID != x.BlogID).Any())
                {
                    ModelState.AddModelError("TitleTxt", _Blogsmodel.TitleTxt + " Post already exists.");
                    return(View(_Blogsmodel));
                }

                if (_Blogsmodel.SlagTxt.ToLower() == "error404") //check 404 error
                {
                    ModelState.AddModelError("SlagTxt", _Blogsmodel.SlagTxt + " URL is not allowed.");
                    return(View(_Blogsmodel));
                }

                try
                {
                    //Save image path
                    if (file != null && file.ContentLength > 0)
                    {
                        #region Upload Image
                        Models.Common.CreateFolder();
                        var croppedfile = new System.IO.FileInfo(Server.MapPath(TempData["CroppedImage"].ToString()));
                        var fileName    = croppedfile.Name;
                        croppedfile = null;
                        var sourcePath = Server.MapPath(TempData["CroppedImage"].ToString());
                        var targetPath = Request.PhysicalApplicationPath + "WebData\\";
                        System.IO.File.Copy(System.IO.Path.Combine(sourcePath.Replace(fileName, ""), fileName), System.IO.Path.Combine(targetPath + "images\\", fileName), true);
                        try
                        {
                            Models.Common.DeleteImage(Server.MapPath(TempData["CroppedImage"].ToString()));
                        }
                        catch
                        {
                        }
                        TempData["CroppedImage"] = null;

                        _Blogsmodel.ImagePathTxt = "~/WebData/images/" + fileName;
                        var width         = 250;
                        var fileExtension = fileName.Substring(fileName.LastIndexOf("."), fileName.Length - fileName.LastIndexOf("."));
                        var strPath       = Request.PhysicalApplicationPath + "WebData\\images\\" + fileName;
                        var myImage       = Models.Common.CreateImageThumbnail(strPath, width);
                        myImage.Save(Request.PhysicalApplicationPath + "WebData\\thumbnails\\" + fileName,
                                     fileExtension.ToLower() == ".png" ?
                                     System.Drawing.Imaging.ImageFormat.Png :
                                     fileExtension.ToLower() == ".gif" ?
                                     System.Drawing.Imaging.ImageFormat.Gif :
                                     System.Drawing.Imaging.ImageFormat.Jpeg
                                     );
                        myImage.Dispose();
                        var mysmallImage = Models.Common.CreateImageThumbnail(strPath, 200);
                        mysmallImage.Save(Request.PhysicalApplicationPath + "WebData\\thumbnails_Small\\" + fileName,
                                          fileExtension.ToLower() == ".png" ?
                                          System.Drawing.Imaging.ImageFormat.Png :
                                          fileExtension.ToLower() == ".gif" ?
                                          System.Drawing.Imaging.ImageFormat.Gif :
                                          System.Drawing.Imaging.ImageFormat.Jpeg
                                          );
                        mysmallImage.Dispose();
                        #endregion
                    }
                    else
                    {
                        _Blogsmodel.ImagePathTxt = BlogsContext.GetBlogs().Where(x => x.BlogID == _Blogsmodel.BlogID).Select(x => x.ImagePathTxt).FirstOrDefault();
                    }
                    if (ViewBag.Submit == "Save")
                    {
                        BlogsContext.AddBlogs(_Blogsmodel);
                        TempData["AlertMessage"] = "Post details saved successfully.";
                    }
                    else
                    {
                        BlogsContext.EditBlogs(_Blogsmodel, false);
                        TempData["AlertMessage"] = "Post details updated successfully.";
                    }
                }
                catch (Exception ex)
                {
                    TempData["AlertMessage"] = "Some error occured, Please try after some time. " + ex.Message;
                }
            }
            var rvd = new RouteValueDictionary();
            rvd.Add("Column", Request.QueryString["Column"] != null ? Request.QueryString["Column"].ToString() : "PostedDate");
            rvd.Add("Direction", Request.QueryString["Direction"] != null ? Request.QueryString["Direction"].ToString() : "Descending");
            rvd.Add("pagesize", Request.QueryString["pagesize"] != null ? Request.QueryString["pagesize"].ToString() : Models.Common._pageSize.ToString());
            rvd.Add("page", Request.QueryString["page"] != null ? Request.QueryString["page"].ToString() : Models.Common._currentPage.ToString());
            return(RedirectToAction("BlogsListing", "Blogs", rvd));
        }
예제 #13
0
        public ActionResult BlogsListing(GridSortOptions gridSortOptions, int?pagetype, int?page, int?pagesize, FormCollection fm, string objresult)
        {
            var _objContext = new Contexts.BlogsContexts();

            ViewBag.Title = " Post Listing";
            var _BlogsModel = new BlogsModel();

            #region Ajax Call
            if (objresult != null)
            {
                AjaxRequest objAjaxRequest = JsonConvert.DeserializeObject <AjaxRequest>(objresult);//Convert json String to object Model
                if (objAjaxRequest.ajaxcall != null && !string.IsNullOrEmpty(objAjaxRequest.ajaxcall) && objresult != null && !string.IsNullOrEmpty(objresult))
                {
                    if (objAjaxRequest.ajaxcall == "paging")       //Ajax Call type = paging i.e. Next|Previous|Back|Last
                    {
                        Session["pageNo"] = page;                  // stores the page no for status
                    }
                    else if (objAjaxRequest.ajaxcall == "sorting") //Ajax Call type = sorting i.e. column sorting Asc or Desc
                    {
                        page = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"].ToString()) : page);
                        Session["GridSortOption"] = gridSortOptions;
                        pagesize = (Session["PageSize"] != null ? Convert.ToInt32(Session["PageSize"].ToString()) : pagesize);
                    }
                    else if (objAjaxRequest.ajaxcall == "ddlPaging")//Ajax Call type = drop down paging i.e. drop down value 10, 25, 50, 100, ALL
                    {
                        Session["PageSize"]       = (Request.QueryString["pagesize"] != null ? Convert.ToInt32(Request.QueryString["pagesize"].ToString()) : pagesize);
                        Session["GridSortOption"] = gridSortOptions;
                        Session["pageNo"]         = page;
                    }
                    else if (objAjaxRequest.ajaxcall == "status")//Ajax Call type = status i.e. Active/Inactive
                    {
                        page            = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"].ToString()) : page);
                        gridSortOptions = (Session["GridSortOption"] != null ? Session["GridSortOption"] as GridSortOptions : gridSortOptions);
                    }
                    else if (objAjaxRequest.ajaxcall == "displayorder")//Ajax Call type = Display Order i.e. drop down values
                    {
                        page            = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"].ToString()) : page);
                        gridSortOptions = (Session["GridSortOption"] != null ? Session["GridSortOption"] as GridSortOptions : gridSortOptions);
                    }
                    objAjaxRequest.ajaxcall = null;; //remove parameter value
                }

                //Ajax CAll for update status for images
                if (objAjaxRequest.hfid != null && objAjaxRequest.hfvalue != null && !string.IsNullOrEmpty(objAjaxRequest.hfid) && !string.IsNullOrEmpty(objAjaxRequest.hfvalue) && objresult != null && !string.IsNullOrEmpty(objresult) && objAjaxRequest.hfvalue.ToString().Trim().ToLower() != "displayOrder".Trim().ToLower())
                {
                    var id1  = Convert.ToInt64(objAjaxRequest.hfid);
                    var blog = _objContext.GetBlogs().Where(x => x.BlogID == id1).FirstOrDefault();
                    if (blog != null)
                    {
                        blog.IsActiveInd = objAjaxRequest.hfvalue == "1";
                        try
                        {
                            blog.strCategoryid = Convert.ToString(blog.CategoryID);
                            _objContext.EditBlogs(blog, true);
                            TempData["AlertMessage"] = "Status updated successfully.";
                        }
                        catch
                        {
                            TempData["AlertMessage"] = "Some error occured, Please try after some time.";
                        }

                        objAjaxRequest.hfid    = null; //remove parameter value
                        objAjaxRequest.hfvalue = null; //remove parameter value
                        pagesize        = (Request.QueryString["pagesize"] != null ? Convert.ToInt32(Request.QueryString["pagesize"].ToString()) : pagesize);
                        page            = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"].ToString()) : page);
                        gridSortOptions = (Session["GridSortOption"] != null ? Session["GridSortOption"] as GridSortOptions : gridSortOptions);
                    }
                }
                else
                {
                    TempData["Message"] = string.Empty;
                }
                objresult = string.Empty;
            }
            #endregion Ajax Call
            //This section is used to retain the values of page , pagesize and gridsortoption on complete page post back(Edit, Dlete)
            if (!Request.IsAjaxRequest() && Session["Edit/Delete"] != null && !string.IsNullOrEmpty(Session["Edit/Delete"].ToString()))
            {
                pagesize               = (Session["PageSize"] != null ? Convert.ToInt32(Session["PageSize"]) : Models.Common._pageSize);
                page                   = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"]) : Models.Common._currentPage);
                gridSortOptions        = (Session["GridSortOption"] != null ? Session["GridSortOption"] as GridSortOptions : gridSortOptions);
                Session["Edit/Delete"] = null;
            }
            else if (!Request.IsAjaxRequest() && Session["Edit/Delete"] == null)
            {
                //gridSortOptions.Column = "CreateDate";
                Session["PageSize"]       = null;
                Session["pageNo"]         = null;
                Session["GridSortOption"] = null;
            }

            var pageSize = pagesize.HasValue ? pagesize.Value : Models.Common._pageSize;
            var Page     = page.HasValue ? page.Value : Models.Common._currentPage;
            TempData["pager"] = pagesize;

            if (gridSortOptions.Column != null && gridSortOptions.Column == "TitleTxt" || gridSortOptions.Column == "AuthorNameTxt" || gridSortOptions.Column == "PostedDate")
            {
            }
            else
            {
                gridSortOptions.Column = "TitleTxt";
            }

            var pagedViewModel = new PagedViewModel <BlogsModel>
            {
                ViewData          = ViewData,
                Query             = _objContext.GetBlogs().AsQueryable(),
                GridSortOptions   = gridSortOptions,
                DefaultSortColumn = "TitleTxt",
                Page     = Page,
                PageSize = pageSize,
            }.Setup();

            if (Request.IsAjaxRequest())                             // check if request comes from ajax, then return Partial view
            {
                return(View("BlogsListingPartial", pagedViewModel)); // ("partial view name ")
            }
            else
            {
                return(View(pagedViewModel));
            }
        }
예제 #14
0
        public ActionResult CreateBlog(int?Blogid)
        {
            var _BlogsContexts      = new Contexts.BlogsContexts();
            var _CategoriesContexts = new Contexts.CategoriesContexts();
            var _UsersContexts      = new Contexts.UsersContexts();
            var _BlogsModel         = new BlogsModel();

            ViewBag.Title  = (Blogid.HasValue ? "Edit " : "Add ") + " Post Details ";
            ViewBag.Submit = Blogid.HasValue && Blogid.Value > 0 ? "Update" : "Save";

            bool isActive = true, allowComments = true;

            _BlogsModel.TagList         = GetAllTags();
            _BlogsModel.SocialMediaList = GetAllSocialMedia();
            try
            {
                var taglist = ViewBag.Tag = string.Join(",", _BlogsModel.TagList.Select(x => x.Text));
                if (Blogid.HasValue && Blogid.Value > 0)
                {
                    _BlogsModel = _BlogsContexts.GetBlogs().Where(x => x.BlogID == Blogid).FirstOrDefault();
                    if (_BlogsModel != null)
                    {
                        isActive                  = _BlogsModel.IsActiveInd;
                        allowComments             = _BlogsModel.IsCommentEnabledInd;
                        _BlogsModel.strCategoryid = Convert.ToString(_BlogsModel.CategoryID);

                        var selecetdtagNamearray = Array.ConvertAll <string, string>(_BlogsContexts.GetFormBlogTags(Blogid.Value).ToArray(),
                                                                                     delegate(string i)
                        {
                            return((string)i.ToString());
                        });

                        var selecetdtagIDarray = Array.ConvertAll <string, string>(_BlogsContexts.GetFormBlogTagsIDList(Blogid.Value).ToArray(),
                                                                                   delegate(string i)
                        {
                            return((string)i.ToString());
                        });

                        var selecetdSocialMediasarray = Array.ConvertAll <int, string>(_BlogsContexts.GetFormBlogSocialMedia(Blogid.Value).ToArray(),
                                                                                       delegate(int i)
                        {
                            return((string)i.ToString());
                        });

                        var UserList = _UsersContexts.GetUser(_BlogsModel.AuthorNameTxt);                                                                //User list based on userid
                        _BlogsModel.AuthorNameID        = Convert.ToString(UserList != null ? UserList.UserID : 0);                                      //UserID
                        ViewBag.Category                = new SelectList(_CategoriesContexts.GetSelectedCategories(Convert.ToString(_BlogsModel.CategoryID)), "CategoryID", "CategoryNameTxt");
                        ViewBag.AuthorName              = new SelectList(_UsersContexts.GetUserList(_BlogsModel.AuthorNameID), "UserID", "UserNameTxt"); //Author drop down listing
                        _BlogsModel.TagList             = GetAllTags();
                        _BlogsModel.SocialMediaList     = GetAllSocialMedia();
                        _BlogsModel.SelectedTags        = selecetdtagNamearray;
                        _BlogsModel.SelectedTagsID      = selecetdtagIDarray;
                        _BlogsModel.SelectedSocialMedia = selecetdSocialMediasarray;
                    }
                }
                else
                {
                    ViewBag.Category   = new SelectList(_CategoriesContexts.GetSelectedCategories(string.Empty), "CategoryID", "CategoryNameTxt");
                    ViewBag.AuthorName = new SelectList(_UsersContexts.GetUserList(string.Empty), "UserID", "UserNameTxt");//Author drop down listing
                    string[] Tagsarr = new string[] { "0" };
                    _BlogsModel.SelectedTagsID = Tagsarr;
                }
            }
            catch (Exception ex)
            {
                ViewBag.Category   = new SelectList(_CategoriesContexts.GetSelectedCategories(string.Empty), "CategoryID", "CategoryNameTxt");
                ViewBag.AuthorName = new SelectList(_UsersContexts.GetUserList(string.Empty), "UserID", "UserNameTxt");//Author drop down listing
                string[] Tagsarr = new string[] { "0" };
                _BlogsModel.SelectedTagsID = Tagsarr;
            }
            ViewBag.IsCommentEnabledInd = Models.Common.GetStatusListBoolean(allowComments ? "true" : "false");
            ViewBag.IsActiveInd         = Models.Common.GetStatusListBoolean(isActive ? "true" : "false");
            return(View(_BlogsModel));
        }
        // GET: /<controller>/
        public IActionResult Index()
        {
            var model = new BlogsModel();

            return(View());
        }
예제 #16
0
        public void AddBlogs(BlogsModel _BlogsModel)
        {
            _BlogsModel.BlogID = (int)(from S in BlogsData.Descendants("Blog") orderby(short) S.Element("BlogID") descending select(short) S.Element("BlogID")).FirstOrDefault() + 1;
            BlogsData.Root.Add(new XElement("Blog", new XElement("BlogID", _BlogsModel.BlogID),
                                            new XElement("TitleTxt", !string.IsNullOrEmpty(_BlogsModel.TitleTxt) ? _BlogsModel.TitleTxt : ""),
                                            new XElement("AuthorNameTxt", !string.IsNullOrEmpty(_BlogsModel.AuthorNameID) ? _BlogsModel.AuthorNameID : ""),
                                            new XElement("BlogDescription", !string.IsNullOrEmpty(_BlogsModel.BlogDescription) ? _BlogsModel.BlogDescription : ""),
                                            new XElement("ImagePathTxt", !string.IsNullOrEmpty(_BlogsModel.ImagePathTxt) ? _BlogsModel.ImagePathTxt : ""),
                                            new XElement("PostedDate", !string.IsNullOrEmpty(Convert.ToString(_BlogsModel.PostedDate)) ? _BlogsModel.PostedDate : System.DateTime.Today),
                                            new XElement("SlagTxt", !string.IsNullOrEmpty(_BlogsModel.SlagTxt) ? _BlogsModel.SlagTxt : ""),
                                            new XElement("IsActiveInd", _BlogsModel.IsActiveInd),
                                            new XElement("MetaTitleTxt", !string.IsNullOrEmpty(_BlogsModel.MetaTitleTxt) ? _BlogsModel.MetaTitleTxt : ""),
                                            new XElement("MetaKeywordTxt", !string.IsNullOrEmpty(_BlogsModel.MetaKeywordTxt) ? _BlogsModel.MetaKeywordTxt : ""),
                                            new XElement("MetaDescriptionTxt", !string.IsNullOrEmpty(_BlogsModel.MetaDescriptionTxt) ? _BlogsModel.MetaDescriptionTxt : ""),
                                            new XElement("IsCommentEnabledInd", _BlogsModel.IsCommentEnabledInd),
                                            new XElement("SocialMediaTxt", !string.IsNullOrEmpty(_BlogsModel.SocialMediaTxt) ? _BlogsModel.SocialMediaTxt : ""),
                                            new XElement("CategoryID", !string.IsNullOrEmpty(_BlogsModel.strCategoryid) ? Convert.ToInt32(_BlogsModel.strCategoryid) : 0),
                                            new XElement("AbstractTxt", !string.IsNullOrEmpty(_BlogsModel.AbstractTxt) ? _BlogsModel.AbstractTxt : "")

                                            ));

            BlogsData.Save(HttpContext.Current.Server.MapPath("~/App_Data/blogs.xml"));
            #region Tag section

            FormBlogTags _FormBlogTags  = new FormBlogTags();
            TagsModel    _TagsModel     = new TagsModel();
            var          _BlogsContexts = new BlogsContexts();
            _FormBlogTags.BlogID = _BlogsModel.BlogID;

            if (_BlogsModel.SelectedTagsID != null)
            {
                foreach (var item in _BlogsModel.SelectedTagsID)
                {
                    foreach (var i in item.Split(','))
                    {
                        var  _TagContexts = new TagsContexts();
                        var  id           = 0;
                        var  tagName      = string.Empty;
                        int  n;
                        var  flag      = false;
                        bool isNumeric = int.TryParse(i, out n);
                        if (isNumeric)
                        {
                            var formBlogtag_count = _BlogsContexts.GetAllFormBlogTags().Where(x => x.BlogID == _BlogsModel.BlogID && x.TagID == i.ToString()).Count();
                            if (formBlogtag_count == 0)
                            {
                                id      = _TagContexts.GetTags().Where(x => x.TagID == Convert.ToInt32(i)).Select(x => x.TagID).FirstOrDefault();
                                tagName = _TagContexts.GetTags().Where(x => x.TagID == Convert.ToInt32(i)).Select(x => x.TagNameTxt).FirstOrDefault();
                                flag    = true;
                            }
                        }
                        else
                        {
                            id      = 0;
                            tagName = i;
                        }

                        if (id == 0)
                        {
                            _TagsModel.TagNameTxt = tagName;
                            var IsTagName_exist = _TagContexts.GetTags().Where(x => x.TagNameTxt.ToLower().Trim() == tagName.ToLower().Trim()).Count();
                            if (IsTagName_exist == 0)
                            {
                                _TagContexts.AddTags(_TagsModel);// Add tags in tag context
                                id   = _TagContexts.GetTags().Select(x => x.TagID).Count() > 0 ? _TagContexts.GetTags().Select(x => x.TagID).Max() + 1 : 1;
                                flag = true;
                            }
                            else
                            {
                                var tagID_exist       = _TagContexts.GetTags().Where(x => x.TagNameTxt.ToLower().Trim() == tagName.ToLower().Trim()).Select(x => x.TagID).FirstOrDefault();
                                var formBlogtag_count = _BlogsContexts.GetAllFormBlogTags().Where(x => x.BlogID == _BlogsModel.BlogID && x.TagID == tagID_exist.ToString()).Count();
                                if (formBlogtag_count == 0)
                                {
                                    id   = tagID_exist;
                                    flag = true;
                                }
                            }
                        }

                        if (flag == true)
                        {
                            _FormBlogTags.BlogTagID = (int)(from S in BlogsTagsData.Descendants("FormBlogTag") orderby(short) S.Element("BlogTagID") descending select(short) S.Element("BlogTagID")).FirstOrDefault() + 1;
                            BlogsTagsData.Root.Add(new XElement("FormBlogTag", new XElement("BlogTagID", _FormBlogTags.BlogTagID),
                                                                new XElement("BlogID", _FormBlogTags.BlogID),
                                                                new XElement("TagID", id)));
                            BlogsTagsData.Save(HttpContext.Current.Server.MapPath("~/App_Data/formblogstag.xml"));
                        }
                    }
                }
            }
            #endregion

            #region social media
            FormBlogSocialMedia _FormBlogSM = new FormBlogSocialMedia();
            _FormBlogSM.BlogID = _BlogsModel.BlogID;
            if (_BlogsModel.SelectedSocialMedia != null)
            {
                foreach (var item in _BlogsModel.SelectedSocialMedia)
                {
                    _FormBlogSM.BlogSocialMediaID = (int)(from S in BlogsSocialMediaData.Descendants("FormBlogSocialMedia") orderby(short) S.Element("BlogSocialMediaID") descending select(short) S.Element("BlogSocialMediaID")).FirstOrDefault() + 1;
                    BlogsSocialMediaData.Root.Add(new XElement("FormBlogSocialMedia", new XElement("BlogSocialMediaID", _FormBlogSM.BlogSocialMediaID),
                                                               new XElement("BlogID", _FormBlogSM.BlogID),
                                                               new XElement("SocialMediaID", item)));
                }
                BlogsSocialMediaData.Save(HttpContext.Current.Server.MapPath("~/App_Data/formblogssocialmedia.xml"));
            }
            #endregion
        }