public static PromotionList InitPromotionList(Product item) { CatalogsBusiness cataBussiness = new CatalogsBusiness(); Catalog cata = new Catalog(); string html = ""; int i = 1; long cataid; try { if (item.PromotionID != null) { return(item.PromotionList); } else { cataid = item.CatalogProducts.First().CatalogId; cata = cataBussiness.GetById(cataid); return(cata.PromotionList); } } catch (Exception ex) { return(null); } }
public JsonResult UpdateCatalog(Common.Catalog viewCatalog) { try { CatalogsBusiness catalogsBusiness = new CatalogsBusiness(); var dbCatalog = catalogsBusiness.GetById(viewCatalog.Id); dbCatalog.ParentId = viewCatalog.ParentId; dbCatalog.Code = viewCatalog.Code; dbCatalog.CatalogName = viewCatalog.CatalogName; dbCatalog.FriendlyUrl = viewCatalog.FriendlyUrl; dbCatalog.Icon = viewCatalog.Icon; dbCatalog.Description = viewCatalog.Description; dbCatalog.Order = viewCatalog.Order; dbCatalog.Status = viewCatalog.Status; dbCatalog.IsLast = viewCatalog.IsLast; dbCatalog.SeoTitle = viewCatalog.SeoTitle; dbCatalog.SeoKeyword = viewCatalog.SeoKeyword; dbCatalog.SeoDescription = viewCatalog.SeoDescription; catalogsBusiness.Edit(dbCatalog); return(Json(1));//Cập nhật thành công } catch (Exception) { throw; } }
public JsonResult GetProperty(long cateId) { try { var htm = ""; var property = _catalogPropertiesBusiness.GetDynamicQuery().Where(x => x.CatalogId == cateId); CatalogsBusiness catabusinness = new CatalogsBusiness(); string friendlyUrl = catabusinness.GetById(cateId).FriendlyUrl; foreach (var item in property) { htm += "<div class=\"panel panel-default tht_panel panlel_" + item.Id + "\">" + "<div class=\"panel-heading\">" + "<h3 class=\"panel-title\">" + " <input id=\"cataproname" + item.Id + "\" type=\"text\" value=\"" + item.Name + "\" />" + " <input id=\"cataprokey" + item.Id + "\" type=\"text\" value=\"" + item.Key + "\" />"; if (item.TypeDesign == 1) { if (item.Type == 1) { htm += "<label style=\"display:none;\"><input type=\"checkbox\" id =\"typeproperty" + item.Id + "\" checked value=\"" + item.Type + "\">Cho phép chọn nhiều? </label><input type=\"checkbox\" id =\"typedesignproperty" + item.Id + "\" checked value=\"" + item.TypeDesign + "\">Hiển thị 1 dòng </label><a class=\"del_1\" onclick=\"UpdateProperties(" + item.Id + ")\">Sửa</a><a class=\"del_1\" onclick=\"DeleteProperties(" + item.Id + ")\">Xóa</a></div>" + "<div class=\"panel-body\">"; } else { htm += "<label style=\"display:none;\"><input type=\"checkbox\" id =\"typeproperty" + item.Id + "\" value=\"" + item.Type + "\">Cho phép chọn nhiều? </label><input type=\"checkbox\" id =\"typedesignproperty" + item.Id + "\" checked value=\"" + item.TypeDesign + "\">Hiển thị 1 dòng </label><a class=\"del_1\" onclick=\"UpdateProperties(" + item.Id + ")\">Sửa</a><a class=\"del_1\" onclick=\"DeleteProperties(" + item.Id + ")\">Xóa</a></div>" + "<div class=\"panel-body\">"; } } else { if (item.Type == 1) { htm += "<label style=\"display:none;\"><input type=\"checkbox\" id =\"typeproperty" + item.Id + "\" checked value=\"" + item.Type + "\">Cho phép chọn nhiều? </label><input type=\"checkbox\" id =\"typedesignproperty" + item.Id + "\" value=\"" + item.TypeDesign + "\">Hiển thị 1 dòng </label><a class=\"del_1\" onclick=\"UpdateProperties(" + item.Id + ")\">Sửa</a><a class=\"del_1\" onclick=\"DeleteProperties(" + item.Id + ")\">Xóa</a></div>" + "<div class=\"panel-body\">"; } else { htm += "<label style=\"display:none;\"><input type=\"checkbox\" id =\"typeproperty" + item.Id + "\" value=\"" + item.Type + "\">Cho phép chọn nhiều? </label><input type=\"checkbox\" id =\"typedesignproperty" + item.Id + "\" value=\"" + item.TypeDesign + "\">Hiển thị 1 dòng </label><a class=\"del_1\" onclick=\"UpdateProperties(" + item.Id + ")\">Sửa</a><a class=\"del_1\" onclick=\"DeleteProperties(" + item.Id + ")\">Xóa</a></div>" + "<div class=\"panel-body\">"; } } foreach (var item2 in item.CatalogPropertiesValues) { htm += "<p id=\"properties_value_" + item2.Id + "\">+ <input id=\"properties_value_edit_" + item2.Id + "\" type=\"text\" value=\"" + item2.Value + "\" /><a class=\"update_2\" onclick=\"UpdatePropertiesValue(" + item2.Id + ")\">Sửa</a><a class=\"del_2\" onclick=\"DeletePropertiesValue(" + item2.Id + ")\">Xóa</a></p>"; } htm += " <div id=\"valueUpdate\"></div> <div style=\"float:right\"><a onclick=\"AddvalueFormUpdate(" + item.Id + ")\" class=\"btn btn-primary btn-sm\">Thêm giá trị</a></div></div></div>"; } return(Json(htm)); } catch (Exception) { //write log return(Json(0)); throw; } }
public static string HtmlBreadcrumb(long id, ref string html) { var catalogsBusiness = new CatalogsBusiness(); var obj = catalogsBusiness.GetById(id); html = "<li><a href=\"#\">" + obj.CatalogName + "</a></li>" + html; if (obj.ParentId != -1) { HtmlBreadcrumb(obj.ParentId, ref html); } return(html); }
public static List <long> GetIdPrentById(long id, ref List <long> listParent) { var catalogsBusiness = new CatalogsBusiness(); var obj = catalogsBusiness.GetById(id); if (obj != null) { if (obj.ParentId != -1) { listParent.Add(obj.ParentId); GetIdPrentById(obj.ParentId, ref listParent); } } return(listParent); }
public static String InitPromotion(Product item) { CatalogsBusiness cataBussiness = new CatalogsBusiness(); Catalog cata = new Catalog(); string html = ""; int i = 1; long cataid; try { if (item.PromotionID != null) { html = "<strong>" + item.PromotionList.Title + " </strong>"; foreach (PromotionItem pr in item.PromotionList.PromotionItem) { html += " <span class=\"promo\" data-id=\"0\">"; html += "<i class=\"numeric\">" + i + "</i>" + pr.Title; i++; html += "</span>"; } html += "<div style=\"margin: 8px; border-top: 1px dashed; padding-top: 5px;\">" + item.PromotionList.Description + "</div>"; } else { cataid = item.CatalogProducts.First().CatalogId; cata = cataBussiness.GetById(cataid); html = "<strong>" + cata.PromotionList.Title + " </strong>"; foreach (PromotionItem pr in cata.PromotionList.PromotionItem) { html += " <span class=\"promo\" data-id=\"0\">"; html += "<i class=\"numeric\">" + i + "</i>" + pr.Title; i++; html += "</span>"; } html += "<div style=\"margin: 8px; border-top: 1px dashed; padding-top: 5px;\">" + cata.PromotionList.Description + "</div>"; } } catch (Exception ex) { } return(html); }
public static void RegisterRoutes(RouteCollection routes) { try { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); FriendlyUrlBusiness a = new FriendlyUrlBusiness(); List <FriendlyUrl> listFriendly = new List <FriendlyUrl>(); listFriendly = a.searchAllLink(); // routes.Clear(); foreach (FriendlyUrl re in listFriendly) { routes.MapRoute(name: re.NameLink, url: re.Link, defaults: new { controller = re.ControllerName, action = re.ActionName, id = re.ItemId, }, namespaces: new string[] { re.NameSpaces }); } // routes.MapRoute(name: "them-lua-tinh-yeu", url: "danh-muc/them-lua-tinh-yeu-voi-nhung-mau-giuong-ngu-dep-mat.html", defaults: new { controller = "News", action = "Detail", nid = 26, }, namespaces: new string[] { "BuyGroup365.Controllers" }); // routes.MapRoute(name: "Catalog", url: "danh-muc/{friendUrl}.html", defaults: new { controller = "Home", action = "Category", friendUrl = UrlParameter.Optional, }); //routes.MapRoute(name: "Manufacturer", url: "{Content}-m{id}", defaults: new { controller = "Home", action = "Manufacturer", id = UrlParameter.Optional, slug = "" }); // routes.MapRoute(name: "ProductDetail", url: "{Content}-ct{id}.html", defaults: new { controller = "Home", action = "ProductDetail", id = UrlParameter.Optional, }); // routes.MapRoute(name: "GetProductByShop", url: "{Content}-mc{id}.html", defaults: new { controller = "Home", action = "GetProductByShop", id = UrlParameter.Optional, }); // routes.MapRoute(name: "NewsDetail", url: "help/{Content}-n{nid}.html", defaults: new { controller = "News", action = "Detail", nid = UrlParameter.Optional, }, // namespaces: new string[] { "BuyGroup365.Controllers" }); try { CatalogsBusiness cata = new CatalogsBusiness(); ManufacturersBusiness manu = new ManufacturersBusiness(); List <Catalog> ListCatalog = new List <Catalog>(); ListCatalog = cata.SearchCatalogALL(); // routes.Clear(); foreach (Catalog re in ListCatalog) { List <Manufacturer> ListManuFater = new List <Manufacturer>(); ListManuFater = manu.GetList(); foreach (Manufacturer mu in ListManuFater) { routes.MapRoute(name: re.CatalogName + re.Id + "hang" + mu.Id, url: re.FriendlyUrl + "-" + Common.util.Function.ConvertFileName(mu.ManufacturerName), defaults: new { controller = "Home", action = "Category", id = re.Id }); } } } catch { } routes.MapRoute(name: "Search", url: "search.html", defaults: new { controller = "Home", action = "Category", id = -2 }); // routes.MapRoute(name: "NewsGroup", url: "tin-tuc/{Content}-nt{nt}.html", defaults: new { controller = "News", action = "Index", nt = UrlParameter.Optional, }, // namespaces: new string[] { "BuyGroup365.Controllers" }); // routes.MapRoute(name: "NewsDetail2", url: "tin-tuc/{Content}-nid{nid}.html", defaults: new { controller = "News", action = "Detail", nid = UrlParameter.Optional, }, // namespaces: new string[] { "BuyGroup365.Controllers" }); //routes.MapRoute(name: "tags", url: "san-pham/{tag}.html", defaults: new { controller = "Home", action = "Tags", tag = UrlParameter.Optional, }, // namespaces: new string[] { "BuyGroup365.Controllers" }); //routes.MapRoute(name: "tagsnew", url: "tin-tuc-tag/{tag}.html", defaults: new { controller = "News", action = "Tags", tag = UrlParameter.Optional, }, // namespaces: new string[] { "BuyGroup365.Controllers" }); routes.MapRoute(name: "video", url: "videos.html", defaults: new { controller = "Videos", action = "index" }, namespaces: new string[] { "BuyGroup365.Controllers" }); routes.MapRoute(name: "download", url: "downloads.html", defaults: new { controller = "Downloads", action = "index" }, namespaces: new string[] { "BuyGroup365.Controllers" }); routes.MapRoute(name: "Contact", url: "lien-he.html", defaults: new { controller = "Home", action = "Contact" }); routes.MapRoute(name: "sitemap", url: "sitemap.xml", defaults: new { controller = "Home", action = "SitemapXml" }); routes.MapRoute(name: "sanphammoi", url: "san-pham-moi.html", defaults: new { controller = "Home", action = "sanphammoi" }); routes.MapRoute(name: "loi404", url: "loi404", defaults: new { controller = "Home", action = "loi404" }); routes.MapRoute(name: "giohang", url: "gio-hang", defaults: new { controller = "PayGoods", action = "CheckOut" }); //routes.MapRoute(name: "faqlist", url: "hoi-dap.html", defaults: new { controller = "News", action = "FAQ" }, namespaces: new string[] { "BuyGroup365.Controllers" }); //routes.MapRoute(name: "faqdetail", url: "chi-tiet-cau-hoi.html", defaults: new { controller = "News", action = "DetailFAQ", id = UrlParameter.Optional }, namespaces: new string[] { "BuyGroup365.Controllers" }); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }, namespaces: new string[] { "BuyGroup365.Controllers" } ); } catch { } }
public ActionResult CreateCate(string categoryname, HttpPostedFileBase icon, HttpPostedFileBase Banner, int statusCatg, int?PromotionListID, int parent, string seoTitle, string seoKeyword, string seoDescription, string description, string ShareTitle, string ShareKeyword, string ShareDescription, string ImageSource) { try { if (ModelState.IsValid) { CatalogsBusiness catalogsBusiness = new CatalogsBusiness(); string friendly = ""; Random rd = new Random(); Catalog obj = new Catalog(); // obj.FriendlyUrl = Function.ConvertFileName(categoryname); string friendlyCata = ""; if (parent != -1) { var dbCatalogSub = catalogsBusiness.GetById(parent); friendlyCata = dbCatalogSub.FriendlyUrl.Replace(".html", "") + "/"; } friendly = friendlyCata + Function.ConvertFileName(categoryname) + duoilink; obj.FriendlyUrl = friendly; obj.ParentId = parent; obj.Status = statusCatg; obj.CatalogName = categoryname; obj.Code = rd.Next(100000, 999999).ToString(); if (icon != null && icon.ContentLength > 0) { // TourInfo entity=new TourInfo(); //Random rdImage = new Random(); string randomImage = Guid.NewGuid().ToString(); //string fileNameImage = Common.util.Function.ConvertFileName(icon.FileName); string pathImage = HttpContext.Server.MapPath("~/FileUpload"); var strurlimage = Common.util.Function.ResizeImageNew(icon, 300, 300, pathImage, randomImage); Common.util.Function.ResizeImageNew(icon, 500, 500, pathImage, randomImage); Common.util.Function.ResizeImageNew(icon, 1000, 1000, pathImage, randomImage); // Common.util.Function.ReSizeImage(pathImage, fileNameImage, randomImage, 1000, 1000, icon); obj.Icon = strurlimage; } if (Banner != null && Banner.ContentLength > 0) { // TourInfo entity=new TourInfo(); //Random rdImage = new Random(); string randomImage = Guid.NewGuid().ToString(); //string fileNameImage = Common.util.Function.ConvertFileName(icon.FileName); string pathImage = HttpContext.Server.MapPath("~/FileUpload"); var strurlimage = Common.util.Function.ResizeImageNew(Banner, 1500, 1500, pathImage, randomImage); //Common.util.Function.ResizeImageNew(Banner, 500, 500, pathImage, randomImage); //Common.util.Function.ResizeImageNew(Banner, 1000, 1000, pathImage, randomImage); // Common.util.Function.ReSizeImage(pathImage, fileNameImage, randomImage, 1000, 1000, icon); obj.Banner = strurlimage; } if (ImageSource != "") { obj.ImageSource = ImageSource; } obj.SeoKeyword = seoKeyword; obj.SeoTitle = seoTitle; obj.SeoDescription = seoDescription; obj.ShareTitle = ShareTitle; obj.ShareKeyword = ShareKeyword; obj.ShareDescription = ShareDescription; obj.Description = description; //obj.PromotionID = PromotionListID; long Catalogid; _catalogsBusiness.AddNew(obj); Catalogid = obj.Id; try { Common.FriendlyUrl friendlyUrl = new Common.FriendlyUrl(); Random rnd = new Random(); int ngaunhien = rnd.Next(1, 100); friendlyUrl.ItemId = Catalogid; friendlyUrl.Link = friendly; friendlyUrl.ControllerName = "Home"; friendlyUrl.ActionName = "Category"; friendlyUrl.NameLink = friendly + ngaunhien.ToString(); friendlyUrl.NameSpaces = "BuyGroup365.Controllers"; friendlyUrl.Order = 0; _friendlyUrlBusines.InsertLink(friendlyUrl); RefreshFriendly.BindataSiteUrl(); } catch { } return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Tạo mới không thành công"); return(View()); } } catch (Exception ex) { //witrelog throw; } }
public ActionResult UpdateCatalog(Common.Catalog viewCatalog, long parent, long?PromotionListID, string FriendlyHD, HttpPostedFileBase Icon, HttpPostedFileBase Banner, string ImageSource) { try { string friendly = ""; CatalogsBusiness catalogsBusiness = new CatalogsBusiness(); var dbCatalog = catalogsBusiness.GetById(viewCatalog.Id); dbCatalog.ParentId = parent; dbCatalog.Code = viewCatalog.Code; dbCatalog.CatalogName = viewCatalog.CatalogName; string friendlyCata = ""; if (dbCatalog.ParentId != -1) { var dbCatalogSub = catalogsBusiness.GetById(dbCatalog.ParentId); friendlyCata = dbCatalogSub.FriendlyUrl.Replace(".html", "") + "/"; } friendly = friendlyCata + Function.ConvertFileName(viewCatalog.CatalogName) + duoilink; dbCatalog.FriendlyUrl = friendly; if (Icon != null && Icon.ContentLength > 0) { // TourInfo entity=new TourInfo(); //Random rdImage = new Random(); string randomImage = Guid.NewGuid().ToString(); //string fileNameImage = Common.util.Function.ConvertFileName(icon.FileName); string pathImage = HttpContext.Server.MapPath("~/FileUpload"); var strurlimage = Common.util.Function.ResizeImageNew(Icon, 300, 300, pathImage, randomImage); Common.util.Function.ResizeImageNew(Icon, 500, 500, pathImage, randomImage); Common.util.Function.ResizeImageNew(Icon, 1000, 1000, pathImage, randomImage); // Common.util.Function.ReSizeImage(pathImage, fileNameImage, randomImage, 1000, 1000, icon); dbCatalog.Icon = strurlimage; } if (Banner != null && Banner.ContentLength > 0) { // TourInfo entity=new TourInfo(); //Random rdImage = new Random(); string randomImage = Guid.NewGuid().ToString(); //string fileNameImage = Common.util.Function.ConvertFileName(icon.FileName); string pathImage = HttpContext.Server.MapPath("~/FileUpload"); var strurlimage = Common.util.Function.ResizeImageNew(Banner, 1500, 1500, pathImage, randomImage); //Common.util.Function.ResizeImageNew(Banner, 500, 500, pathImage, randomImage); //Common.util.Function.ResizeImageNew(Banner, 1000, 1000, pathImage, randomImage); // Common.util.Function.ReSizeImage(pathImage, fileNameImage, randomImage, 1000, 1000, icon); dbCatalog.Banner = strurlimage; } if (ImageSource != "") { dbCatalog.ImageSource = ImageSource; } dbCatalog.Description = viewCatalog.Description; dbCatalog.Order = viewCatalog.Order; dbCatalog.Status = viewCatalog.Status; //dbCatalog.PromotionID = PromotionListID; dbCatalog.IsLast = viewCatalog.IsLast; dbCatalog.SeoTitle = viewCatalog.SeoTitle; dbCatalog.SeoKeyword = viewCatalog.SeoKeyword; dbCatalog.SeoDescription = viewCatalog.SeoDescription; dbCatalog.ShareTitle = viewCatalog.ShareTitle; dbCatalog.ShareKeyword = viewCatalog.ShareKeyword; dbCatalog.ShareDescription = viewCatalog.ShareDescription; catalogsBusiness.Edit(dbCatalog); try { Common.FriendlyUrl friendlyUrl = new Common.FriendlyUrl(); Random rnd = new Random(); int ngaunhien = rnd.Next(1, 100); string linkcu = ""; if (FriendlyHD != friendly) { linkcu = FriendlyHD; } else { linkcu = ""; } friendlyUrl.ItemId = viewCatalog.Id; friendlyUrl.Link = friendly; friendlyUrl.ControllerName = "Home"; friendlyUrl.ActionName = "Category"; friendlyUrl.NameLink = friendly + ngaunhien; friendlyUrl.NameSpaces = "BuyGroup365.Controllers"; friendlyUrl.Order = 0; _friendlyUrlBusines.UpdateLink(linkcu, friendlyUrl); RefreshFriendly.BindataSiteUrl(); } catch { } return(RedirectToAction("Index")); } catch (Exception) { throw; } }