public IActionResult Post([FromBody] CartBO cart) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(Ok(facade.CartService.Create(cart))); }
public decimal GetProductTotal(CartBO cartInfo) { decimal subTotal = cartInfo.checkOutTotal * cartInfo.checkOutQuantity; decimal subTax = subTotal * cartInfo.checkOutTax; subTotal = (subTotal + subTax); return(subTotal); }
public CartBO Create(CartBO cart) { using (var uow = facade.UnitOfWork) { _newCart = uow.CartRepository.Create(cartConv.Convert(cart)); uow.Complete(); return(cartConv.Convert(_newCart)); } }
public CartItemBO Create(CartBO cart, ProductBO prod) { using (var uow = facade.UnitOfWork) { CartItemBO cartItem = new CartItemBO() { Cart = cart, Product = prod }; _newCartItem = uow.CartItemRepository.Create(cartItemConv.Convert(cartItem)); uow.Complete(); return(cartItemConv.Convert(_newCartItem)); } }
public Cart Convert(CartBO cart) { if (cart == null) { return(null); } { return(new Cart() { Id = cart.Id, //ProductIds = cart.ProductIds }); } }
public CartBO GetProductInfo(CartPO infoToMap) { // return an instance of the object CartBO infoToView = new CartBO(); // map the info infoToView.checkOutQuantity = infoToMap.checkOutQuantity; infoToView.checkOutTax = infoToMap.checkOutTax; infoToView.checkOutShipping = infoToMap.checkOutShipping; infoToView.checkOutTotal = infoToMap.checkOutTotal; // return the info return(infoToView); }
public IActionResult Put(int id, [FromBody] CartBO cart) { if (id != cart.Id) { return(StatusCode(405, "Path id does not match cart ID json object")); } try { return(Ok(facade.CartService.Update(cart))); } catch (InvalidOperationException e) { return(StatusCode(404, e.Message)); } }
public List <CartBO> GetProductInfoList(List <CartPO> infoToMapList) { // create an instance of the object list List <CartBO> cartBOList = new List <CartBO>(); // create a foreach loop to map through each object foreach (CartPO singleCartToMap in infoToMapList) { CartBO singleProductBO = GetProductInfo(singleCartToMap); // add the info to the list cartBOList.Add(singleProductBO); } // return the list return(cartBOList); }
public HttpResponseMessage SyncPurchaseOrder(string userId) { CartBO cartBOLogic = new CartBO(); cartBOLogic.UserManager = UserManager; cartBOLogic.RoleManager = RoleManager; var obj = cartBOLogic.SyncPurchaseOrder(userId); if (obj == null) { return(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, cartBOLogic.ErrorMessage)); } else { return(Request.CreateResponse(HttpStatusCode.OK, obj)); } }
public CartBO Update(CartBO cart) { using (var uow = facade.UnitOfWork) { var cartFromDb = uow.CartRepository.Get(cart.Id); if (cartFromDb == null) { throw new InvalidOperationException("Cart not found"); } cartFromDb.Id = cart.Id; //cartFromDb.ProductIds = cart.ProductIds; uow.Complete(); return(cartConv.Convert(cartFromDb)); } }
public CartController() { logic = new CartLogic(); cartBOLogic = new CartBO(); }