public ActionResult _SetSellState(Guid GoodID, bool IsSelling) { Goods_BLL bll = new Goods_BLL(); Goods off = bll.Get(a => a.GoodID == GoodID); off.IsSelling = IsSelling; bll.Update(off); return(PartialView(off)); }
public ActionResult Details(Guid id) { Goods_BLL bll = new Goods_BLL(); Goods good = bll.Get(a => a.GoodID == id); AutoMapper.Mapper.CreateMap <Goods, Goods_ViewModel>().ForMember(dest => dest.UserName, opt => opt.MapFrom(src => src.Users.UserName)); Goods_ViewModel newmodel = AutoMapper.Mapper.Map <Goods_ViewModel>(good); return(View(newmodel)); }
public ActionResult Add(Goods_Order_ViewModel model) { AutoMapper.Mapper.CreateMap <Goods_Order_ViewModel, Goods_Order>(); Goods_Order order = AutoMapper.Mapper.Map <Goods_Order>(model); order.State = "未发货"; if (model.CategoryName == "虚拟商品") { order.State = "已发货"; } order.CreateTime = DateTime.Now; Goods_Order_BLL bll = new Goods_Order_BLL(); bll.Add(order); Goods_BLL gbll = new Goods_BLL(); Goods good = gbll.Get(a => a.GoodID == model.GoodID); Subscriber_BLL sbll = new Subscriber_BLL(); Subscriber sub = sbll.Get(a => a.SubscribeID == model.SubscribeID); if (sub.Score >= 0 && sub.Score >= good.CostScore) { sub.Score = sub.Score - good.CostScore; if (sub.ScoreUsed != null) { sub.ScoreUsed += good.CostScore; } else { sub.ScoreUsed = good.CostScore; } sbll.Update(sub); good.Count = good.Count - 1; gbll.Update(good); //Subscriber sub = new Subscriber_BLL().Get(a => a.SubscribeID == model.SubscribeID); //string link = WeiXinHelper.AuthorizeUrl(sub.OfficialAccount.AppID, Url.Content("~/WeiXin/Order/MyList"), // sub.AccountID.ToString()); return(RedirectToAction("MyList", "Order", new { SubscribeID = model.SubscribeID })); } else { ModelState.AddModelError("", "抱歉,您的积分不够!"); return(View(model)); } }
public ActionResult Edit(Guid id) { Goods_SendWay_BLL sendbll = new Goods_SendWay_BLL(); ViewBag.SendWaysList = new SelectList(sendbll.GetList().OrderBy(a => a.SendWayOrder), "SendWayID", "SendWayName"); Goods_Category_BLL categorybll = new Goods_Category_BLL(); ViewBag.GoodsCategorysList = new SelectList(categorybll.GetList().OrderBy(a => a.CategoryOrder), "CategoryID", "CategoryName"); Goods_BLL bll = new Goods_BLL(); Goods good = bll.Get(a => a.GoodID == id); AutoMapper.Mapper.CreateMap <Goods, Goods_ViewModel>(); Goods_ViewModel model = AutoMapper.Mapper.Map <Goods_ViewModel>(good); return(View(model)); }
public ActionResult Delete(Guid id) { try { Goods_BLL bll = new Goods_BLL(); Goods good = bll.Get(a => a.GoodID == id); if (good.Image != null) { QiNiuHelper.Delete(ConfigurationManager.AppSettings["QiNiuBucket"], good.Image); } bll.Delete(a => a.GoodID == id); return(RedirectToAction("MyList")); } catch (Exception ex) { return(RedirectToAction("MyList")); } }