/// <summary>
        /// Updates the status is hot post.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="status">The status.</param>
        /// <param name="type">The type.</param>
        /// <returns>update status is hot post</returns>
        public ActionResult Update_status_is_hot_post(string id, string status, string type)
        {
            PostModels postModel = new PostModels();
            C_Post     objPost   = new C_Post();
            bool       isOk      = false;

            if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, "change_post", "adminPost", CommonGlobal.Edit, type))
            {
                isOk = true;
            }
            else
            {
                isOk = false;
            }

            if (!string.IsNullOrEmpty(id))
            {
                if (int.Parse(id) > 0)
                {
                    objPost = postModel.GetbyID(int.Parse(id));
                }

                if (objPost != null)
                {
                    try
                    {
                        if (bool.Parse(status) == true)
                        {
                            objPost.IsHot = true;
                        }
                        else
                        {
                            objPost.IsHot = false;
                        }

                        if (isOk)
                        {
                            objPost.DateModified = DateTime.Now;
                            postModel.Edit(objPost);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            var jsonSerialiser = new JavaScriptSerializer();
            var results        = Convert.ToDateTime(DateTime.Now).ToString("dd/MM/yyyy") + "|" + objPost.IsHot;

            return(this.Json(results));
        }
        public ActionResult Change_post(FormCollection collection, HttpPostedFileBase file_image)
        {
            CatalogModels         cateModels          = new CatalogModels();
            PostModels            postModel           = new PostModels();
            C_Post                objPost             = new C_Post();
            StringBuilder         sb                  = new StringBuilder();
            int                   rt                  = 0;
            bool                  is_valid            = true;
            int                   level               = 0;
            List <SelectListItem> list_select_catalog = new List <SelectListItem>();
            var                   post_view           = new Web.Areas.Admin.ViewModels.Post_view();

            this.TryUpdateModel(post_view);

            if (post_view.PostID > 0)
            {
                objPost = postModel.GetbyID(post_view.PostID);
            }

            ////validation server
            if (string.IsNullOrEmpty(post_view.PostName))
            {
                is_valid          = false;
                post_view.Message = "Bạn cần nhập tên danh mục";
            }

            ////validation server
            if (post_view.Parent == 0)
            {
                is_valid          = false;
                post_view.Message = "Bạn cần lựa chọn danh mục";
            }
            ////action
            ////post_view.act = "change_post";
            ////post_view.ctrl = "adminPost";
            post_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            post_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();

            if (post_view.PostID != 0 && post_view.Type_act == CommonGlobal.Edit)
            {
                ////Link tab
                sb.Append("<li><a class=\"active\" href=\"" + Url.Action("index", "dashboard", new { act = "list_post", ctrl = "adminPost", type = post_view.Type, page = "1" }) + "\"><span><span>Danh sách tin tức</span></span></a></li>");
                sb.Append("<li class=\"active\"><a href=\"#\"><span><span>Cập nhật</span></span></a></li>");

                ////list parent
                cateModels.List_catalog_parent(0, level, objPost.CatelogID ?? 0, post_view.Type, objPost.Lang, ref list_select_catalog);
                post_view.List_category = list_select_catalog;

                ////list language
                post_view.List_language = this.List_select_language(objPost.Lang);
            }
            else
            {
                ////Link tab
                sb.Append("<li><a class=\"active\" href=\"" + Url.Action("index", "dashboard", new { act = "list_post", ctrl = "adminPost", type = post_view.Type, page = "1" }) + "\"><span><span>Danh sách tin tức</span></span></a></li>");
                sb.Append("<li class=\"active\"><a href=\"#\"><span><span>Thêm mới</span></span></a></li>");

                ////list parent
                cateModels.List_catalog_parent(0, level, 0, post_view.Type, post_view.Lang, ref list_select_catalog);
                post_view.List_category = list_select_catalog;

                ////list language
                post_view.List_language = this.List_select_language(post_view.Lang);
            }

            post_view.Html_link_tab = sb.ToString();

            if (!is_valid)
            {
                return(this.PartialView("../control/change_post", post_view));
            }

            ////Post info
            objPost.CatelogID = post_view.Parent;
            objPost.PostName  = post_view.PostName;

            var imgPathTemp = "images/newspost/" +
                              DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/";
            var name_time = DateTime.Now.Day + DateTime.Now.Month + DateTime.Now.Year + DateTime.Now.Hour + DateTime.Now.Minute + string.Empty;

            if (file_image != null && file_image.ContentLength > 0 && CommonGlobal.IsImage(file_image) == true)
            {
                string image_small = imgPathTemp + "sc_small_" + name_time + "_" + CommonGlobal.CompleteNamefileImages(file_image.FileName);
                string image_lager = imgPathTemp + "sc_full_" + name_time + "_" + CommonGlobal.CompleteNamefileImages(file_image.FileName);

                ////save image and delete old file
                this.Savephoto(objPost.ImagePath, file_image, imgPathTemp, image_small, image_lager);

                ////set image thumb to link catalog
                objPost.ImagePath   = "/" + image_small;
                post_view.ImagePath = "/" + image_small;
            }
            else if (string.IsNullOrEmpty(objPost.ImagePath))
            {
                objPost.ImagePath = "0";
            }
            else
            {
                objPost.ImagePath = post_view.ImagePath;
            }

            objPost.Link         = CommonGlobal.CompleteLink(post_view.PostName);
            objPost.Summary      = post_view.Summary;
            objPost.PostContent  = post_view.PostContent;
            objPost.DateModified = DateTime.Now;
            objPost.IsHot        = post_view.IsHot;
            if (objPost.IsHot == true)
            {
                post_view.IsHot         = true;
                post_view.Is_short_text = "checked='checked'";
            }
            else
            {
                post_view.IsHot         = false;
                post_view.Is_short_text = string.Empty;
            }

            objPost.Approve = post_view.Approve;

            if (objPost.Approve == true)
            {
                post_view.Approve   = true;
                post_view.Show_text = "checked='checked'";
            }
            else
            {
                post_view.Approve   = false;
                post_view.Show_text = string.Empty;
            }

            objPost.Lang         = post_view.Lang;
            objPost.Title        = post_view.Title;
            objPost.Keyword      = post_view.Keyword;
            objPost.Description  = post_view.Description;
            objPost.OrderDisplay = post_view.OrderDisplay;

            if (post_view.PostID != 0 && post_view.Type_act == CommonGlobal.Edit)
            {
                objPost.CreateDate = post_view.CreateDate;
                rt = postModel.Edit(objPost);
            }
            else
            {
                objPost.CreateDate = DateTime.Now;
                rt = postModel.Add(objPost);
            }

            if (rt > 0)
            {
                post_view.Message  = "Cập nhật thành công!";
                post_view.PostID   = rt;
                post_view.Type_act = CommonGlobal.Edit;
            }
            else
            {
                post_view.Message = "Cập nhật không thành công!";
            }

            return(this.PartialView("../control/change_post", post_view));
        }