public ActionResult Index() { // 先获得推荐商品的索引 即商品的guid list IEnumerable <ReCommend> recommendList = _recommendBLL.GetAllReCommendListwithSortByTime(); List <GoodsModel> goodsModelList = new List <GoodsModel>(); foreach (var item in recommendList) { Goods goods = _goodsBLL.GetGoodsById(item.GoodsId); if (goods == null) { LogHelper.Log.Write("goods is null"); } GoodsImage gi = _goodsImageBLL.GetPictureByGoodsId(goods.Id); if (gi == null) { LogHelper.Log.Write("gi is null"); } GoodsModel gm = new GoodsModel(goods); gm.PicturePath = gi.ImagePath; goodsModelList.Add(gm); } // 要显示的推荐商品 ViewData["GoodsModelList"] = goodsModelList; return(View()); }
/// <summary> /// </summary> /// <param name="GoodsCode"></param> /// <returns></returns> public ActionResult Update(string GoodsCode) { // 根据 传递过来的goodsCode 获取对应的goods Goods goods = _goodsBLL.GetGoodsByCode(GoodsCode); // 再生成 goodsModel 这个将作为model传递到前台 GoodsModel gm = new GoodsModel(goods); // 构造 categoryList List <Category> categoryList = new List <Category>(); // 先根据 goodsId 获取 该 goods对应的分类Id列表 // 再 找到对应的分类列表 foreach (var item in _goodsCategoryBLL.GetGoodsCategoryListByGoodsId(gm.Id)) { Category category = _categoryBLL.GetCategoryById(item.CategoryId); categoryList.Add(category); } // 当前已选分类 ViewData["CurrentCategoryList"] = categoryList; // 所有的分类 ViewData["CategoryList"] = _categoryBLL.GetAllCategory(); GoodsImage gi = new GoodsImage(); gi = _goodsImagesBLL.GetPictureByGoodsId(gm.Id); gm.PicturePath = gi.ImagePath; return(View(gm)); }
public Task <int> SaveItemAsync(GoodsImage item) { if (item.ImageID != 0) { return(database.UpdateAsync(item)); } else { return(database.InsertAsync(item)); } }
public JsonResult Edit(GoodsImage model) { try { if (model.GoodsImageId > 0) { var entity = _GoodsImageService.GetById(model.GoodsImageId); //修改 entity.BaseImageId = model.BaseImageId; entity.Type = model.Type; model.EditPersonId = Loginer.AccountId; model.EditTime = DateTime.Now; _GoodsImageService.Update(model); return(Json(new { Status = Successed.Ok }, JsonRequestBehavior.AllowGet)); } else { //if (_GoodsImageService.CheckBusinessName(model.Name) > 0) // return Json(new { Status = Successed.Repeat }, JsonRequestBehavior.AllowGet); //添加 model.Status = (int)EnabledEnum.效; model.IsDelete = (int)IsDeleteEnum.效; model.CreatePersonId = Loginer.AccountId; model.CreateTime = DateTime.Now; model.EditPersonId = Loginer.AccountId; model.EditTime = DateTime.Now; model = _GoodsImageService.Insert(model); if (model.GoodsImageId > 0) { return(Json(new { Status = Successed.Ok }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Status = Successed.Error }, JsonRequestBehavior.AllowGet)); } } } catch (Exception ex) { return(Json(new { Status = Successed.Error }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Detail(string code) { // 先取出当前vip等级会员折扣 Member member = _memberBLL.GetMemberByOpenId(System.Web.HttpContext.Current.Session["member"].ToString()); double discount = _rulesBLL.GetDiscountByVIP(member.Vip); GoodsModel gm = new GoodsModel(_goodsBLL.GetGoodsByCode(code)); if (gm == null) { return(View(gm)); } GoodsImage gi = _goodsImagesBLL.GetPictureByGoodsId(gm.Id); gm.PicturePath = gi.ImagePath; gm.Discount = discount; return(View(gm)); }
public ActionResult Delete(string GoodsCode) { if (string.IsNullOrEmpty(GoodsCode)) { return(Json("False", JsonRequestBehavior.AllowGet)); } Goods goods = _goodsBLL.GetGoodsByCode(GoodsCode); if (goods == null) { return(Json("False", JsonRequestBehavior.AllowGet)); } goods.IsDeleted = true; goods.DeletedTime = DateTime.Now; if (_goodsBLL.Update(goods)) { // 删除商品图片 GoodsImage gi = _goodsImagesBLL.GetPictureByGoodsId(goods.Id); gi.IsDeleted = true; gi.DeletedTime = DateTime.Now; _goodsImagesBLL.Update(gi); // 获取商品分类列表 List <GoodsCategory> gcList = _goodsCategoryBLL.GetGoodsCategoryListByGoodsId(goods.Id).ToList(); // 异步删除商品分类列表 DelGoodsCategoryDel del = new DelGoodsCategoryDel(DeleteGoodsCategory); IAsyncResult result = del.BeginInvoke(gcList, CallBack, null); return(Json("True", JsonRequestBehavior.AllowGet)); } else { return(Json("False", JsonRequestBehavior.AllowGet)); } }
public IList <GoodsImage> GetGoodsImageListInGroup(Guid goodsGroupId) { IList <Goods> goodsList = null; try { _daoManager.OpenConnection(); goodsList = _goodsDao.GetGoodsListInGroup(goodsGroupId); } catch (Exception exception) { LogHelper.GetInstance().Error("[GetGoodsImageListInGroup]参数:goodsGroupId_" + goodsGroupId, exception); } finally { _daoManager.CloseConnection(); } IList <GoodsImage> goodsImageList = null; //获取图片逻辑 if (goodsList != null && goodsList.Count > 0) { goodsImageList = new List <GoodsImage>(); string imageDirPath = GetImageDirPath(); foreach (Goods goods in goodsList) { string saveImagePath = string.Format("{0}\\{1}.jpg", imageDirPath, goods.GoodsID); string saveThumbnailPath = string.Format("{0}\\{1}_s.jpg", imageDirPath, goods.GoodsID); GoodsImage goodsImage = new GoodsImage { GoodsID = goods.GoodsID, OriginalImage = ImageToByteArray(saveImagePath), GoodsThumb = ImageToByteArray(saveThumbnailPath) }; goodsImageList.Add(goodsImage); } } return(goodsImageList); }
public void AddGoodsImage() { //DisplayDatabase(); string[] ImageName = new string[] { "Assets/AntiFlag-UndergroundNetwork.jpg", "Assets/Blink182-EnemaOfTheState.jpg", "Assets/BoxCarRacer-Album.jpg", "Assets/GoodCharlote-TheYoungAndTheHopeless.jpg", "Assets/GreenDay-AmericanIdiot.jpg", "Assets/SimplePlan-StillNotGetAny.jpg", "Assets/Sum41-AllKillerNoFiller.jpg" }; for (int i = 0; i < ImageName.Length; i++) { GoodsImage image = new GoodsImage(); image.ImageName = ImageName[i]; int count = 0; foreach (GoodsImage item in GoodsImageDatabase.GetItemsAsync().Result) { if (item.ImageName.Equals(ImageName[i])) { count += 1; } } if (count == 0) { GoodsImageDatabase.SaveItemAsync(image); } } }
public ActionResult List() { Member member = _memberBLL.GetMemberByOpenId(System.Web.HttpContext.Current.Session["member"] as string); double discount = _rulesBLL.GetDiscountByVIP(member.Vip); List <Cart> cartList = _cartBLL.GetCartByMemberId(member.Id).ToList(); List <CartModel> cartModelList = new List <CartModel>(); foreach (var item in cartList) { CartModel cm = new CartModel(_goodsBLL.GetGoodsById(item.GoodsId)); GoodsImage gi = _goodsImageBLL.GetPictureByGoodsId(item.GoodsId); cm.PicturePath = gi.ImagePath; cm.Count = item.Count; cm.Discount = discount; cartModelList.Add(cm); } ViewData["CartModelList"] = cartModelList; return(View()); }
public Task <int> DeleteItemAsync(GoodsImage item) { return(database.DeleteAsync(item)); }
/// <summary> /// 删除实体 /// </summary> /// <param name="model"></param> /// <returns></returns> public void Delete(GoodsImage model) { this._GoodsImageBiz.Delete(model); }
/// <summary> /// 修改实体 /// </summary> /// <param name="model"></param> /// <returns></returns> public void Update(GoodsImage model) { this._GoodsImageBiz.Update(model); }
/// <summary> /// 添加实体 /// </summary> /// <param name="model"></param> /// <returns></returns> public GoodsImage Insert(GoodsImage model) { return(this._GoodsImageBiz.Insert(model)); }
public GoodsImage Insert(GoodsImage model) { return(this._repoGoodsImage.Insert(model)); }
public ActionResult Add(GoodsModel model) { // 判断传递的值是否为空 if (model == null) { // 是空 则直接返回 return(RedirectToAction("Add", new { msg = "提交的数据为空,请重新提交" })); } // 构造 Goods 对象 #region 构造 Goods 对象 Goods goods = new Goods(); goods.Id = Guid.NewGuid(); goods.IsDeleted = false; goods.Name = model.Name; goods.Price = model.Price; goods.Code = "Goods_" + TimeManager.GetCurrentTimestamp(); goods.CreatedTime = DateTime.Now.Date; goods.Description = model.Description; goods.ServiceCount = model.ServiceCount; goods.DeletedTime = DateTime.MinValue.AddHours(8); // 商品新家字段 OriginalPrice 原价 // 该字段不影响原来商品添加的逻辑 goods.OriginalPrice = model.OriginalPrice; #endregion // 添加新的Goods 对象 if (_goodsBLL.Add(goods)) { #region 此处应该用事务来做 但是现在简易版就随意一点 将来这里必须用事务 #endregion // 添加成功后 构造 goodsimage 对象 // 并添加到数据库 LogHelper.Log.Write("添加商品成功,现在正在构造goodsImage"); GoodsImage gi = new GoodsImage(); gi.Id = Guid.NewGuid(); gi.ImagePath = model.PicturePath; gi.CreatedTime = DateTime.Now.Date; gi.GoodsId = goods.Id; gi.IsDeleted = false; gi.DeletedTime = DateTime.MinValue.AddHours(8); _goodsImagesBLL.Add(gi); LogHelper.Log.Write("添加商品图片成功"); // 添加成功 则 遍历传递过来的分类列表 // 并添加到数据库 foreach (var item in model.CategoryList) { if (item == null) { LogHelper.Log.Write("获取商品分类列表失败"); } // 构造 GoodsCategory 对象 GoodsCategory gc = new GoodsCategory(); gc.Id = Guid.NewGuid(); gc.CreatedTime = DateTime.Now.Date; gc.CategoryId = _categoryBLL.GetCategoryByCategoryNo(item).Id; gc.IsDeleted = false; gc.GoodsId = goods.Id; gc.DeletedTime = DateTime.MinValue.AddHours(8); _goodsCategoryBLL.Add(gc); } Thread.Sleep(2000); return(RedirectToAction("Add", new { msg = "添加成功" })); } else { return(RedirectToAction("Add", new { msg = "添加失败" })); } }
public ActionResult Update(GoodsModel model) { if (model == null) { return(RedirectToAction("List", new { msg = "更新失败" })); } // 更新 Goods 本身 #region 更新goods本身 Goods goods = _goodsBLL.GetGoodsByCode(model.Code); goods.Price = model.Price; goods.Description = model.Description; goods.ServiceCount = model.ServiceCount; // 商品添加新的字段 OriginalPrice 更新时 也要更新 goods.OriginalPrice = model.OriginalPrice; if (!_goodsBLL.Update(goods)) { return(RedirectToAction("List", new { msg = "更新商品失败" })); } #endregion // 更新 商品图片 #region 更新商品图片 GoodsImage gi = _goodsImagesBLL.GetPictureByGoodsId(goods.Id); if (gi.ImagePath != model.PicturePath) { gi.ImagePath = model.PicturePath; } if (!_goodsImagesBLL.Update(gi)) { return(RedirectToAction("List", new { msg = "更新商品图片失败" })); } #endregion // 更新商品分类的时候 先删除原先的分类 // 再根据新的 model.CategoryList 重新添加上分类 #region 更新 商品分类列表 if (_goodsCategoryBLL.RemoveGoodsCategoryByGoodsId(goods.Id)) { foreach (var item in model.CategoryList) { // 构造 GoodsCategory 对象 GoodsCategory gc = new GoodsCategory(); gc.Id = Guid.NewGuid(); gc.CreatedTime = DateTime.Now.Date; gc.CategoryId = _categoryBLL.GetCategoryByCategoryNo(item).Id; gc.IsDeleted = false; gc.GoodsId = goods.Id; _goodsCategoryBLL.Add(gc); } } #endregion return(RedirectToAction("List", new { msg = "更新成功" })); }
/// <summary> /// 更新GoodsImages /// </summary> /// <param name="gi"></param> /// <returns></returns> public bool Update(GoodsImage gi) { return(_goodsImagesDAL.Update(gi)); }
public void Update(GoodsImage rec) { Exec(GetProcedureString(), rec); }
/// <summary> /// 修改实体 /// </summary> /// <param name="model"></param> /// <returns></returns> public void Update(GoodsImage model) { this._repoGoodsImage.Update(model); }
/// <summary> /// 删除实体 /// </summary> /// <param name="model"></param> /// <returns></returns> public void Delete(GoodsImage model) { this._repoGoodsImage.Delete(model); }
public void Insert(GoodsImage rec) { Exec(GetProcedureString(), rec); }
public bool Add(GoodsImage gi) { return(_goodsImagesDAL.Insert(gi)); }