public RedirectToRouteResult AddToCart(int Id, string returnUrl) { Models.Good good = db.Goods .FirstOrDefault(g => g.Id == Id); if (good != null) { GetCart().AddItem(good, 1); } return(RedirectToAction("Index", new { returnUrl })); }
public RedirectToRouteResult RemoveFromCart(int Id, string returnUrl) { Models.Good good = db.Goods .FirstOrDefault(g => g.Id == Id); if (good != null) { GetCart().RemoveLine(good); } return(RedirectToAction("Index", new { returnUrl })); }
public static DTO.Goods ToDTO(this Models.Good model) { var goods = new DTO.Goods { id = model.id, name = model.name, detailName = model.detailName, unit = model.Unit1.unit1, category = model.Category1.category1, price = model.price, sellCount = model.sellCount, limited = model.limited, imageName = model.imageName, goodsStatus = model.goodsStatus, evaluate = model.evaluate, goodsDetail = null }; goods.goodsDetail = model.GoodsDetail.ToDTO(); return(goods); }