public ActionResult Create(string id, string s, string p) { shSectionService _section = new shSectionService(); shProductService _product = new shProductService(); shProductSet section = new shProductSet(); if (!string.IsNullOrWhiteSpace(s)) { section = _section.FindByKey(s); ViewBag.parent = string.IsNullOrWhiteSpace(section.ParentId) ? 0 : 1; } section.ProductGuid = id; ViewBag.ProductName = _product.ProductName(id); ViewBag.ProductGuid = id; IEnumerable <shProductSet> dsSection = _section.DanhSachSection() .Where(x => x.ProductGuid == id && x.ParentId == null && x.SectionGuid != s) .OrderBy(x => x.SectionId); ViewBag.dsSection = new SelectList(dsSection, "SectionGuid", "SectionName", null); ViewBag.p = p; return(View(section)); }
public ActionResult DeleteSection(string SectionGuid, string ProductGuid) { shSectionService _section = new shSectionService(); shProductSet section = _section.FindByKey(SectionGuid); using (var context = new ShopOnlineDb()) { using (var dbContextTransaction = context.Database.BeginTransaction()) { try { if (section != null) { section.Status = false; _section.Update(section); } dbContextTransaction.Commit(); } catch (Exception ex) { dbContextTransaction.Rollback(); } } } if (Request.IsAjaxRequest()) { return(Json("OK", JsonRequestBehavior.AllowGet)); } return(RedirectToAction("Index")); }
public static MvcHtmlString SectionName(this HtmlHelper helper, string SectionGuid) { shSectionService _section = new shSectionService(); shProductSet section = _section.FindByKey(SectionGuid); if (section == null) { section = new shProductSet(); } return(new MvcHtmlString(section.SectionName)); }
public ActionResult Details(int?id) { shProductService _product = new shProductService(); shProduct product = _product.FindList().Where(x => x.ProductId == id).FirstOrDefault(); shProductImageService _productImage = new shProductImageService(); IEnumerable <shProductImage> dsImage = _productImage.DanhSachProductImage_ByProductGuid(product.ProductGuid); ViewBag.dsImageMauMa = dsImage.Where(x => x.ProductImageCategory == Config.ProductImageCategory_Design); ViewBag.dsImageChatLieu = dsImage.Where(x => x.ProductImageCategory == Config.ProductImageCategory_Material); shSectionService _section = new shSectionService(); IEnumerable <shProductSet> dsSection = _section.DanhSachSection_TheoProductGuid_ParentNull(product.ProductGuid); shProductSet section = new shProductSet(); if (dsSection != null && dsSection.Count() > 0) { section = dsSection.FirstOrDefault(); } shSizeService _size = new shSizeService(); IEnumerable <shSetSize> dsSize = _size.DanhSachSize_BySectionGuid(section.SectionGuid, product.ProductGuid, null); ViewBag.ProductSize = section.SectionName + " --- " + CommonHelper.TinhToanKichThuocMaxMin(dsSize.FirstOrDefault(), dsSize.LastOrDefault()); ViewBag.ProductPrice = CommonHelper.TinhToanGiaTienMaxMin(dsSize.FirstOrDefault(), dsSize.LastOrDefault()); // Tính toán số tiền sau khuyến mại string productSale = CommonHelper.TinhToanGiaTienSauKhiGiam(dsSize.FirstOrDefault(), dsSize.LastOrDefault()); if (!string.IsNullOrEmpty(productSale) && !string.IsNullOrWhiteSpace(productSale)) { ViewBag.ProductSale = Format.FormatDecimalToString(Convert.ToDecimal(productSale)); } ViewBag.ListSection = dsSection; return(View(product)); }
public static MvcHtmlString SectionName_SizeName(this HtmlHelper helper, string SectionGuid, string SizeGuid) { string html = string.Empty; shSectionService _section = new shSectionService(); shProductSet section = _section.FindByKey(SectionGuid); if (section != null) { html += section.SectionName; } shSizeService _size = new shSizeService(); shSetSize size = _size.FindByKey(SizeGuid); if (size != null) { html += " " + size.SizeName + " " + size.Stuff; } return(new MvcHtmlString(html)); }
public static MvcHtmlString ChatLieu_KichThuoc_TenSection(this HtmlHelper helper, string SizeGuid, string SizeName, string Stuff, string ParentId, string SectionGuid) { string html = string.Empty; shSectionService _section = new shSectionService(); shProductSet section = _section.FindByKey(SectionGuid); if (!string.IsNullOrWhiteSpace(SizeName)) { html += SizeName; } if (!string.IsNullOrWhiteSpace(Stuff)) { html += " - " + Stuff; } string title = string.Empty; string style = string.Empty; if (!string.IsNullOrWhiteSpace(ParentId)) { shSizeService _size = new shSizeService(); shSetSize size = _size.FindByKey(ParentId); if (size != null) { title = section.SectionName + " [" + size.SizeName + "]"; } style = "font-weight:bold;"; } else { style = "font-weight:bold; cursor: pointer"; } string span = "<span title='" + title + "' class=''>" + section.SectionName + " - " + "<span class='parent-size' style='" + style + "' >" + html + "</span>" + "</span>"; return(new MvcHtmlString(span)); }
public ActionResult Create(string ProductGuid, string SectionGuid, string SectionName, string ProductName, int?SortOrder, string ParentId, string parent) { if (parent == "0") { ParentId = null; } using (var context = new ShopOnlineDb()) { using (var dbContextTransaction = context.Database.BeginTransaction()) { try { shSectionService _section = new shSectionService(); shProductSet section = _section.Insert_UpdateSection( SectionGuid, null, ProductGuid, SectionName, SortOrder, null, true, DateTime.Now, ParentId); dbContextTransaction.Commit(); } catch (Exception ex) { dbContextTransaction.Rollback(); } } } return(RedirectToAction("Index", new { id = ProductGuid })); }