public ActionResult Forgot_password(FormCollection collection) { OrderModels orderModels = new OrderModels(); WebInfoModels web_infor = new WebInfoModels(); UserModels sv = new UserModels(); C_User it = new C_User(); var login_view = new Login_view(); this.TryUpdateModel(login_view); login_view.Parent_action = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString(); login_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString(); login_view.Return_url = Url.Action("login", "dashboard", new { area = "admin" }); ////check user_name or email it = sv.GetUserbyUserName(login_view.User_name); if (it != null) { login_view.Message = App_GlobalResources.Lang.strMessageSendNewPassword; string code = GetCodeUniqueKey(8); ////orderModels.getOrderCodeUnique(); string link = Url.Action("change_password", "dashboard", new { cfcode = MD5Extend.EncodePassword(code + " " + login_view.User_name), area = "admin" }); //// send email to client var strBody_email_client = GeneralModels.GetContent(CommonGlobal.EmailConfirmForgotPassword, Lang).ToString(); ////get from email template strBody_email_client = strBody_email_client.Replace("{domain}", Util.GetConfigValue("Domain", Request.UserHostName).ToString()); strBody_email_client = strBody_email_client.Replace("{store_name}", GeneralModels.GetContent(CommonGlobal.PageName, Lang).ToString()); strBody_email_client = strBody_email_client.Replace("{email}", web_infor.GetContent(CommonGlobal.Email).ToString()); strBody_email_client = strBody_email_client.Replace("{email_client}", login_view.User_name); strBody_email_client = strBody_email_client.Replace("{code}", code); strBody_email_client = strBody_email_client.Replace("{link}", Util.GetConfigValue("Domain", Request.UserHostName).ToString() + link); ////send email to email system if (login_view.User_name == "Admin") { CommonGlobal.SendMail(web_infor.GetContent(CommonGlobal.Email), App_GlobalResources.Lang.strSubjectConfirmForgotPassword + "- " + Util.GetConfigValue("Domain", Request.UserHostName).ToString(), strBody_email_client); } else { CommonGlobal.SendMail(login_view.User_name, App_GlobalResources.Lang.strSubjectConfirmForgotPassword + "- " + Util.GetConfigValue("Domain", Request.UserHostName).ToString(), strBody_email_client); } } else { login_view.Message = App_GlobalResources.Lang.strMessageForgotPassword; } return(this.PartialView("../page/forgot_password", login_view)); }
public override void ChannelRead(IChannelHandlerContext context, object message) { try { MapleBuffer buffer = new MapleBuffer((byte[])message); if (buffer.Available < 2) { return; } System.Console.WriteLine("封包: {0}", buffer.ToString()); CMapleClient client = context.GetAttribute <CMapleClient>(CMapleClient.attributeKey).Get(); if (client != null) { short packetId = buffer.read <byte>(); CommonGlobal.Run(packetId, buffer, client); } } catch (Exception e) { System.Console.WriteLine("错误:" + e); } }
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_general(string type, string act, string ctrl, string type_act) { var general_content_view = new Web.Areas.Admin.ViewModels.General_content_view(); GeneralModels generalModels = new GeneralModels(); C_General general = new C_General(); 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() : "general_content"; } 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; } if (string.IsNullOrEmpty(this.Lang)) { this.Lang = LanguageModels.ActiveLanguage().LangCultureName; } try { general = generalModels.GetGeneral(type, this.Lang); general_content_view.Id = general.GeneralID; general_content_view.GeneralName = general.GeneralName; general_content_view.General_name_text = CommonGlobal.GetLinkADTypeName(type); general_content_view.GeneralContent = general.GeneralContent; general_content_view.Lang = general.Lang; general_content_view.Show = general.Show ?? false; if (general.Show == true) { general_content_view.Show = true; general_content_view.IsShow_text = "checked='checked'"; } else { general_content_view.Show = false; general_content_view.IsShow_text = string.Empty; } ////list language general_content_view.List_language = this.List_select_language(general.Lang); } catch (Exception) { general_content_view.Message = "Đã xảy ra lỗi trong quá trình lấy dữ liệu."; } general_content_view.Type = type; general_content_view.Type_act = type_act; ////Link tab StringBuilder sb = new StringBuilder(); sb.Append("<li class=\"active\"><a href=\"#\"><span>" + CommonGlobal.GetLinkADTypeName(type) + "</span></a></li>"); general_content_view.Html_link_tab = sb.ToString(); ////action general_content_view.Act = act; general_content_view.Ctrl = ctrl; general_content_view.Parent_action = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString(); general_content_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString(); ////end action return(this.PartialView("../control/change_general", general_content_view)); }
public ActionResult Change_general(FormCollection collection) { GeneralModels generalModels = new GeneralModels(); C_General general = new C_General(); var general_content_view = new Web.Areas.Admin.ViewModels.General_content_view(); this.TryUpdateModel(general_content_view); bool is_valid = true; ////action general_content_view.Parent_action = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString(); general_content_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString(); ////end action ////Link tab StringBuilder sb = new StringBuilder(); sb.Append("<li class=\"active\"><a href=\"#\"><span>" + CommonGlobal.GetLinkADTypeName(general_content_view.Type) + "</span></a></li>"); general_content_view.Html_link_tab = sb.ToString(); ////list language general_content_view.List_language = this.List_select_language(general_content_view.Lang); if (string.IsNullOrEmpty(general_content_view.GeneralContent)) { is_valid = false; general_content_view.Message = "Bạn cần nhập nội dung"; } if (!is_valid) { return(this.PartialView("../control/change_general", general_content_view)); } try { if (!string.IsNullOrEmpty(general_content_view.GeneralName)) { general = generalModels.GetGeneral(general_content_view.GeneralName, general_content_view.Lang); } general.Lang = general_content_view.Lang; general.GeneralContent = general_content_view.GeneralContent; general.Show = general_content_view.Show; if (general.Show == true) { general_content_view.Show = true; general_content_view.IsShow_text = "checked='checked'"; } else { general_content_view.Show = false; general_content_view.IsShow_text = string.Empty; } generalModels.Update(general); } catch (Exception) { general_content_view.Message = "Đã xảy ra lỗi cập nhật dữ liệu."; } general_content_view.Message = "Cập nhật thành công."; return(this.PartialView("../control/change_general", general_content_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)); }
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_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 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); }
public ActionResult List_link(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) { LinkModels linkModels = new LinkModels(); C_Link clink = new C_Link(); StringBuilder sb = new StringBuilder(); var list_link_view = new Web.Areas.Admin.ViewModels.List_link_view(); int total_record = 0; if (string.IsNullOrEmpty(type)) { type = Request.QueryString["type"] != null ? Request.QueryString["type"].ToString() : string.Empty; } if (type == string.Empty) { list_link_view.Message = "Chúng tôi không tìm thấy danh sách bạn yêu cầu"; } if (string.IsNullOrEmpty(act)) { act = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : "list_link"; } 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 (string.IsNullOrEmpty(lang)) { lang = LanguageModels.ActiveLanguage().LangCultureName; } if (page_size == null) { page_size = int.Parse(Util.GetConfigValue("NumberPageSizeAdmin", "30")); } 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)) { clink = linkModels.GetByID((int)id); if (clink != null) { ////delete old image if (!string.IsNullOrEmpty(clink.ImagePath)) { string strImg = clink.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 clink bool rt = linkModels.Delete((int)id); if (rt) { list_link_view.Message = "Bạn đã xóa " + id; } else { list_link_view.Message = "Xóa không thành công"; } } else { list_link_view.Message = "Không tìm thấy : " + id; } } else { list_link_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 = "OrderDisplay"; order_type = "asc"; } list_link_view.Type = type; list_link_view.Cate_type = CommonGlobal.GetLinkADTypeName(type); list_link_view.Lang = lang; list_link_view.Type_act = type_act; ////tab sb.Append("<li class=\"active\"><a class=\"active\" href=\"" + Url.Action("index", "dashboard", new { act = "list_link", ctrl = "adminLink", type_act = CommonGlobal.View, type = type, page = "1" }) + "\"><span><span>Danh sách " + CommonGlobal.GetLinkADTypeName(type) + "</span></span></a></li>"); sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "change_link", ctrl = "adminLink", type_act = CommonGlobal.Add, type = type }) + "\"><span><span>Thêm mới</span></span></a></li>"); list_link_view.Html_link_tab = sb.ToString(); ////list language list_link_view.List_language = this.List_select_language(this.Lang); ////list page size and paging list_link_view.List_page_size = this.GetSizePagingPublic((int)page_size); list_link_view.Page = (int)page; list_link_view.Page_size = (int)page_size; ////list catalog list_link_view.Page_list_link = linkModels.AdminGetAllLinkAd(type, lang, search, (int)page, (int)page_size, order_by, order_type, out total_record); list_link_view.Search = search; list_link_view.Order_by = order_by; list_link_view.Order_type = order_type; list_link_view.Total_record = total_record; ////acton and parent action list_link_view.Act = act; list_link_view.Ctrl = ctrl; list_link_view.Parent_action = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString(); list_link_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString(); return(this.PartialView("../control/list_link", list_link_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(int?id, string type, string act, string ctrl, string lang, string type_act) { LinkModels linkModels = new LinkModels(); C_Link clink = new C_Link(); StringBuilder sb = new StringBuilder(); var link_view = new Web.Areas.Admin.ViewModels.Link_view(); 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_link"; } if (string.IsNullOrEmpty(ctrl)) { ctrl = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : "adminLink"; } if (id == null) { id = RouteData.Values["id"] != null?Convert.ToInt32(RouteData.Values["id"].ToString()) : 0; } if (string.IsNullOrEmpty(type_act)) { type_act = Request.QueryString["type_act"] != null ? Request.QueryString["type_act"].ToString() : CommonGlobal.Add; if (id == 0) { type_act = CommonGlobal.Add; } else { type_act = CommonGlobal.Edit; } } if (type_act == CommonGlobal.Edit) { clink = linkModels.GetByID((int)id); sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "list_link", ctrl = "adminLink", type_act = CommonGlobal.Add, type = type, page = "1" }) + "\"><span><span>Danh sách " + CommonGlobal.GetLinkADTypeName(type) + "</span></span></a></li>"); sb.Append("<li class=\"active\"><a href=\"#\"><span><span>" + clink.Title + "</span></span></a></li>"); link_view.Lang = clink.Lang ?? lang; link_view.Id = clink.ID; link_view.Title = clink.Title; link_view.ImagePath = clink.ImagePath; link_view.LinkContent = clink.LinkContent; link_view.Link_url = clink.Link; link_view.Summary = clink.Summary; link_view.OrderDisplay = clink.OrderDisplay ?? 0; link_view.List_language = this.List_select_language(clink.Lang ?? this.Lang); } else { sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "list_link", ctrl = "adminLink", type_act = CommonGlobal.Add, type = type, page = "1" }) + "\"><span><span>Danh sách " + CommonGlobal.GetLinkADTypeName(type) + "</span></span></a></li>"); sb.Append("<li class=\"active\"><a href=\"#\"><span><span>Thêm mới</span></span></a></li>"); link_view.Lang = lang; link_view.List_language = this.List_select_language(this.Lang); link_view.OrderDisplay = linkModels.GetMaxOrderDisplay(type); } link_view.Html_link_tab = sb.ToString(); link_view.Type = type; link_view.Type_act = type_act; ////action and parent action link_view.Act = act; link_view.Ctrl = ctrl; link_view.Parent_action = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString(); link_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString(); return(this.PartialView("../control/change_link", link_view)); }
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)); }
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(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 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)); }
/// <summary> /// Orders the view. /// </summary> /// <param name="fcode">The order code.</param> /// <returns>Order view</returns> public ActionResult Order_view(string fcode) { if (!this.CheckMemberlogin()) { return(this.RedirectToAction("login", "account", new { return_url = string.Empty + Url.Action("order_view", "account", new { fcode = fcode }) })); } else { var order_view = new Order_register_view(); string strBread; ViewBag.Title = App_GlobalResources.Lang.strOrderCode + " " + fcode; strBread = string.Format("<li><a href=\"" + Url.Action("my_account", "account") + "\">" + App_GlobalResources.Lang.strPersonalInformation + "</a></li>"); strBread = string.Format("<li><a href=\"" + Url.Action("order_history", "account") + "\">" + App_GlobalResources.Lang.strOrderHistory + "</a></li>"); strBread += "<li>" + fcode + "</li>"; ViewBag.heading = App_GlobalResources.Lang.strOrderCode + " " + fcode; ViewBag.str_breadcrumbs = strBread; this.AddMeta(CommonGlobal.Keyword, App_GlobalResources.Lang.strOrderCode + " " + fcode); this.AddMeta(CommonGlobal.Description, App_GlobalResources.Lang.strOrderCode + " " + fcode); DetailOrderModels detailsv = new DetailOrderModels(); OrderModels orderModels = new OrderModels(); if (string.IsNullOrEmpty(fcode)) { return(this.HttpNotFound()); } C_User usr = new C_User(); order_view.Parent_action = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString(); order_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString(); order_view.ContentShipping = GeneralModels.GetContent(CommonGlobal.ContentShipping, this.Lang); UserModels sv = new UserModels(); usr = sv.GetUserbyUserName(Session["mem"].ToString()); var orders = orderModels.GetOrdersbyCode(fcode, usr.Username); if (orders == null) { order_view.Message = App_GlobalResources.Lang.messOrderNotFound; return(this.PartialView("../page/order_view", order_view)); } order_view.Message = string.Empty; order_view.Email = orders.Email; order_view.Name = orders.Name; order_view.Phone = orders.Phone; order_view.Address = orders.Address; order_view.Gender = orders.Gender; order_view.Sub_total = CommonGlobal.FormatMoney(orders.Total); order_view.Content = orders.Note; order_view.Order_code = fcode; order_view.Payment_status_text = CommonGlobal.GetPaymentStatusString(int.Parse(orders.Payment ?? "0")); order_view.Process_status_text = CommonGlobal.GetOrderStatusString(orders.Process ?? 0); var list_order_detail = detailsv.GetAllOrderDetail(fcode); if (list_order_detail.Count > 0) { order_view.ShoppingCart = new ArrayList(list_order_detail.ToArray()); } return(this.PartialView("../page/order_view", order_view)); } }
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)); }
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)); }
public ActionResult List_email(FormCollection collection, int?email_id, string type, string act, string ctrl, string type_act, int?page, int?page_size) { EmailModels emailModel = new EmailModels(); EmailTemplateModels emailTemplateModels = new EmailTemplateModels(); var list_email = new Web.Areas.Admin.ViewModels.List_email_view(); this.TryUpdateModel(list_email); List <SelectListItem> list_select_tempate = new List <SelectListItem>(); emailTemplateModels.List_email_template(0, ref list_select_tempate); StringBuilder sb = new StringBuilder(); int total_record = 0; if (string.IsNullOrEmpty(type)) { type = Request.QueryString["type"] != null ? Request.QueryString["type"].ToString() : CommonGlobal.RoleAdmin; } if (string.IsNullOrEmpty(act)) { act = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : "list_email"; } if (string.IsNullOrEmpty(ctrl)) { ctrl = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : "dminEmail"; } 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")); } string email_address = collection["email_address"].ToString(); if (email_id > 0 && type_act != null && type_act == CommonGlobal.Delete) { if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, act, ctrl, type_act, type)) { bool rt = emailModel.Delete((int)email_id); if (rt) { list_email.Message = "Bạn đã xóa email: " + email_address; } else { list_email.Message = "Xóa không thành công"; } } } int totalRecord = 0; if (!string.IsNullOrEmpty(collection["total_record_on_page"])) { totalRecord = int.Parse(collection["total_record_on_page"]); } string subject = collection["emailSubject"]; string body = collection["emailBody"]; bool flag_SendMail = false; if (list_email.IsSendAll) { list_email.IsSendAll = true; list_email.IsSendAllText = "checked='checked'"; List <C_Email> lstEmailSend = emailModel.AllEmail(); if (lstEmailSend.Any()) { foreach (C_Email objEmail in lstEmailSend) { CommonGlobal.SendMail(objEmail.email, subject, body); } flag_SendMail = true; } } else { list_email.IsSendAll = false; list_email.IsSendAllText = string.Empty; for (int i = 1; i <= totalRecord; ++i) { string email = string.Empty; string chkBox = collection["chk_" + i]; if (!string.IsNullOrEmpty(chkBox)) { if (chkBox.Contains("true")) { email = collection["email_" + i]; CommonGlobal.SendMail(email, subject, body); flag_SendMail = true; } } } } if (flag_SendMail) { ////Message list_email.Message = "Đã gửi mail thành công."; } //////tab sb.Append("<li class=\"active\"><a href=\"#\"><span>Email Marketing</span></a></li>"); list_email.Html_link_tab = sb.ToString(); //////list post PagedList <C_Email> lstEmail = emailModel.GetListEmail((int)page, (int)page_size, out total_record); list_email.ListEmail = lstEmail; list_email.Total_record = total_record; list_email.Total_record_on_page = lstEmail.Count(); list_email.Type_act = type_act; list_email.ListTemplate = list_select_tempate; //////action list_email.Act = act; list_email.Ctrl = ctrl; list_email.SubjectEmail = subject; list_email.BodyEmail = body; list_email.Parent_action = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString(); list_email.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString(); //////end action return(this.PartialView("../control/list_email", list_email)); }