P1_TrevorGraham/MvcStoreApplication/BusinessLogic/BusinessLogic.cs
/// <summary>
/// attempts to add a line to a cart based on a given orderline viewmodel and returns whether or not it was successful
/// </summary>
/// <param name="orderLineViewModel"></param>
/// <returns></returns>
attempts to add a line to a cart based on a given orderline viewmodel and returns whether or not it was successful
attempts to add a line to a cart based on a given orderline viewmodel and returns whether or not it was successful
public bool AddToCart(OrderLineViewModel orderLineViewModel)
        {
            if (!CurrentUserIsCustomer())
            {
                return false;
            }
            if (orderLineViewModel == null)
            {
                return false;
            }
            var dbInv = _repository.GetInventoryById(orderLineViewModel.InventoryId);
            if (orderLineViewModel.Quantity <= 0 || orderLineViewModel.Quantity > dbInv.Quantity)
            {
                return false;
            }
            var cart = _repository.GetOpenCartForCustomer((Guid)SessionGetCurrentUser());
            var line = _mapper.ConvertOrderLineViewModelToOrderLine(orderLineViewModel);
            return _repository.AddItemToCart(cart, line);
        }
public bool AddToCart ( OrderLineViewModel orderLineViewModel ) { if ( ! CurrentUserIsCustomer ( ) ) { return false ; } if ( orderLineViewModel == null ) { return false ; } var dbInv = _repository . GetInventoryById ( orderLineViewModel . InventoryId ) ; if ( orderLineViewModel . Quantity <= 0 || orderLineViewModel . Quantity > dbInv . Quantity ) { return false ; } var cart = _repository . GetOpenCartForCustomer ( ( Guid ) SessionGetCurrentUser ( ) ) ; var line = _mapper . ConvertOrderLineViewModelToOrderLine ( orderLineViewModel ) ; return _repository . AddItemToCart ( cart , line ) ; }
attempts to add a line to a cart based on a given orderline viewmodel and returns whether or not it was successful
attempts to add a line to a cart based on a given orderline viewmodel and returns whether or not it was successful
//check if orderline is empty //check if order amount is greater than inventory amount //get current cart and line //try to add to cart //return false;
None
orderLineViewModel
OrderLineViewModel
None