public ActionResult ModifyProductCate() { if (!AppData.IsManagerLogin) { return(Json(new { success = false, msg = "您未登录后台或会话已过期" })); } if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 302)) { return(Json(new { success = false, msg = "您没有执行该操作的权限" })); } Validation validation = new Validation(); int categoryID = validation.GetInt("categoryID"); ProductBLL productBLL = new ProductBLL(); ProductCateObj productCateObj = productBLL.GetProductCateByCateID(categoryID); if (productCateObj != null) { productCateObj.CategoryName = validation.Get("categoryName", false, "新闻分类名称不可为空!"); productCateObj.Sort = validation.GetInt("sort"); if (validation.HasError) { return(Json(new { success = false, msg = "ValidationFailed", errors = validation.GetErrors() })); } productBLL.ModifyProductCate(productCateObj); return(Json(new { success = true })); } else { return(Json(new { success = false, msg = "该类别不存在!" })); } }
public ActionResult AddProductCate() { if (!AppData.IsManagerLogin) { return(Json(new { success = false, msg = "您未登录后台或会话已过期" })); } if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 301)) { return(Json(new { success = false, msg = "您没有执行该操作的权限" })); } Validation validation = new Validation(); ProductCateObj productCateObj = new ProductCateObj(); productCateObj.CategoryName = validation.Get("categoryName", false, "新闻分类名称不可为空!"); productCateObj.ParentID = validation.GetInt("categoryID"); productCateObj.Sort = validation.GetInt("sort"); if (validation.HasError) { return(Json(new { success = false, msg = "ValidationFailed", errors = validation.GetErrors() })); } ProductBLL productBLL = new ProductBLL(); productBLL.AddProductCate(productCateObj); return(Json(new { success = true })); }
public void ModifyProductCate(ProductCateObj productCateObj) { dal.ModifyProductCate(productCateObj); }
public void AddProductCate(ProductCateObj productCateObj) { dal.AddProductCate(productCateObj); }
public ActionResult Cates(string id) { int cateID; int startPage; if (id.IndexOf('_') == -1) { cateID = int.Parse(id); startPage = 1; } else { string[] strId = id.Split('_'); cateID = int.Parse(strId[0]); startPage = int.Parse(strId[1]); } ViewBag.page = startPage; MediaBLL mediaBLL = new MediaBLL(); IDictionary <int, MediaObj> flash = new Dictionary <int, MediaObj>(); flash.Add(32, mediaBLL.GetMedia(32)); flash.Add(33, mediaBLL.GetMedia(33)); flash.Add(34, mediaBLL.GetMedia(34)); flash.Add(35, mediaBLL.GetMedia(35)); ViewBag.flash = flash; ProductBLL productBLL = new ProductBLL(); IList <ProductCateObj> productCateList = new List <ProductCateObj>(); ProductCateObj productCateObj = productBLL.GetProductCateByCateID(cateID); ViewBag.cates = productCateObj; while (productCateObj != null) { productCateObj = productBLL.GetProductCateByCateID(productCateObj.ParentID); if (productCateObj == null) { break; } else { productCateList.Add(productCateObj); } } StringBuilder sb = new StringBuilder(); for (int i = productCateList.Count - 1; i >= 0; i--) { sb.Append(">") .Append("<a href='/list/") .Append(productCateList[i].CategoryID) .Append(".html'>") .Append(productCateList[i].CategoryName) .Append("</a>"); } ViewBag.current = new MvcHtmlString(sb.ToString()); ViewBag.allCates = productBLL.GetProductCates(); Validation vld = new Validation(false); int sort = vld.GetInt("sort"); string price = vld.Get("price"); decimal priceFrom = 0; decimal priceTo = 0; if (!string.IsNullOrEmpty(price)) { string[] p = price.Split('-'); priceFrom = decimal.Parse(p[0]); priceTo = decimal.Parse(p[1]); } string sortField; bool isAsc; switch (sort) { case 1: sortField = "Price"; isAsc = true; break; case 2: sortField = "ProductID"; isAsc = false; break; case 4: sortField = "SellNum"; isAsc = false; break; case 5: sortField = "Price"; isAsc = false; break; default: sortField = "Products.Sort"; isAsc = false; break; } ViewBag.sort = sort; ViewBag.price = price; int pageSize = 24; int total; ViewBag.data = productBLL.GetProducts(cateID, null, priceFrom, priceTo, -1, -1, -1, -1, startPage, pageSize, out total, 1, sortField, isAsc); ViewBag.pageSize = pageSize; ViewBag.total = total; ViewBag.totalPages = total % pageSize == 0 ? total / pageSize : (total / pageSize + 1); int totalRecommends; ViewBag.recommends = productBLL.GetProducts(0, null, 0, 0, -1, -1, 1, -1, 1, 10, out totalRecommends); ViewBag.onSaleProducts = WriteProducts(productBLL.GetProducts(0, null, 0, 0, -1, 1, -1, -1, 1, 5, out total)); ViewBag.newProducts = WriteProducts(productBLL.GetProducts(0, null, 0, 0, 1, -1, -1, -1, 1, 20, out total), 5); return(View()); }
public ActionResult Product(int id) { ProductBLL productBLL = new ProductBLL(); ProductObj productObj = productBLL.GetProduct(id); Dictionary <int, string> cates = new Dictionary <int, string>(); ProductCateObj productCateObj = productBLL.GetProductCateByCateID(productObj.CategoryID); IList <ProductCateObj> productCateList = new List <ProductCateObj>(); ViewBag.allCates = productBLL.GetProductCates(); int total; productBLL.GetComments(id, 1, 1, out total); ViewBag.commentCount = total; productBLL.GetMessages(id, 1, 1, out total); ViewBag.messageCount = total; while (productCateObj != null) { productCateList.Add(productCateObj); productCateObj = productBLL.GetProductCateByCateID(productCateObj.ParentID); } StringBuilder sb = new StringBuilder(); for (int i = productCateList.Count - 1; i >= 0; i--) { sb.Append(">") .Append("<a href='/list/") .Append(productCateList[i].CategoryID) .Append(".html'>") .Append(productCateList[i].CategoryName) .Append("</a>"); } ViewBag.current = new MvcHtmlString(sb.ToString()); ViewBag.product = productObj; //int totalRecommends; //ViewBag.recommends = productBLL.GetProducts(0, null, 0, 0, -1, -1, 1, -1, 1, 10, out totalRecommends); ExpressBLL expressBLL = new ExpressBLL(); ViewBag.express = expressBLL.GetExpress(); HttpCookie cookie = Request.Cookies["phistory"]; if (cookie == null || string.IsNullOrEmpty(cookie.Value)) { cookie = new HttpCookie("phistory", id.ToString()); cookie.Expires = DateTime.Now.AddDays(30); ViewBag.recommends = productBLL.GetProducts(new List <int> { id }); } else { string[] values = cookie.Value.Split(','); bool flag = false; IList <int> hst = new List <int>(); for (int i = 0; i < values.Length; i++) { hst.Add(int.Parse(values[i])); if (int.Parse(values[i]) == id) { flag = true; break; } } if (!flag) { hst.Insert(0, id); cookie.Value = ""; for (int i = 0; i < hst.Count && i < 10; i++) { if (i != 0) { cookie.Value += ","; } cookie.Value += hst[i].ToString(); } } ViewBag.recommends = productBLL.GetProducts(hst); cookie.Expires = DateTime.Now.AddDays(30); } Response.SetCookie(cookie); return(View()); }