public ActionResult Change_post(int?post_id, string type, string act, string ctrl, string type_act, string lang)
        {
            CatalogModels         cateModels          = new CatalogModels();
            PostModels            postModel           = new PostModels();
            C_Catalog             cate                = new C_Catalog();
            C_Post                objPost             = new C_Post();
            List <SelectListItem> list_select_catalog = new List <SelectListItem>();
            var           post_view = new Web.Areas.Admin.ViewModels.Post_view();
            StringBuilder sb        = new StringBuilder();
            int           level     = 0;

            if (string.IsNullOrEmpty(type))
            {
                type = Request.QueryString["type"] != null ? Request.QueryString["type"].ToString() : CommonGlobal.CateNews;
            }

            if (string.IsNullOrEmpty(act))
            {
                act = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : "change_post";
            }

            if (string.IsNullOrEmpty(ctrl))
            {
                ctrl = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : "adminPost";
            }

            if (post_id == null)
            {
                post_id = RouteData.Values["id"] != null?Convert.ToInt32(RouteData.Values["id"].ToString()) : 0;
            }

            if (string.IsNullOrEmpty(lang))
            {
                lang = LanguageModels.ActiveLanguage().LangCultureName;
            }

            if (string.IsNullOrEmpty(type_act))
            {
                type_act = Request.QueryString["type_act"] != null ? Request.QueryString["type_act"].ToString() : CommonGlobal.Add;
                if (post_id == 0)
                {
                    type_act = CommonGlobal.Add;
                }
                else
                {
                    type_act = CommonGlobal.Edit;
                }
            }

            if (type_act == CommonGlobal.Edit)
            {
                objPost                = postModel.GetbyID((int)post_id);
                post_view.PostID       = objPost.PostID;
                post_view.PostName     = objPost.PostName;
                post_view.PostContent  = objPost.PostContent;
                post_view.ImagePath    = objPost.ImagePath;
                post_view.Title        = objPost.Title;
                post_view.Keyword      = objPost.Keyword;
                post_view.Description  = objPost.Description;
                post_view.Summary      = objPost.Summary;
                post_view.Lang         = objPost.Lang;
                post_view.CatalogID    = (int)objPost.CatelogID;
                post_view.OrderDisplay = (int)objPost.OrderDisplay;
                post_view.Parent       = (int)objPost.CatelogID;
                post_view.CreateDate   = objPost.CreateDate ?? DateTime.Now;
                if ((objPost.IsHot ?? false) == true)
                {
                    post_view.IsHot         = true;
                    post_view.Is_short_text = "checked='checked'";
                }
                else
                {
                    post_view.IsHot         = false;
                    post_view.Is_short_text = string.Empty;
                }

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

                cateModels.List_catalog_parent(0, level, (int)objPost.CatelogID, type, cate.Lang ?? objPost.Lang, ref list_select_catalog);

                ////Link tab
                sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "list_post", ctrl = "adminPost", type = type, page = "1", lang = objPost.Lang }) + "\"><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>");

                post_view.List_language = this.List_select_language(cate.Lang ?? objPost.Lang);
            }
            else
            {
                ////Link tab
                sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "list_post", ctrl = "adminPost", type = type, page = "1", lang = lang }) + "\"><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>");

                cateModels.List_catalog_parent(0, level, 0, type, lang, ref list_select_catalog);
                post_view.List_language = this.List_select_language(lang);
            }

            post_view.List_category = list_select_catalog;
            post_view.Type          = type;
            post_view.Type_act      = type_act;
            post_view.Html_link_tab = sb.ToString();
            ////action
            post_view.Act               = act;
            post_view.Ctrl              = ctrl;
            post_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            post_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();
            ////end action

            return(this.PartialView("../control/change_post", post_view));
        }
        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));
        }