public bool saveOrder(List <CartDetail> cartDetails) { try { var userID = getUserAccID(); var isValid = false; foreach (var cart in cartDetails) { var storeID = cart.StoreDetailId; //check if cart is active, then change status to submitted //and save to the db if (cart.CartStatusId == 1) { //update cart status to Submitted //var cartStatus = db.CartStatus.Find(2); //Submitted cart.CartStatu = cartdb.GetCartStatus(2); var addResult = cartdb.AddCartDetails(cart); if (addResult) { if (addCartHistory(cart, 2, userID)) { if (removeCartSession(storeID)) { isValid = true; } } } else { return(false); } } } if (isValid) { if (cartdb.Save()) { return(true); } } return(false); } catch { return(false); } }
public int AddCartDetails(CartDetail cart) { CartDetail tempCart = new CartDetail() { CartStatusId = 2, //Submitted DeliveryType = cart.DeliveryType, DtPickup = cart.DtPickup, StoreDetailId = cart.StoreDetailId, StorePickupPointId = cart.StorePickupPointId, UserDetailId = cart.UserDetailId }; var addResult = cartdb.AddCartDetails(tempCart); if (addResult) { return(tempCart.Id); } return(0); }