Пример #1
0
        public ActionResult Gallery_lookbook()
        {
            ///// Lấy danh sách gallery mới nhất
            CatalogModels cateModels = new CatalogModels();
            var           lstGallery = cateModels.GetMenubyParentID(0, CommonGlobal.CateLookBook, LanguageModels.ActiveLanguage().LangCultureName);

            return(this.PartialView("../control/gallery_lookbook", lstGallery));
        }
Пример #2
0
        public ActionResult Post_category_host(int?parent_id)
        {
            ///// Lấy danh sách collection mới nhất
            CatalogModels cateModels  = new CatalogModels();
            var           lstCategory = cateModels.GetbyParentID(0, CommonGlobal.CateService, LanguageModels.ActiveLanguage().LangCultureName, int.Parse(Util.GetConfigValue("NumberListCategory", "0")));

            return(this.PartialView("../control/post_category_host", lstCategory));
        }
Пример #3
0
        public ActionResult Index()
        {
            CatalogModels model = new CatalogModels();

            model.listOfCatalogs = this._catalog.GetAll();

            return(View(model));
        }
Пример #4
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"));
            }
        }
Пример #5
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));
        }
        /// <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));
        }
Пример #7
0
        public ActionResult Edit(CatalogModels model)
        {
            if (ModelState.IsValid)
            {
                Catalog catalog = _catalog.GetById(model.catalog.Id);

                try
                {
                    if (model.catalog != null)
                    {
                        catalog.Code        = model.catalog.Code;
                        catalog.Description = model.catalog.Description;
                        _catalog.Save();
                    }

                    if (model._SelectedProducts != null)
                    {
                        foreach (var sel in model._SelectedProducts)
                        {
                            ProductsCatalogs procals = _productscatalogs.GetAll().Where(c => c.Catalog.Id == model.catalog.Id).Where(c => c.Product.Id == sel.Id).FirstOrDefault();

                            if (sel.Checked == 0 && procals != null)
                            {
                                _productscatalogs.Delete(procals);
                                _productscatalogs.Save();
                            }
                            else if (sel.Checked == 1 && procals == null)
                            {
                                ProductsCatalogs procalen = new ProductsCatalogs();
                                Product          pro      = _product.GetById(sel.Id);
                                procalen.Product = pro;
                                procalen.Catalog = catalog;
                                _productscatalogs.Insert(procalen);
                                _productscatalogs.Save();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    //...
                }
            }

            return(RedirectToAction("Index"));
        }
Пример #8
0
        public ActionResult Create(CatalogModels model)
        {
            if (ModelState.IsValid)
            {
                Catalog catalog = new Catalog();

                try
                {
                    if (model.catalog != null)
                    {
                        catalog.Code        = model.catalog.Code;
                        catalog.Description = model.catalog.Description;
                        _catalog.Insert(catalog);
                        _catalog.Save();
                    }
                }
                catch (Exception ex)
                {
                    //...
                }
            }

            return(RedirectToAction("Index"));
        }
Пример #9
0
        public ActionResult Edit(int id)
        {
            CatalogModels model = new CatalogModels();

            model.catalog = _catalog.GetById(id);

            IEnumerable <Product> products = _product.GetAll();

            List <SelectedProducts> selProds = new List <SelectedProducts>();

            foreach (var pro in products)
            {
                SelectedProducts prods = new SelectedProducts();
                prods.Checked     = _productscatalogs.GetAll().Where(c => c.Catalog.Id == id).Where(c => c.Product.Id == pro.Id).Any()?1:0;
                prods.Id          = pro.Id;
                prods.Code        = pro.Code;
                prods.Description = pro.Description;
                selProds.Add(prods);
            }

            model._SelectedProducts = selProds;

            return(View(model));
        }
        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));
        }
        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));
        }
        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));
        }
Пример #13
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));
        }
Пример #14
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"));
            }
        }
Пример #15
0
        public ActionResult List_album_images(FormCollection collection)
        {
            CatalogModels         cateModels          = new CatalogModels();
            GalleryModels         galleryModels       = new GalleryModels();
            C_Catalog             cate                = new C_Catalog();
            ImageAlbum            imgPro              = 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();

            this.TryUpdateModel(list_album_images_view);
            int  total_record = 0;
            int  level        = 0;
            bool rt           = true;
            bool is_valid     = true;

            list_album_images_view.Cate_type = CommonGlobal.GetCatalogTypeName(list_album_images_view.Type);
            ////tab
            sb.Append("<li class=\"active\"><a class=\"active\" href=\"" + Url.Action("index", "dashboard", new { act = "list_catalog", ctrl = "adminCatalog", type = list_album_images_view.Type, page = "1", parent = list_album_images_view.Parent }) + "\"><span><span>Danh sách " + CommonGlobal.GetCatalogTypeName(list_album_images_view.Type) + "</span></span></a></li>");
            list_album_images_view.Html_link_tab = sb.ToString();
            ////list page size and paging
            list_album_images_view.List_page_size = this.GetSizePagingPublic(list_album_images_view.Page_size);
            ////acton and parent action
            list_album_images_view.Act               = "list_album_images";
            list_album_images_view.Ctrl              = "adminLink";
            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();
            ////delete image
            if (list_album_images_view.Id > 0 && list_album_images_view.Type_act == CommonGlobal.Delete)
            {
                ////check permission delete
                if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, list_album_images_view.Act, list_album_images_view.Ctrl, list_album_images_view.Type_act, list_album_images_view.Type))
                {
                    imgPro = galleryModels.GetImageById(list_album_images_view.Id);
                    if (imgPro != null)
                    {
                        ////delete old image
                        if (!string.IsNullOrEmpty(imgPro.Images))
                        {
                            string strImg = imgPro.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 image product
                        rt = galleryModels.Delete_Images(list_album_images_view.Id);

                        if (rt)
                        {
                            list_album_images_view.Message = "Bạn đã xóa ảnh " + list_album_images_view.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 : " + list_album_images_view.Id;
                    }
                }
                else
                {
                    list_album_images_view.Message = " Bạn không có quyền thực thi hành động xóa.";
                }
            }
            else
            {
                if (list_album_images_view.Type_act == CommonGlobal.Add)
                {
                    ////check permission add
                    if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, list_album_images_view.Act, list_album_images_view.Ctrl, list_album_images_view.Type_act, list_album_images_view.Type))
                    {
                        ////validation server
                        if (list_album_images_view.Album == 0)
                        {
                            is_valid = false;
                            list_album_images_view.Message = "Bạn cần lựa chọn album";
                        }

                        if (list_album_images_view.File_image == null)
                        {
                            is_valid = false;
                            list_album_images_view.Message = "Bạn cần chọn ảnh";
                        }

                        var max_length = 1024 * 1024 * 10; ////10MB
                        var length_all = 0;
                        foreach (HttpPostedFileBase fi in list_album_images_view.File_image)
                        {
                            if (fi != null)
                            {
                                length_all = length_all + fi.ContentLength;
                            }
                        }

                        if (length_all == 0)
                        {
                            is_valid = false;
                        }

                        if (length_all > max_length)
                        {
                            is_valid = false;
                            list_album_images_view.Message = "Bạn đã không thể đăng quá nhiều ảnh (Tổng dung lượng tối đa 10MB)";
                        }

                        if (is_valid)
                        {
                            ////upload multi images
                            foreach (HttpPostedFileBase fi in list_album_images_view.File_image)
                            {
                                if (fi != null && fi.ContentLength > 0 && CommonGlobal.IsImage(fi) == true)
                                {
                                    ////add new image
                                    var imgPathTemp = "images/photogallery/" +
                                                      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 + DateTime.Now.Second + DateTime.Now.Ticks + string.Empty;

                                    imgPro = new ImageAlbum();
                                    string image_small = imgPathTemp + "sc_small_" + name_time + "_" + CommonGlobal.CompleteNamefileImages(fi.FileName);
                                    string image_lager = imgPathTemp + "sc_full_" + name_time + "_" + CommonGlobal.CompleteNamefileImages(fi.FileName);
                                    //////save images for multi file
                                    this.Savephoto(null, fi, imgPathTemp, image_small, image_lager);

                                    imgPro.Images     = "/" + image_small;
                                    imgPro.ImagesFull = "/" + image_lager;
                                    imgPro.CatalogID  = list_album_images_view.Album;
                                    list_album_images_view.ImagePath = "/" + image_small;
                                    rt = galleryModels.Add_Images(imgPro);

                                    if (rt)
                                    {
                                        list_album_images_view.Message = "Bạn đã thêm ảnh thành công!";
                                    }
                                    else
                                    {
                                        if (list_album_images_view.Message != string.Empty)
                                        {
                                            list_album_images_view.Message = "updload ảnh không thành công: " + CommonGlobal.CompleteNamefileImages(fi.FileName);
                                        }
                                        else
                                        {
                                            list_album_images_view.Message += "; " + CommonGlobal.CompleteNamefileImages(fi.FileName);
                                        }
                                    }

                                    list_album_images_view.File_image = null;
                                }
                            }
                        }
                    }
                    else
                    {
                        list_album_images_view.Message = " Bạn không có quyền thực thi thêm ảnh cho album ";
                    }
                }
                else
                {
                    list_album_images_view.Message = string.Empty;
                }
            }

            ////list language
            list_album_images_view.List_language = this.List_select_language(list_album_images_view.Lang);
            ////list category
            cateModels.List_catalog_parent(0, level, list_album_images_view.Parent, list_album_images_view.Type, list_album_images_view.Lang, ref list_select_catalog);
            list_album_images_view.List_parent = list_select_catalog;
            ////get list product
            list_album_images_view.Page_list_image = galleryModels.AdminGetAllImageGallery(list_album_images_view.Parent, list_album_images_view.Type, list_album_images_view.Lang, list_album_images_view.Page, list_album_images_view.Page_size, list_album_images_view.Order_by, list_album_images_view.Order_type, out total_record);
            list_album_images_view.Total_record    = total_record;
            list_album_images_view.Order_by        = list_album_images_view.Order_by;
            list_album_images_view.Order_type      = list_album_images_view.Order_type;


            return(this.PartialView("../control/list_album_images", list_album_images_view));
        }
Пример #16
0
        public ActionResult List_post(int?parent, int?cate_id, int?post_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         cataModel           = new CatalogModels();
            PostModels            postModel           = new PostModels();
            C_Post                post                = new C_Post();
            List <SelectListItem> list_select_catalog = new List <SelectListItem>();
            var           list_post_view              = new Web.Areas.Admin.ViewModels.List_post_view();
            StringBuilder sb = new StringBuilder();

            int total_record = 0;
            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() : "list_post";
            }

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

            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"));
            }

            list_post_view.Page      = (int)page;
            list_post_view.Page_size = (int)page_size;

            list_post_view.Cate_type = CommonGlobal.GetCatalogTypeName(type);

            ////list category
            cataModel.List_catalog_parent(0, level, (int)parent, type, lang, ref list_select_catalog);
            list_post_view.List_parent = list_select_catalog;

            ////list language
            list_post_view.List_language = this.List_select_language(lang);

            ////tab
            sb.Append("<li class=\"active\"><a class=\"active\" href=\"" + Url.Action("index", "dashboard", new { act = "list_post", ctrl = "adminPost", type = type, page = "1", parent = parent, lang = lang }) + "\"><span><span>Danh mục " + CommonGlobal.GetCatalogTypeName(type) + "</span></span></a></li>");
            sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "change_post", ctrl = "adminPost", type = type, type_act = "add", parent = parent, lang = lang }) + "\"><span><span>Thêm bài viết</span></span></a></li>");
            list_post_view.Html_link_tab = sb.ToString();

            if (post_id != null && post_id != 0 && 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))
                {
                    post = postModel.GetbyID((int)post_id);
                    if (post != null)
                    {
                        ////delete old image
                        if (!string.IsNullOrEmpty(post.ImagePath))
                        {
                            string strImg = post.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 post
                        bool rt = postModel.Delete((int)post_id);
                        if (rt)
                        {
                            list_post_view.Message = "Bạn đã xóa bài viết: " + post_id;
                        }
                        else
                        {
                            list_post_view.Message = "Xóa không thành công";
                        }
                    }
                    else
                    {
                        list_post_view.Message = "Không tìm thấy bài viết : " + post_id;
                    }
                }
                else
                {
                    list_post_view.Message = " Bạn không có quyền thực thi hành động xóa.";
                }
            }

            ////list post
            list_post_view.List_page_size = this.GetSizePagingPublic((int)page_size);
            list_post_view.Page_list_post = postModel.GetListPostAll(lang, type, (int)parent, search, (int)page, (int)page_size, order_by, order_type, out total_record);
            list_post_view.Total_record   = total_record;
            list_post_view.Search         = search;
            list_post_view.Type_act       = type_act;
            list_post_view.Type           = type;
            ////action
            list_post_view.Act               = act;
            list_post_view.Ctrl              = ctrl;
            list_post_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            list_post_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();
            ////end action

            return(this.PartialView("../control/list_post", list_post_view));
        }
Пример #17
0
        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));
        }
Пример #18
0
        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));
        }
        public IActionResult Get(int?parent, string type, string lang, string search, int?pageIndex, int?pageSize, string orderBy, string orderType)
        {
            IActionResult         response          = null;
            CatalogModels         cateModels        = new CatalogModels();
            Catalog               cate              = new Catalog();
            StringBuilder         sb                = new StringBuilder();
            List <SelectListItem> listSelectCatalog = new List <SelectListItem>();
            BaseClass             baseClass         = new BaseClass();
            var listCatalogView = new AdminListCatalogView();
            var isOk            = true;

            /////type is get type catalog
            /////ex   : SP - product
            /////     : TT - news
            /////     : CL - collection
            /////     : LB - lookbook
            /////     : GL - gallery
            /////parent is parent id
            type = type ?? CommonGlobal.CateProduct;

            if (type == string.Empty)
            {
                isOk     = false;
                response = Json(new { code = Constant.NotExist, message = Constant.MessageNotExist });
            }

            if (!isOk)
            {
                return(response);
            }

            if (pageIndex == null || pageIndex == 0)
            {
                pageIndex = 1;
            }

            if (pageSize == null)
            {
                pageSize = 25;
            }

            parent = parent ?? 0;

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

            if (parent != 0)
            {
                // cate = cateModels.GetbyID((int)parent);
            }

            listCatalogView.PageListCatalog = cateModels.AdminGetAllCatalogFullTree(type, lang, search, (int)parent, (int)pageIndex, (int)pageSize, out int totalRecord);
            listCatalogView.CateType        = CommonGlobal.GetCatalogTypeName(type);
            listCatalogView.PageIndex       = (int)pageIndex;
            listCatalogView.PageSize        = (int)pageSize;
            listCatalogView.TotalPage       = totalRecord > 0 ? (int)System.Math.Ceiling((double)totalRecord / (double)pageSize) : 0;
            listCatalogView.TotalRecord     = totalRecord;

            response = Json(listCatalogView);

            return(response);
        }
Пример #20
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));
        }
Пример #21
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));
        }