Esempio n. 1
0
        public ActionResult Change_showroom(FormCollection collection, HttpPostedFileBase file_image)
        {
            ShowroomModels showroomModels = new ShowroomModels();
            CityModels     cityModels     = new CityModels();
            DistrictModels districtModels = new DistrictModels();
            Showroom       objShowroom    = new Showroom();
            StringBuilder  sb             = new StringBuilder();
            int            rt             = 0;
            bool           is_valid       = true;
            var            showroom_view  = new Web.Areas.Admin.ViewModels.Showroom_view();

            this.TryUpdateModel(showroom_view);

            if (showroom_view.ShowroomID > 0)
            {
                objShowroom = showroomModels.GetShowroomById(showroom_view.ShowroomID);
            }

            ////validation server
            if (string.IsNullOrEmpty(showroom_view.Name))
            {
                is_valid = false;
                showroom_view.Message = "Bạn cần nhập tên Showroom";
            }

            ////validation server
            if (showroom_view.District == 0)
            {
                is_valid = false;
                showroom_view.Message = "Bạn cần lựa chọn Quận/Huyện";
            }

            ////action
            ////post_view.act = "change_post";
            ////post_view.ctrl = "adminPost";
            showroom_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            showroom_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();

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

            ////Post info
            objShowroom.DistrictID = showroom_view.District;
            objShowroom.Name       = showroom_view.Name;
            objShowroom.Address    = showroom_view.Address;
            objShowroom.Phone      = showroom_view.Phone;
            objShowroom.Latitude   = showroom_view.Latitude;
            objShowroom.Longitude  = showroom_view.Longitude;

            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(objShowroom.Image, file_image, imgPathTemp, image_small, image_lager);

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

            if (showroom_view.ShowroomID != 0 && showroom_view.Type_act == CommonGlobal.Edit)
            {
                rt = showroomModels.Edit(objShowroom);
            }
            else
            {
                objShowroom.CreateDate = DateTime.Now;
                rt = showroomModels.Add(objShowroom);
            }

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

                ////list parent
                District objDistrict = districtModels.GetDistrictByID(showroom_view.District);
                ////City and District
                showroom_view.List_city     = cityModels.List_city(objDistrict.CityID);
                showroom_view.List_district = districtModels.List_district(objDistrict.CityID, showroom_view.District);
            }
            else
            {
                ////Link tab
                sb.Append("<li><a class=\"active\" href=\"" + Url.Action("index", "dashboard", new { act = "list_showroom", ctrl = "adminShowroom", type = showroom_view.Type, page = "1" }) + "\"><span><span>Danh sách Showroom</span></span></a></li>");
                sb.Append("<li class=\"active\"><a href=\"#\"><span><span>Thêm mới</span></span></a></li>");

                ////City and District
                showroom_view.List_city     = cityModels.List_city(showroom_view.City);
                showroom_view.List_district = districtModels.List_district(showroom_view.City, showroom_view.District);
            }

            showroom_view.Html_link_tab = sb.ToString();

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

            return(this.PartialView("../control/change_showroom", showroom_view));
        }
        public ActionResult Change_static(FormCollection collection)
        {
            PageModels    pageModels = new PageModels();
            C_Pages       cpage      = new C_Pages();
            StringBuilder sb         = new StringBuilder();
            var           page_view  = new Web.Areas.Admin.ViewModels.Page_view();

            this.TryUpdateModel(page_view);
            int  rt       = 0;
            bool is_valid = true;

            if (page_view.Id > 0)
            {
                cpage = pageModels.GetbyID(page_view.Id);
            }

            ////validation server
            if (string.IsNullOrEmpty(page_view.PageName))
            {
                is_valid = false;
                if (page_view.Message != string.Empty)
                {
                    page_view.Message = "Bạn cần nhập Tên trang";
                }
            }

            if (string.IsNullOrEmpty(page_view.PageContent))
            {
                is_valid = false;
                if (page_view.Message != string.Empty)
                {
                    page_view.Message = "Bạn cần nhập nội dung trang tĩnh";
                }
            }

            ////Link tab
            sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "list_page_static", ctrl = "adminStatic", page = "1" }) + "\"><span><span>Danh sách trang tĩnh</span></span></a></li>");
            if (page_view.Id != 0 && page_view.Type_act == CommonGlobal.Edit)
            {
                sb.Append("<li class=\"active\"><a href=\"#\"><span><span>" + cpage.PageName + "</span></span></a></li>");
                page_view.List_language = this.List_select_language(cpage.Lang);
                page_view.Id            = cpage.PageID;
            }
            else
            {
                sb.Append("<li class=\"active\"><a href=\"#\"><span><span>Thêm trang tĩnh</span></span></a></li>");
                page_view.List_language = this.List_select_language(page_view.Lang);
            }

            page_view.Html_link_tab = sb.ToString();
            ////action
            page_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            page_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();
            if (!is_valid)
            {
                return(this.PartialView("../control/change_static", page_view));
            }

            cpage.Summary     = string.IsNullOrEmpty(page_view.Summary) == false ? page_view.Summary : string.Empty;
            cpage.PageContent = string.IsNullOrEmpty(page_view.PageContent) == false ? page_view.PageContent : string.Empty;
            cpage.Lang        = page_view.Lang;
            cpage.PageName    = page_view.PageName;
            if (string.IsNullOrEmpty(page_view.Title))
            {
                cpage.Title = page_view.PageName;
            }
            else
            {
                cpage.Title = page_view.Title;
            }

            cpage.Keyword     = string.IsNullOrEmpty(page_view.Keyword) == false ? page_view.Keyword : string.Empty;
            cpage.Description = string.IsNullOrEmpty(page_view.Description) == false ? page_view.Description : string.Empty;
            cpage.Show        = page_view.Show;
            if ((cpage.Show ?? false) == true)
            {
                page_view.Show      = true;
                page_view.Show_text = "checked='checked'";
            }
            else
            {
                page_view.Show      = false;
                page_view.Show_text = string.Empty;
            }

            cpage.Link         = CommonGlobal.CompleteLink(page_view.PageName);
            cpage.DateModified = DateTime.Now;

            var imgPathTemp = "images/static/" +
                              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 (page_view.File_image != null && page_view.File_image.ContentLength > 0 && CommonGlobal.IsImage(page_view.File_image) == true)
            {
                string image_small = imgPathTemp + "sc_small_" + name_time + "_" + CommonGlobal.CompleteNamefileImages(page_view.File_image.FileName);
                string image_lager = imgPathTemp + "sc_full_" + name_time + "_" + CommonGlobal.CompleteNamefileImages(page_view.File_image.FileName);
                ////save image and delete old file
                this.Savephoto(cpage.ImagePath, page_view.File_image, imgPathTemp, image_small, image_lager);
                ////set image thumb to link catalog
                cpage.ImagePath     = "/" + image_small;
                page_view.ImagePath = "/" + image_small;
            }
            else if (string.IsNullOrEmpty(cpage.ImagePath))
            {
                cpage.ImagePath = "0";
            }
            else
            {
                cpage.ImagePath = page_view.ImagePath;
            }

            cpage.OrderDisplay = page_view.OrderDisplay;

            if (page_view.Id != 0 && page_view.Type_act == CommonGlobal.Edit)
            {
                rt = pageModels.Edit(cpage);
            }
            else
            {
                rt = pageModels.Add(cpage);
            }

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

            return(this.PartialView("../control/change_static", page_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));
        }
        public ActionResult System_config(FormCollection collection, string lang, string act, string ctrl, string type_act, string type, HttpPostedFileBase file_img)
        {
            var           system_config_view = new Web.Areas.Admin.ViewModels.System_config_view();
            GeneralModels generalModel       = new GeneralModels();
            WebInfoModels webInfoModels      = new WebInfoModels();

            this.TryUpdateModel(system_config_view);

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

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

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

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

            system_config_view.Type_act = type_act;

            ////Update data
            if (system_config_view.Is_update > 0 && system_config_view.Type_act == CommonGlobal.Edit)
            {
                ////Pagename
                C_General pagename = new C_General();
                pagename.GeneralName    = CommonGlobal.PageName;
                pagename.GeneralContent = system_config_view.Page_name;
                pagename.Show           = true;
                pagename.Lang           = system_config_view.Lang;
                pagename.Datemodified   = DateTime.Now;
                generalModel.Update(pagename);

                ////Keyword
                C_General keyword = new C_General();
                keyword.GeneralName    = CommonGlobal.Keyword;
                keyword.GeneralContent = system_config_view.Keywords;
                keyword.Show           = true;
                keyword.Lang           = system_config_view.Lang;
                keyword.Datemodified   = DateTime.Now;
                generalModel.Update(keyword);

                ////Description
                C_General description = new C_General();
                description.GeneralName    = CommonGlobal.Description;
                description.GeneralContent = system_config_view.Description;
                description.Show           = true;
                description.Lang           = system_config_view.Lang;
                description.Datemodified   = DateTime.Now;
                generalModel.Update(description);

                ////Support
                C_General support = new C_General();
                support.GeneralName    = CommonGlobal.Support;
                support.GeneralContent = system_config_view.Support;
                support.Show           = true;
                support.Lang           = system_config_view.Lang;
                support.Datemodified   = DateTime.Now;
                generalModel.Update(support);

                ////Address
                C_General address = new C_General();
                address.GeneralName    = CommonGlobal.Address;
                address.GeneralContent = system_config_view.Address;
                address.Show           = true;
                address.Lang           = system_config_view.Lang;
                address.Datemodified   = DateTime.Now;
                generalModel.Update(address);

                ////Hotline
                C_WebInfo hotline = new C_WebInfo();
                hotline.GeneralName    = CommonGlobal.Hotline;
                hotline.GeneralContent = system_config_view.Hotline;
                hotline.Datemodified   = DateTime.Now;
                webInfoModels.Update(hotline);

                ////Skyper
                C_WebInfo skyper = new C_WebInfo();
                skyper.GeneralName    = CommonGlobal.Skyper;
                skyper.GeneralContent = system_config_view.Skype;
                skyper.Datemodified   = DateTime.Now;
                webInfoModels.Update(skyper);

                ////Slogan
                C_General slogan = new C_General();
                slogan.GeneralName    = CommonGlobal.Slogan;
                slogan.GeneralContent = system_config_view.Slogan;
                slogan.Show           = true;
                slogan.Datemodified   = DateTime.Now;
                slogan.Lang           = system_config_view.Lang;
                generalModel.Update(slogan);

                ////facebook
                C_WebInfo facebook = new C_WebInfo();
                facebook.GeneralName    = CommonGlobal.Facebook;
                facebook.GeneralContent = system_config_view.Facebook;
                facebook.Datemodified   = DateTime.Now;
                webInfoModels.Update(facebook);

                ////Fees
                C_WebInfo fees = new C_WebInfo();
                fees.GeneralName    = CommonGlobal.Fees;
                fees.GeneralContent = system_config_view.Fees;
                fees.Datemodified   = DateTime.Now;
                webInfoModels.Update(fees);

                ////Fees
                C_WebInfo min_fees = new C_WebInfo();
                min_fees.GeneralName    = CommonGlobal.MinFees;
                min_fees.GeneralContent = system_config_view.Min_fees;
                min_fees.Datemodified   = DateTime.Now;
                webInfoModels.Update(min_fees);

                ////Fees
                C_WebInfo tax = new C_WebInfo();
                tax.GeneralName    = CommonGlobal.Tax;
                tax.GeneralContent = system_config_view.Tax;
                tax.Datemodified   = DateTime.Now;
                webInfoModels.Update(tax);

                ////google_analysis
                C_WebInfo google_analysis = new C_WebInfo();
                google_analysis.GeneralName    = CommonGlobal.GoogleAnalysis;
                google_analysis.GeneralContent = system_config_view.Google_analysis;
                google_analysis.Datemodified   = DateTime.Now;
                webInfoModels.Update(google_analysis);

                ////app_extend_one
                C_WebInfo app_extend_one = new C_WebInfo();
                app_extend_one.GeneralName    = CommonGlobal.AppExtendOne;
                app_extend_one.GeneralContent = system_config_view.App_extend_one;
                app_extend_one.Datemodified   = DateTime.Now;
                webInfoModels.Update(app_extend_one);

                ////app_extend_two
                C_WebInfo app_extend_two = new C_WebInfo();
                app_extend_two.GeneralName    = CommonGlobal.AppExtendTwo;
                app_extend_two.GeneralContent = system_config_view.App_extend_two;
                app_extend_two.Datemodified   = DateTime.Now;
                webInfoModels.Update(app_extend_two);

                ////latitude
                C_WebInfo latitude = new C_WebInfo();
                latitude.GeneralName    = CommonGlobal.Latitude;
                latitude.GeneralContent = system_config_view.Latitude;
                latitude.Datemodified   = DateTime.Now;
                webInfoModels.Update(latitude);

                ////latitude
                C_WebInfo longitude = new C_WebInfo();
                longitude.GeneralName    = CommonGlobal.Longitude;
                longitude.GeneralContent = system_config_view.Longitude;
                longitude.Datemodified   = DateTime.Now;
                webInfoModels.Update(longitude);

                ////image
                C_WebInfo imgmap = new C_WebInfo();
                imgmap.GeneralName = CommonGlobal.ImageMap;
                //// imgmap. = system_config_view.imgmap;
                imgmap.Datemodified = DateTime.Now;

                var imgPathTemp = "images/icon/"; ////+ 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_img != null && file_img.ContentLength > 0 && CommonGlobal.IsImage(file_img) == true)
                {
                    string image_name = imgPathTemp + "sc_original_" + name_time + "_" + CommonGlobal.CompleteNamefileImages(file_img.FileName);

                    ////save image and delete old file
                    this.SavephotoOriginal(imgmap.GeneralContent, file_img, imgPathTemp, image_name);

                    ////set image thumb to link catalog
                    imgmap.GeneralContent        = "/" + image_name;
                    system_config_view.Image_map = "/" + image_name;
                }
                else if (string.IsNullOrEmpty(imgmap.GeneralContent))
                {
                    imgmap.GeneralContent = "0";
                }
                else
                {
                    imgmap.GeneralContent = system_config_view.Image_map;
                }

                webInfoModels.Update(imgmap);

                system_config_view.Message = "Cập nhật thành công.";
            }

            ////list language
            system_config_view.List_language = this.List_select_language(lang);
            try
            {
                ////General
                system_config_view.Page_name   = GeneralModels.GetContent(CommonGlobal.PageName, lang);
                system_config_view.Keywords    = GeneralModels.GetContent(CommonGlobal.Keyword, lang);
                system_config_view.Description = GeneralModels.GetContent(CommonGlobal.Description, lang);
                system_config_view.Support     = GeneralModels.GetContent(CommonGlobal.Support, lang);
                system_config_view.Address     = GeneralModels.GetContent(CommonGlobal.Address, lang);
                system_config_view.Slogan      = GeneralModels.GetContent(CommonGlobal.Slogan, lang);
                ////webinfo
                system_config_view.Hotline         = webInfoModels.GetContent(CommonGlobal.Hotline);
                system_config_view.Facebook        = webInfoModels.GetContent(CommonGlobal.Facebook);
                system_config_view.Skype           = webInfoModels.GetContent(CommonGlobal.Skyper);
                system_config_view.Fees            = webInfoModels.GetContent(CommonGlobal.Fees);
                system_config_view.Min_fees        = webInfoModels.GetContent(CommonGlobal.MinFees);
                system_config_view.Tax             = webInfoModels.GetContent(CommonGlobal.Tax);
                system_config_view.Google_analysis = webInfoModels.GetContent(CommonGlobal.GoogleAnalysis);
                system_config_view.App_extend_one  = webInfoModels.GetContent(CommonGlobal.AppExtendOne);
                system_config_view.App_extend_two  = webInfoModels.GetContent(CommonGlobal.AppExtendTwo);
                system_config_view.Latitude        = webInfoModels.GetContent(CommonGlobal.Latitude);
                system_config_view.Longitude       = webInfoModels.GetContent(CommonGlobal.Longitude);
                system_config_view.Image_map       = webInfoModels.GetContent(CommonGlobal.ImageMap);
            }
            catch (Exception)
            {
                system_config_view.Message = "Đã xảy ra lỗi trong quá trình lấy dữ liệu.";
            }

            ////Link tab
            StringBuilder sb = new StringBuilder();

            sb.Append("<li class=\"active\"><a href=\"#\"><span>Cấu hình chung</span></a></li>");
            sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "system_email", ctrl = "adminGeneral", type_act = CommonGlobal.Edit }) + "\"><span>Cấu hình email</span></a></li>");
            sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "footer", ctrl = "adminGeneral", type_act = CommonGlobal.Edit }) + "\"><span>Footer</span></a></li>");

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

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

            this.TryUpdateModel(post_view);

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

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

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

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

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

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

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

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

            post_view.Html_link_tab = sb.ToString();

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

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

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

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

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

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

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

            objPost.Approve = post_view.Approve;

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

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

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

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

            return(this.PartialView("../control/change_post", post_view));
        }
        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));
        }
        public ActionResult Change_link(FormCollection collection)
        {
            LinkModels    linkModels = new LinkModels();
            C_Link        clink      = new C_Link();
            StringBuilder sb         = new StringBuilder();
            var           link_view  = new Web.Areas.Admin.ViewModels.Link_view();

            this.TryUpdateModel(link_view);
            int  rt       = 0;
            bool is_valid = true;

            if (link_view.Id > 0)
            {
                clink = linkModels.GetByID(link_view.Id);
            }

            ////validation server
            if (string.IsNullOrEmpty(link_view.Title))
            {
                is_valid          = false;
                link_view.Message = "Bạn cần nhập tiêu đề";
            }

            ////action
            link_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            link_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();
            ////Link tab
            var link_dashboard = Url.Action("index", "dashboard", new { act = "list_link", ctrl = "adminLink", type_act = CommonGlobal.Add, type = link_view.Type, page = "1" });

            sb.Append("<li><a href=\"" + link_dashboard + "\"><span><span>Danh sách " + CommonGlobal.GetLinkADTypeName(link_view.Type) + "</span></span></a></li>");
            if (link_view.Id != 0 && link_view.Type_act == CommonGlobal.Edit)
            {
                sb.Append("<li class=\"active\"><a href=\"#\"><span><span>" + clink.Title + "</span></span></a></li>");
                link_view.List_language = this.List_select_language(clink.Lang);
            }
            else
            {
                sb.Append("<li class=\"active\"><a href=\"#\"><span><span>Thêm mới</span></span></a></li>");
                link_view.List_language = this.List_select_language(link_view.Lang);
            }

            link_view.Html_link_tab = sb.ToString();
            if (!is_valid)
            {
                return(this.PartialView("../control/change_link", link_view));
            }

            clink.Title       = link_view.Title;
            clink.Summary     = string.IsNullOrEmpty(link_view.Summary) == false ? link_view.Summary : string.Empty;
            clink.LinkContent = string.IsNullOrEmpty(link_view.LinkContent) == false ? link_view.LinkContent : string.Empty;
            clink.Link        = string.IsNullOrEmpty(link_view.Link_url) == false ? link_view.Link_url : string.Empty;
            clink.Lang        = link_view.Lang;
            clink.Type        = link_view.Type;

            var imgPathTemp = "images/link/" + 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 (link_view.File_image != null && link_view.File_image.ContentLength > 0 && CommonGlobal.IsImageOrVideo(link_view.File_image) == true)
            {
                string image_name = imgPathTemp + "sc_original_" + name_time + "_" + CommonGlobal.CompleteNamefileImages(link_view.File_image.FileName);

                ////save image and delete old file
                this.SavephotoOriginal(clink.ImagePath, link_view.File_image, imgPathTemp, image_name);

                ////set image thumb to link catalog
                clink.ImagePath     = "/" + image_name;
                link_view.ImagePath = "/" + image_name;
            }
            else if (string.IsNullOrEmpty(clink.ImagePath))
            {
                clink.ImagePath = "0";
            }
            else
            {
                clink.ImagePath = link_view.ImagePath;
            }

            clink.OrderDisplay = link_view.OrderDisplay;

            if (link_view.Id != 0 && link_view.Type_act == CommonGlobal.Edit)
            {
                rt = linkModels.Update(clink);
            }
            else
            {
                rt = linkModels.Add(clink);
            }

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

            // return this.PartialView("../control/change_link", link_view);

            string return_url = Url.Action("index", "dashboard", new { act = "list_link", ctrl = "adminLink", type = link_view.Type, type_act = Web.Models.CommonGlobal.Edit, page = 1, parent = 0 });

            return(this.PartialView("../control/redirect", return_url));
        }