コード例 #1
0
        /// <summary>
        /// Posts the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="cate_id">The cate identifier.</param>
        /// <param name="cate_type">Type of the cate.</param>
        /// <returns>Posts the specified</returns>
        public ActionResult LookbookDetail(int?id, string cate_type)
        {
            /////lookbook detail
            GalleryModels sv         = new GalleryModels();
            CatalogModels cateModels = new CatalogModels();
            C_Catalog     cateItem   = new C_Catalog();

            id = RouteData.Values["id"] != null?Convert.ToInt16(RouteData.Values["id"].ToString()) : 0;

            var link = RouteData.Values["Link"] != null ? RouteData.Values["Link"].ToString() : string.Empty;

            if (string.IsNullOrEmpty(cate_type))
            {
                cate_type = CommonGlobal.CateGallery;
            }

            if (id == 0)
            {
                return(this.HttpNotFound());
            }
            else
            {
                cateItem = cateModels.GetbyID((int)id);

                if (cateItem.CatalogID == 0)
                {
                    return(this.HttpNotFound());
                }

                ViewBag.Title = cateItem.CategoryName + " | " + GeneralModels.GetContent(CommonGlobal.PageName, this.Lang);

                ////breadcrumbs
                string strbreadcrumbs = string.Empty;

                strbreadcrumbs = string.Format("<li><a href=\"" + Url.Action("lookbook", "gallery") + "\">" + App_GlobalResources.Lang.mnuGallery + "</a></li>");
                if (cateItem != null)
                {
                    strbreadcrumbs   += string.Format("<li><a href=\"" + Url.RouteUrl("_lookbook", new { controller = "gallery", action = "LookbookDetail", id = id, Link = cateItem.Link != null ? cateItem.Link : string.Empty, cate_type = cate_type }) + "\">" + cateItem.CategoryName + "</a></li>");
                    ViewBag.cate_name = cateItem.CategoryName;
                }

                strbreadcrumbs += string.Format("<li>" + cateItem.CategoryName + "</li>");

                ViewBag.str_breadcrumbs = strbreadcrumbs;
                ViewBag.back_link       = Url.RouteUrl("_lookbook", new { controller = "gallery", action = "LookbookDetail", id = id, Link = cateItem.Link != null ? cateItem.Link : string.Empty, cate_type = cate_type });
                ViewBag.heading         = cateItem.CategoryName;

                this.AddMeta(CommonGlobal.Keyword, cateItem.CategoryName);
                this.AddMeta(CommonGlobal.Description, this.ClearHtml(HttpUtility.HtmlDecode(cateItem.Description)));
                ViewBag.id        = id;
                ViewBag.cate_id   = id;
                ViewBag.cate_type = cate_type;
                ViewBag.ImagePath = cateItem.ImagePath;
                ViewBag.MoreInfo  = cateItem.MoreInfo;

                return(this.PartialView("../page/lookbookDetail"));
            }
        }
コード例 #2
0
        /// <summary>
        /// Posts the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="search">The search.</param>
        /// <param name="tag">The tag.</param>
        /// <param name="param">The parameter.</param>
        /// <param name="style_list">The style list.</param>
        /// <param name="type">The type.</param>
        /// <returns>the post</returns>
        public ActionResult Posts(int?id, string search, string tag, string param, string style_list, string type)
        {
            /////list post
            var    posts_view = new Posts_view();
            string strBread;

            id = RouteData.Values["id"] != null?Convert.ToInt16(RouteData.Values["id"].ToString()) : 0;

            var link = RouteData.Values["Link"] != null ? RouteData.Values["Link"].ToString() : string.Empty;

            if (Request.QueryString["search"] != null && Request.QueryString["search"].ToString() != string.Empty)
            {
                search = HttpUtility.HtmlDecode(Request.QueryString["search"].ToString());
            }

            if (id == 0)
            {
                ViewBag.Title           = App_GlobalResources.Lang.strPost + " | " + GeneralModels.GetContent(CommonGlobal.PageName, this.Lang);
                strBread                = "<li>" + App_GlobalResources.Lang.strPost + "</li>";
                posts_view.Heading      = App_GlobalResources.Lang.strPost;
                ViewBag.str_breadcrumbs = strBread;
            }
            else
            {
                CatalogModels cateModels = new CatalogModels();
                C_Catalog     obj        = cateModels.GetbyID((int)id);
                if (obj.Title != string.Empty)
                {
                    ViewBag.Title      = obj.Title + " | " + GeneralModels.GetContent(CommonGlobal.PageName, this.Lang);
                    strBread           = "<li>" + obj.Title + "</li>";
                    posts_view.Heading = obj.Title;
                }
                else
                {
                    ViewBag.Title      = obj.CategoryName + " | " + GeneralModels.GetContent(CommonGlobal.PageName, this.Lang);
                    strBread           = "<li>" + obj.CategoryName + "</li>";
                    posts_view.Heading = obj.CategoryName;
                }

                this.AddMeta(CommonGlobal.Keyword, obj.Keyword);
                this.AddMeta(CommonGlobal.Description, obj.Description);
                ViewBag.str_breadcrumbs = strBread;
            }

            posts_view.Link        = link;
            posts_view.Cate_id     = id ?? 0;
            posts_view.Text_search = search;
            posts_view.Tag         = tag;
            posts_view.Param       = param;
            posts_view.Style_list  = style_list;
            posts_view.Cate_type   = type;

            return(this.PartialView("../page/posts", posts_view));
        }
コード例 #3
0
        /// <summary>
        /// Updates the status catalog.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="status">The status.</param>
        /// <param name="type">The type.</param>
        /// <returns>update status catalog</returns>
        public ActionResult Update_status_catalog(string id, string status, string type)
        {
            CatalogModels cateModels = new CatalogModels();
            C_Catalog     cate       = new C_Catalog();
            bool          isOk       = false;

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

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

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

                        if (isOk)
                        {
                            cateModels.Edit(cate);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }

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

            return(this.Json(results));
        }
コード例 #4
0
        public ActionResult Change_catalog(int?parent, int?cate_id, string type, string act, string ctrl, string lang, string type_act)
        {
            CatalogModels         cateModels          = new CatalogModels();
            C_Catalog             cate                = new C_Catalog();
            StringBuilder         sb                  = new StringBuilder();
            List <SelectListItem> list_select_catalog = new List <SelectListItem>();
            var catalog_view = new Web.Areas.Admin.ViewModels.Catalog_view();
            int level        = 0;

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

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

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

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

            if (parent == null)
            {
                parent = string.IsNullOrEmpty(Request.QueryString["parent"]) ? 0 : Convert.ToInt32(Request.QueryString["parent"].ToString());
            }

            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 (cate_id == 0)
                {
                    type_act = CommonGlobal.Add;
                }
                else
                {
                    type_act = CommonGlobal.Edit;
                }
            }

            if (type_act == CommonGlobal.Edit)
            {
                cate = cateModels.GetbyID((int)cate_id);
                cateModels.List_catalog_parent(0, level, cate.ParentID ?? 0, type, cate.Lang ?? lang, ref list_select_catalog);
                var link_catalog = Url.Action("index", "dashboard", new { act = "list_catalog", ctrl = "adminCatalog", type_act = CommonGlobal.View, type = type, page = "1", parent = parent, lang = cate.Lang ?? lang });
                sb.Append("<li><a class=\"active\" href=\"" + link_catalog + "\"><span><span>Danh mục " + CommonGlobal.GetCatalogTypeName(type) + "</span></span></a></li>");
                sb.Append("<li class=\"active\"><a href=\"#\"><span><span>" + cate.CategoryName + "</span></span></a></li>");
                catalog_view.Lang          = cate.Lang ?? lang;
                catalog_view.Cate_id       = cate.CatalogID;
                catalog_view.Category_name = cate.CategoryName;
                catalog_view.ImagePath     = cate.ImagePath;
                catalog_view.Intro         = cate.Intro;
                catalog_view.MoreInfo      = cate.MoreInfo;
                catalog_view.Keyword       = cate.Keyword;
                catalog_view.Description   = cate.Description;
                catalog_view.Title         = cate.Title;
                catalog_view.Link          = cate.Link;
                catalog_view.Parent        = cate.ParentID ?? 0;
                if ((cate.Show ?? false) == true)
                {
                    catalog_view.Show      = true;
                    catalog_view.Show_text = "checked='checked'";
                }
                else
                {
                    catalog_view.Show      = false;
                    catalog_view.Show_text = string.Empty;
                }

                catalog_view.List_language = this.List_select_language(cate.Lang ?? this.Lang);
                catalog_view.OrderDisplay  = (int)cate.OrderDisplay;
            }
            else
            {
                cateModels.List_catalog_parent(0, level, (int)parent, type, lang, ref list_select_catalog);
                var link_catalog = Url.Action("index", "dashboard", new { act = "list_catalog", ctrl = "adminCatalog", type = type, page = "1", parent = parent, lang = lang });
                sb.Append("<li><a class=\"active\" href=\"" + link_catalog + "\"><span><span>Danh mục " + CommonGlobal.GetCatalogTypeName(type) + "</span></span></a></li>");
                sb.Append("<li class=\"active\"><a href=\"#\"><span><span>Thêm danh mục</span></span></a></li>");
                catalog_view.Lang          = lang;
                catalog_view.List_language = this.List_select_language(this.Lang);
                catalog_view.OrderDisplay  = cateModels.GetMaxOrderDisplay(type);
                catalog_view.Parent        = (int)parent;
            }

            catalog_view.List_parent   = list_select_catalog;
            catalog_view.Html_link_tab = sb.ToString();
            catalog_view.Type          = type;
            catalog_view.Type_act      = type_act;

            ////action and parent action
            catalog_view.Act               = act;
            catalog_view.Ctrl              = ctrl;
            catalog_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            catalog_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();

            return(this.PartialView("../control/change_catalog", catalog_view));
        }
コード例 #5
0
        public ActionResult List_catalog(int?parent, int?cate_id, string act, string ctrl, string type, string type_act, string lang, string search, int?page, int?page_size, string order_by, string order_type)
        {
            CatalogModels         cateModels          = new CatalogModels();
            C_Catalog             cate                = new C_Catalog();
            StringBuilder         sb                  = new StringBuilder();
            List <SelectListItem> list_select_catalog = new List <SelectListItem>();
            var list_catalog_view = new Web.Areas.Admin.ViewModels.List_catalog_view();
            int total_record      = 0;
            int level             = 0;

            /////type is get type catalog
            /////ex   : SP - product
            /////     : TT - news
            /////     : CL - collection
            /////     : LB - lookbook
            /////     : GL - gallery
            /////parent is parent id
            if (string.IsNullOrEmpty(type))
            {
                type = Request.QueryString["type"] != null ? Request.QueryString["type"].ToString() : CommonGlobal.CateProduct;
            }

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

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

            if (page == null || page == 0)
            {
                page = Request.QueryString["page"] != null?Convert.ToInt32(Request.QueryString["page"].ToString()) : 1;
            }

            if (parent == null)
            {
                parent = Request.QueryString["parent"] != null?Convert.ToInt32(Request.QueryString["parent"].ToString()) : 0;
            }

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

            if (page_size == null)
            {
                page_size = int.Parse(Util.GetConfigValue("NumberPageSizeAdmin", "30"));
            }

            if (string.IsNullOrEmpty(order_by) || string.IsNullOrEmpty(order_type))
            {
                order_by   = "OrderDisplay";
                order_type = "asc";
            }

            ////type act delete
            if (cate_id != null && type_act != null && type_act == CommonGlobal.Delete)
            {
                ////check permission delete
                if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, act, ctrl, type_act, type))
                {
                    cate = cateModels.GetbyID((int)cate_id);
                    if (cate != null)
                    {
                        ////delete old image
                        if (!string.IsNullOrEmpty(cate.ImagePath))
                        {
                            string strImg = cate.ImagePath;
                            strImg = "~" + strImg;
                            string fileDelete = Server.MapPath(strImg);
                            if (System.IO.File.Exists(fileDelete))
                            {
                                System.IO.File.Delete(fileDelete);
                            }

                            string fileDelete2 = Server.MapPath(strImg.Replace("sc_small_", "sc_full_"));
                            if (System.IO.File.Exists(fileDelete2))
                            {
                                System.IO.File.Delete(fileDelete2);
                            }
                        }

                        ////delete category
                        bool rt = cateModels.Delete((int)cate_id);
                        if (rt)
                        {
                            list_catalog_view.Message = "Bạn đã xóa danh mục " + cate_id;
                        }
                        else
                        {
                            list_catalog_view.Message = "Xóa không thành công";
                        }
                    }
                    else
                    {
                        list_catalog_view.Message = "Không tìm thấy danh mục : " + cate_id;
                    }
                }
                else
                {
                    list_catalog_view.Message = " Bạn không có quyền thực thi hành động xóa cho danh mục này ";
                }
            }

            if (parent != 0)
            {
                cate = cateModels.GetbyID((int)parent);
                list_catalog_view.Category_name = cate.CategoryName;
            }

            list_catalog_view.Type      = type;
            list_catalog_view.Cate_type = CommonGlobal.GetCatalogTypeName(type);
            list_catalog_view.Parent    = (int)parent;
            list_catalog_view.Lang      = lang;
            list_catalog_view.Type_act  = type_act;
            ////tab
            var link_dashboard      = Url.Action("index", "dashboard", new { act = "list_catalog", ctrl = "adminCatalog", type_act = CommonGlobal.View, type = type, page = "1", parent = parent, lang = lang });
            var link_change_catalog = Url.Action("index", "dashboard", new { act = "change_catalog", ctrl = "adminCatalog", type_act = CommonGlobal.Add, type = type, parent = parent, lang = lang });

            sb.Append("<li class=\"active\"><a class=\"active\" href=\"" + link_dashboard + "\"><span><span>Danh sách " + CommonGlobal.GetCatalogTypeName(type) + "</span></span></a></li>");
            sb.Append("<li><a href=\"" + link_change_catalog + "\"><span><span>Thêm mới</span></span></a></li>");
            list_catalog_view.Html_link_tab = sb.ToString();
            ////list language
            list_catalog_view.List_language = this.List_select_language(this.Lang);
            ////list category
            cateModels.List_catalog_parent(0, level, (int)parent, type, lang, ref list_select_catalog);
            list_catalog_view.List_parent = list_select_catalog;
            ////list page size and paging
            list_catalog_view.List_page_size = this.GetSizePagingPublic((int)page_size);
            list_catalog_view.Page           = (int)page;
            list_catalog_view.Page_size      = (int)page_size;
            ////list catalog
            list_catalog_view.Page_list_catalog = cateModels.GetAllCatalogByParentID((int)parent, type, lang, search, (int)page, (int)page_size, order_by, order_type, out total_record);
            list_catalog_view.Search            = search;
            list_catalog_view.Order_by          = order_by;
            list_catalog_view.Order_type        = order_type;
            list_catalog_view.Total_record      = total_record;
            ////acton and parent action
            list_catalog_view.Act               = act;
            list_catalog_view.Ctrl              = ctrl;
            list_catalog_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            list_catalog_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();

            return(this.PartialView("../control/list_catalog", list_catalog_view));
        }
コード例 #6
0
        public ActionResult Change_catalog(FormCollection collection, HttpPostedFileBase file_image)
        {
            CatalogModels         cateModels          = new CatalogModels();
            C_Catalog             cate                = new C_Catalog();
            StringBuilder         sb                  = new StringBuilder();
            int                   rt                  = 0;
            bool                  is_valid            = true;
            int                   level               = 0;
            List <SelectListItem> list_select_catalog = new List <SelectListItem>();
            var                   catalog_view        = new Web.Areas.Admin.ViewModels.Catalog_view();

            this.TryUpdateModel(catalog_view);

            if (catalog_view.Cate_id > 0)
            {
                cate = cateModels.GetbyID(catalog_view.Cate_id);
            }

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

            ////action
            catalog_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            catalog_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();

            if (catalog_view.Cate_id != 0 && catalog_view.Type_act == CommonGlobal.Edit)
            {
                ////tab
                var link_catalog = Url.Action("index", "dashboard", new { act = "list_catalog", ctrl = "adminCatalog", type_act = CommonGlobal.View, type = catalog_view.Type, page = "1", parent = catalog_view.Parent, lang = catalog_view.Lang });
                sb.Append("<li><a href=\"" + link_catalog + "\"><span><span>Danh sách " + CommonGlobal.GetCatalogTypeName(catalog_view.Type) + "</span></span></a></li>");
                sb.Append("<li class=\"active\"><a href=\"#\"><span><span>" + cate.CategoryName + "</span></span></a></li>");
                ////list parent
                cateModels.List_catalog_parent(0, level, cate.ParentID ?? 0, catalog_view.Type, cate.Lang, ref list_select_catalog);
                catalog_view.List_parent = list_select_catalog;
                ////list lang
                catalog_view.List_language = this.List_select_language(cate.Lang);
                catalog_view.Cate_id       = cate.CatalogID;
            }
            else
            {
                ////tab
                sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "list_catalog", ctrl = "adminCatalog", type_act = CommonGlobal.View, type = catalog_view.Type, page = "1", parent = catalog_view.Parent, lang = catalog_view.Lang }) + "\"><span><span>Danh sách " + CommonGlobal.GetCatalogTypeName(catalog_view.Type) + "</span></span></a></li>");
                sb.Append("<li class=\"active\"><a href=\"#\"><span><span>Thêm danh mục</span></span></a></li>");
                ////list parent
                cateModels.List_catalog_parent(0, level, 0, catalog_view.Type, catalog_view.Lang, ref list_select_catalog);
                catalog_view.List_parent = list_select_catalog;
                ////list lang
                catalog_view.List_language = this.List_select_language(catalog_view.Lang);
            }

            catalog_view.Html_link_tab = sb.ToString();

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

            cate.CategoryName = catalog_view.Category_name;
            cate.Description  = string.IsNullOrEmpty(catalog_view.Description) == false ? catalog_view.Description : string.Empty;
            cate.Keyword      = string.IsNullOrEmpty(catalog_view.Keyword) == false ? catalog_view.Keyword : string.Empty;
            if (!string.IsNullOrEmpty(catalog_view.Title))
            {
                cate.Title = catalog_view.Title;
            }
            else
            {
                cate.Title         = catalog_view.Category_name;
                catalog_view.Title = cate.Title;
            }

            cate.Intro        = string.IsNullOrEmpty(catalog_view.Intro) == false ? catalog_view.Intro : string.Empty;
            cate.MoreInfo     = string.IsNullOrEmpty(catalog_view.MoreInfo) == false ? catalog_view.MoreInfo : string.Empty;
            cate.Lang         = catalog_view.Lang;
            cate.OrderDisplay = catalog_view.OrderDisplay;
            cate.ParentID     = catalog_view.Parent;
            cate.Show         = catalog_view.Show;
            if ((cate.Show ?? false) == true)
            {
                catalog_view.Show      = true;
                catalog_view.Show_text = "checked='checked'";
            }
            else
            {
                catalog_view.Show      = false;
                catalog_view.Show_text = string.Empty;
            }

            cate.Link = CommonGlobal.CompleteLink(catalog_view.Category_name);
            cate.Type = catalog_view.Type;

            var imgPathTemp = "images/catalog/" + 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.SavephotoCategory(cate.ImagePath, file_image, imgPathTemp, image_small, image_lager);

                ////save image and delete old file
                this.SavephotoOriginal(cate.ImagePath, file_image, imgPathTemp, image_lager);

                ////set image thumb to link catalog
                cate.ImagePath         = "/" + image_lager;
                catalog_view.ImagePath = "/" + image_lager;
            }
            else if (string.IsNullOrEmpty(cate.ImagePath))
            {
                cate.ImagePath = "0";
            }
            else
            {
                cate.ImagePath = catalog_view.ImagePath;
            }

            if (catalog_view.Cate_id != 0 && catalog_view.Type_act == "edit")
            {
                rt = cateModels.Edit(cate);
            }
            else
            {
                rt = cateModels.Add(cate);
            }

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

            return(this.PartialView("../control/change_catalog", catalog_view));
        }
コード例 #7
0
        public ActionResult Post_list_all(string lang, string cate_type, int?cate_id, string link_text, string search, string tag, string param, int?page, int?page_size, string order, string style_list_show)
        {
            CatalogModels cateModels   = new CatalogModels();
            WebInfoModels web_infor    = new Models.WebInfoModels();
            int           total_record = 0;
            PostModels    postModels   = new PostModels();
            C_Catalog     cate         = null;

            ////request query string param
            page = Request.QueryString["page"] != null?Convert.ToInt16(Request.QueryString["page"].ToString()) : 1;

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

            if (string.IsNullOrEmpty(link_text))
            {
                link_text = RouteData.Values["Link"] != null ? RouteData.Values["Link"].ToString() : string.Empty;
            }

            if (cate_id > 0)
            {
                cate = cateModels.GetbyID((int)cate_id);
            }

            ////get order for product list
            string order_by   = string.Empty;
            string order_type = string.Empty;

            if (string.IsNullOrEmpty(order))
            {
                order_by   = "DateModified";
                order_type = "desc";
                order      = order_by + ";" + order_type;
            }
            else
            {
                if (order.Contains(';'))
                {
                    order_by   = order.Split(';')[0];
                    order_type = order.Split(';')[1];
                }
                else
                {
                    order_by   = "DateModified";
                    order_type = "desc";
                    order      = order_by + ";" + order_type;
                }
            }

            postModels.ClearCache(lang + cate_type + (cate_id ?? 0) + search + tag + param + page + page_size + order_by + order_type);

            List <SelectListItem> orderDrop = new List <SelectListItem>();

            orderDrop.AddRange(new SelectListItem[]
            {
                new SelectListItem {
                    Selected = order == "DateModified;desc" ? true : false, Text = App_GlobalResources.Lang.strOrderDateDesc, Value = "DateModified;desc"
                },
                new SelectListItem {
                    Selected = order == "DateModified;asc" ? true : false, Text = App_GlobalResources.Lang.strOrderDateAsc, Value = "DateModified;asc"
                }
            });

            List <C_Catalog> lst_parent     = new List <C_Catalog>();
            List <C_Catalog> lst_parent_all = new List <C_Catalog>();

            if (cate == null || (cate.CategoryName != App_GlobalResources.Lang.mnuRecruitment && cate.CategoryName != App_GlobalResources.Lang.mnuBeautyTips))
            {
                lst_parent = cateModels.GetbyParentID(0, cate_type, lang).Where(p => p.CategoryName != App_GlobalResources.Lang.mnuRecruitment && p.CategoryName != App_GlobalResources.Lang.mnuBeautyTips).ToList();

                foreach (var it in lst_parent)
                {
                    lst_parent_all.Add(it);
                    var lst_child = cateModels.GetbyParentID(it.CatalogID, cate_type, lang).Where(p => p.Show == true).ToList();
                    foreach (var child in lst_child)
                    {
                        lst_parent_all.Add(child);
                    }
                }
            }

            var posts_view = new ViewModels.Page_posts_view();

            posts_view.List_parent_category = lst_parent;
            posts_view.List_parent_all      = lst_parent_all;
            posts_view.List_page_size       = this.GetSizePagingPublic(page_size ?? int.Parse(Util.GetConfigValue("NumberPageSizeNews", "8")));
            posts_view.List_order           = orderDrop;
            posts_view.Page_list_post       = postModels.GetListPostAll(lang, cate_type, cate_id, search, tag, param, (int)page, (int)page_size, order_by, order_type, out total_record);
            posts_view.Total_record         = total_record;
            if (total_record == 0 && search != string.Empty && !string.IsNullOrEmpty(search))
            {
                posts_view.Text_search_result = App_GlobalResources.Lang.strSearchResult;
            }

            posts_view.Order      = order;
            posts_view.Page_size  = page_size ?? int.Parse(Util.GetConfigValue("NumberPageSizeNews", "4"));
            posts_view.Style_list = style_list_show;
            posts_view.Cate_type  = cate_type;
            posts_view.Cate_id    = cate_id ?? 0;
            if (cate != null && (cate.CategoryName == App_GlobalResources.Lang.mnuBeautyTips || cate.CategoryName == App_GlobalResources.Lang.mnuRecruitment))
            {
                posts_view.Cate_name = cate.CategoryName;
            }
            else
            {
                posts_view.Cate_name = string.Empty;
            }

            posts_view.Link              = link_text;
            posts_view.Lang              = lang;
            posts_view.Tag               = tag;
            posts_view.Text_search       = search;
            posts_view.Param             = param;
            posts_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            posts_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();

            return(this.PartialView("../control/post_list_all", posts_view));
        }
コード例 #8
0
        /// <summary>
        /// Posts the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="cate_id">The cate identifier.</param>
        /// <param name="cate_type">Type of the cate.</param>
        /// <returns>Posts the specified</returns>
        public ActionResult Post(int?id, int?cate_id, string cate_type)
        {
            /////post detail
            PostModels postModels = new PostModels();

            id = RouteData.Values["id"] != null?Convert.ToInt16(RouteData.Values["id"].ToString()) : 0;

            var link = RouteData.Values["Link"] != null ? RouteData.Values["Link"].ToString() : string.Empty;

            cate_id = string.IsNullOrEmpty(Request.QueryString["cate_id"]) ? 0 : Convert.ToInt16(Request.QueryString["cate_id"].ToString());
            if (string.IsNullOrEmpty(cate_type))
            {
                cate_type = CommonGlobal.CateNews;
            }

            if (id == 0)
            {
                return(this.HttpNotFound());
            }
            else
            {
                postModels.ClearCache(CommonGlobal.Post + string.Empty + id);
                C_Post obj = postModels.GetbyID((int)id);

                if (obj.PostID == 0)
                {
                    return(this.HttpNotFound());
                }

                ViewBag.Title = obj.Title + " | " + GeneralModels.GetContent(CommonGlobal.PageName, this.Lang);

                ////breadcrumbs
                string        strbreadcrumbs = string.Empty;
                CatalogModels catalogModel   = new CatalogModels();
                C_Catalog     cateItem       = new C_Catalog();

                if (cate_id == 0)
                {
                    if (obj.CatelogID != null && obj.CatelogID != 0)
                    {
                        cate_id = obj.CatelogID;
                    }
                }

                cateItem       = catalogModel.GetbyID((int)cate_id);
                strbreadcrumbs = string.Format("<li><a href=\"" + Url.RouteUrl((cate_type != CommonGlobal.CateService ? "_post_only" : "_service_only"), new { controller = "news", action = "posts" }) + "\">" + (cate_type != CommonGlobal.CateService ? App_GlobalResources.Lang.mnuNews : App_GlobalResources.Lang.mnuService) + "</a></li>");
                if (cateItem != null)
                {
                    strbreadcrumbs   += string.Format("<li><a href=\"" + Url.RouteUrl(cate_type == Web.Models.CommonGlobal.CateService ? "_service" : "_post", new { controller = "news", action = "posts", id = cate_id, Link = cateItem.Link != null ? cateItem.Link : string.Empty, cate_type = cate_type }) + "\">" + cateItem.CategoryName + "</a></li>");
                    ViewBag.cate_name = cateItem.CategoryName;
                }

                strbreadcrumbs += string.Format("<li>" + obj.Title + "</li>");

                ViewBag.str_breadcrumbs = strbreadcrumbs;
                ViewBag.back_link       = Url.RouteUrl(cate_type == CommonGlobal.CateService ? "_service" : "_post", new { controller = "news", action = "posts", id = cate_id, Link = cateItem.Link, cate_type = cate_type });
                ViewBag.heading         = obj.Title;

                this.AddMeta(CommonGlobal.Keyword, obj.Title);
                this.AddMeta(CommonGlobal.Description, this.ClearHtml(HttpUtility.HtmlDecode(obj.Summary)));
                ViewBag.id        = id;
                ViewBag.cate_id   = cate_id;
                ViewBag.cate_type = cate_type;

                ////// Add post cookies
                HttpCookie mycookie    = HttpContext.Request.Cookies["listPostView"];
                ArrayList  arrListView = new ArrayList();

                ////// Lấy danh sách post đã xem từ cookies
                if (mycookie != null)
                {
                    var arr = mycookie.Value.Split(',');
                    for (int j = 0; j < arr.Count(); j++)
                    {
                        arrListView.Add(arr[j]);
                    }
                }
                else
                {
                    arrListView = new ArrayList();
                }

                if (obj.PostID != 0)
                {
                    if (!Util.CheckExistInArray(obj.PostID.ToString(), arrListView))
                    {
                        arrListView.Add(obj.PostID.ToString());
                    }
                    ////// Lưu danh sách xuống cookies
                    string[] arrLst = (string[])arrListView.ToArray(typeof(string));

                    if (mycookie != null)
                    {
                        HttpContext.Response.Cookies.Remove("listPostView");
                        mycookie.Expires = DateTime.Now.AddMonths(-6);
                        mycookie.Value   = null;
                        HttpContext.Response.SetCookie(mycookie);
                    }

                    HttpCookie cookie_new = new HttpCookie("listPostView");
                    cookie_new.Value   = string.Join(",", arrLst);
                    cookie_new.Expires = DateTime.Now.AddMonths(6);
                    HttpContext.Response.Cookies.Add(cookie_new);
                }

                return(this.PartialView("../page/post"));
            }
        }
コード例 #9
0
        public ActionResult Post_detail(int?id, int?cate_id, string back_link, string cate_type)
        {
            string       url          = Request.Url.ToString();
            RatingModels ratingModels = new RatingModels();
            PostModels   postModels   = new PostModels();

            id = RouteData.Values["id"] != null?Convert.ToInt16(RouteData.Values["id"].ToString()) : 0;

            var post_view = new ViewModels.Post_detail_view();

            if (id == 0)
            {
                return(this.HttpNotFound());
            }
            else
            {
                postModels.ClearCache(CommonGlobal.Post + string.Empty + id);
                C_Post obj = postModels.GetbyID((int)id);
                if (obj.PostID == 0)
                {
                    return(this.HttpNotFound());
                }

                ////post_view.listRating = ratingModels.GetListRatingByItem(obj.PostID);
                ////StringBuilder _html5 = new StringBuilder();
                ////for (int j = 0; j < post_view.listRating.Count; j++)
                ////{

                ////    _html5.Append("<div class=\"review-header\">");
                ////    _html5.Append("   <h5>" + HttpUtility.HtmlDecode(post_view.listRating[j].name) + "</h5>");
                ////    _html5.Append("   <div class=\"product-rating\">");
                ////    _html5.Append("      <div class=\"stars\">");
                ////    var start = post_view.listRating[j].Rating ?? 0;
                ////    var other = 5 - start;
                ////    for (int jj = 0; jj < other; jj++)
                ////    {
                ////        _html5.Append("<span class=\"star\"></span>");
                ////    }
                ////    for (int ii = 0; ii < start; ii++)
                ////    {
                ////        _html5.Append("<span class=\"star active\"></span>");
                ////    }
                ////    _html5.Append("      </div>");
                ////    _html5.Append("   </div>");
                ////    _html5.Append("</div>");
                ////    _html5.Append("<div class=\"review-body\">");
                ////    _html5.Append("   <p>" + HttpUtility.HtmlDecode(post_view.listRating[j].contents) + "</p>");
                ////    _html5.Append("</div>");
                ////    _html5.Append("<hr>");
                ////}
                ////post_view.ltrRating = _html5.ToString();
                ////post_view.ratingSum = ratingModels.GetRatingSumforItem(obj.PostID);
                ////post_view.ratingTotal = ratingModels.GetRatingTotalforItem(obj.PostID);

                ////StringBuilder _html6 = new StringBuilder();
                ////var start_no = post_view.ratingTotal != 0 ? (post_view.ratingSum / post_view.ratingTotal) : 0;
                ////var other_no = 5 - start_no;
                ////for (int jj = 0; jj < other_no; jj++)
                ////{
                ////    _html6.Append("<span class=\"star\"></span>");
                ////}
                ////for (int ii = 0; ii < start_no; ii++)
                ////{
                ////    _html6.Append("<span class=\"star active\"></span>");
                ////}
                ////post_view.ratingStart = _html6.ToString();

                post_view.ListOther = postModels.GetOthers(obj.PostID, obj.CatelogID ?? 0, LanguageModels.ActiveLanguage().LangCultureName, int.Parse(Util.GetConfigValue("NumberOtherNews", "3")));

                CatalogModels catalogModel = new CatalogModels();
                C_Catalog     cateItem     = new C_Catalog();

                if (cate_id == 0)
                {
                    if (obj.CatelogID != null && obj.CatelogID != 0)
                    {
                        cate_id = obj.CatelogID;
                    }
                }

                cateItem = catalogModel.GetbyID((int)cate_id);

                post_view.PostID       = obj.PostID;
                post_view.PostName     = obj.PostName;
                post_view.Title        = obj.Title;
                post_view.Summary      = CommonGlobal.CutString(obj.Summary, 500);
                post_view.CatalogID    = obj.CatelogID;
                post_view.ImagePath    = obj.ImagePath;
                post_view.Link         = obj.Link;
                post_view.PostContent  = obj.PostContent;
                post_view.DateModified = obj.DateModified;
                post_view.IsHot        = obj.IsHot;
                post_view.Lang         = obj.Lang;
                post_view.Keyword      = obj.Keyword;
                post_view.Description  = obj.Description;
                post_view.OrderDisplay = obj.OrderDisplay;
                post_view.Approve      = obj.Approve;
                post_view.Cate_id      = cate_id ?? 0;
                post_view.Cate_type    = cate_type;
                post_view.Url          = url;
            }

            return(this.PartialView("../control/post_detail", post_view));
        }
コード例 #10
0
        public ActionResult List_album_images(int?parent, int?id, string type, string act, string ctrl, string type_act, string lang, string search, int?page, int?page_size, string order_by, string order_type)
        {
            CatalogModels         cateModels          = new CatalogModels();
            GalleryModels         galleryModels       = new GalleryModels();
            C_Catalog             cate                = new C_Catalog();
            ImageAlbum            img                 = new ImageAlbum();
            StringBuilder         sb                  = new StringBuilder();
            List <SelectListItem> list_select_catalog = new List <SelectListItem>();
            var list_album_images_view                = new Web.Areas.Admin.ViewModels.List_album_images_view();
            int total_record = 0;
            int level        = 0;

            /////type is get type catalog
            /////ex   : LB - Lookbook
            /////     : GL - Gallery
            /////parent is array parent id
            if (string.IsNullOrEmpty(type))
            {
                type = Request.QueryString["type"] != null ? Request.QueryString["type"].ToString() : CommonGlobal.CateLookBook;
            }

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

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

            if (page == null || page == 0)
            {
                page = Request.QueryString["page"] != null?Convert.ToInt32(Request.QueryString["page"].ToString()) : 1;
            }

            if (page_size == null)
            {
                page_size = int.Parse(Util.GetConfigValue("NumberPageSizeAdmin", "30"));
            }

            if (parent == null)
            {
                parent = Request.QueryString["parent"] != null?Convert.ToInt32(Request.QueryString["parent"].ToString()) : 0;
            }

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

            if (id != null && type_act != null && type_act == CommonGlobal.Delete)
            {
                ////check permission delete
                if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, act, ctrl, type_act, type))
                {
                    img = galleryModels.GetImageById((int)id);
                    if (img != null)
                    {
                        ////delete old image
                        if (!string.IsNullOrEmpty(img.Images))
                        {
                            string strImg = img.Images;
                            strImg = "~" + strImg;
                            string fileDelete = Server.MapPath(strImg);
                            if (System.IO.File.Exists(fileDelete))
                            {
                                System.IO.File.Delete(fileDelete);
                            }

                            string fileDelete2 = Server.MapPath(strImg.Replace("sc_small_", "sc_full_"));
                            if (System.IO.File.Exists(fileDelete2))
                            {
                                System.IO.File.Delete(fileDelete2);
                            }
                        }
                        ////delete imgage album
                        bool rt = galleryModels.Delete_Images((int)id);
                        if (rt)
                        {
                            list_album_images_view.Message = "Bạn đã xóa ảnh " + id;
                        }
                        else
                        {
                            list_album_images_view.Message = "Xóa không thành công";
                        }
                    }
                    else
                    {
                        list_album_images_view.Message = "Không tìm thấy ảnh : " + id;
                    }
                }
                else
                {
                    list_album_images_view.Message = " Bạn không có quyền thực thi hành động xóa.";
                }
            }

            if (string.IsNullOrEmpty(order_by) || string.IsNullOrEmpty(order_type))
            {
                order_by   = "ID";
                order_type = "asc";
            }

            if (parent != 0)
            {
                cate = cateModels.GetbyID((int)parent);
                list_album_images_view.Category_name = cate.CategoryName;
            }

            list_album_images_view.Type      = type;
            list_album_images_view.Cate_type = CommonGlobal.GetCatalogTypeName(type);
            list_album_images_view.Parent    = (int)parent;
            list_album_images_view.Lang      = lang;
            list_album_images_view.Type_act  = type_act;
            ////tab
            sb.Append("<li class=\"active\"><a class=\"active\" href=\"" + Url.Action("index", "dashboard", new { act = "list_catalog", ctrl = "adminCatalog", type = type, page = "1", parent = parent }) + "\"><span><span>Danh sách " + CommonGlobal.GetCatalogTypeName(type) + "</span></span></a></li>");
            list_album_images_view.Html_link_tab = sb.ToString();
            ////list language
            list_album_images_view.List_language = this.List_select_language(this.Lang);
            ////list category for filter
            cateModels.List_catalog_parent(0, level, (int)parent, type, lang, ref list_select_catalog);
            list_album_images_view.List_parent = list_select_catalog;
            ////list page size and paging
            list_album_images_view.List_page_size = this.GetSizePagingPublic((int)page_size);
            list_album_images_view.Page           = (int)page;
            list_album_images_view.Page_size      = (int)page_size;
            ////list product
            list_album_images_view.Page_list_image = galleryModels.AdminGetAllImageGallery((int)parent, type, lang, (int)page, (int)page_size, order_by, order_type, out total_record);
            list_album_images_view.Order_by        = order_by;
            list_album_images_view.Order_type      = order_type;
            list_album_images_view.Total_record    = total_record;
            ////acton and parent action
            list_album_images_view.Act               = act;
            list_album_images_view.Ctrl              = ctrl;
            list_album_images_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            list_album_images_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();

            return(this.PartialView("../control/list_album_images", list_album_images_view));
        }