public bool Delete(SellerOrderDetail model, string connectionString, out string errMsg) { errMsg = string.Empty; try { PredicateGroup pdg = new PredicateGroup(); pdg.Predicates = new List <IPredicate>(); pdg.Predicates.Add(Predicates.Field <SellerOrderDetail>(o => o.SellerId, Operator.Eq, model.SellerId)); pdg.Predicates.Add(Predicates.Field <SellerOrderDetail>(o => o.OrderId, Operator.Eq, model.OrderId)); pdg.Predicates.Add(Predicates.Field <SellerOrderDetail>(o => o.Index, Operator.Eq, model.Index)); return(Delete(pdg, connectionString, out errMsg)); } catch (Exception ex) { Logger.LogError4Exception(ex, "AppLogger"); return(false); } }
public ActionResult SellerAddToCart(int id) { SellerOrderDetail OD = new SellerOrderDetail(); OD.ProductID = id; int Qty = 1; decimal price = ds.ProductSellers.Find(id).Price; OD.Quantity = Qty; OD.UnitPrice = price; OD.TotalAmount = Qty * price; OD.ProductSeller = ds.ProductSellers.Find(id); if (SellerShippingData.items == null) { SellerShippingData.items = new List <SellerOrderDetail>(); } SellerShippingData.items.Add(OD); //AddRecentViewProduct(id); return(Redirect(TempData["returnURL"].ToString())); //return RedirectToAction("Index", "ForSellerCart"); }
public JsonResult AddSellerOrdersToDb(string orderdetail) { if (Session["IsGuest"] != null) { bool isGuest = (bool)Session["IsGuest"]; if (isGuest) { return(new JsonResult() { Data = new JsonResponseData() { IsSuccess = false, Msg = "该功能暂未开通" } }); } } JsonResponseData result = new JsonResponseData(); var user = GetUser(); if (user == null) { result.IsSuccess = false; result.Msg = "请重新登陆"; return(new JsonResult() { Data = result }); } var models = JsonConvert.DeserializeObject <List <SellerOrderDetailTinyViewModel> >(orderdetail); if (models == null) { result.IsSuccess = false; result.Msg = "订单无效,无法提交"; return(new JsonResult() { Data = result }); } models = models.Where(m => m.ProductQuantity > 0).ToList(); if (models.Count == 0) { result.IsSuccess = false; result.Msg = "什么也没有买~"; return(new JsonResult() { Data = result }); } SellerOrderRun run = new SellerOrderRun() { Amount = models.Sum(m => m.ProductQuantity * m.Price), BuyerId = user.BuyerId, SellerId = models.First().SellerId, OrderDate = DateTime.Now, Code = "", Config = "", LDate = DateTime.Now, RDate = DateTime.Now, LMan = user.BuyerId, RMan = user.BuyerId, ProductQuantity = models.Sum(m => m.ProductQuantity) }; int orderId; string code; string msg; if (SellerOrderRunBll.Insert(run, out orderId, out code, out msg)) { int index = 0; foreach (SellerOrderDetailTinyViewModel detailTinyViewModel in models) { SellerOrderDetail detail = new SellerOrderDetail() { SellerId = detailTinyViewModel.SellerId, BuyerId = user.BuyerId, LMan = user.BuyerId, RMan = user.BuyerId, LDate = DateTime.Now, RDate = DateTime.Now, Index = index++, OrderId = orderId, ProductId = detailTinyViewModel.ProductId, ProductQuantity = detailTinyViewModel.ProductQuantity, ProductName = detailTinyViewModel.ProductName, ProductPrice = detailTinyViewModel.Price, TotalPrice = detailTinyViewModel.Price * detailTinyViewModel.ProductQuantity, ProductUnit = detailTinyViewModel.ProductUnit }; SellerOrderDetailBll.Insert(detail); BuyerShoppingCartBll.Delete(detail.SellerId, detail.BuyerId, detail.ProductId, out msg); } result.Msg = "订单生成成功"; result.IsSuccess = true; } else { result.Msg = "通讯异常,订单创建失败"; } return(new JsonResult() { Data = result }); }