Ejemplo n.º 1
0
        /// <summary>
        /// compare the saved customer with the received one.
        /// check the carts of both.
        /// update the saved customer to be exactly the same as the
        /// received one.
        /// </summary>
        /// <param name="customer"></param>
        /// <returns></returns>
        public bool UpdateOrder(Customer customer, OrderModel orderModel)
        {
            bool success = false;

            if (orderModel.addedStacks != null)
            {
                foreach (var stackId in orderModel.addedStacks)
                {
                    // System.Console.WriteLine("added stack: ");
                    // System.Console.WriteLine(stack.Item.SellableName);
                    // System.Console.WriteLine(stack.Count);
                    // System.Console.WriteLine(stack.Item.SellablePrice);
                    var stack = _toyRepository.GetSellableStackByIdDb(stackId);
                    if (_checkIfCanAddToOrder(stack, customer.CurrentOrder))
                    {
                        if (_checkIfStackIsInOrder(stack, customer.CurrentOrder))
                        {
                            if (!_toyRepository.AddSellableStackToCustomerOrder(customer, stack))
                            {
                                return(false);
                            }
                            else
                            {
                                success = true;
                            }
                        }
                    }
                }
            }

            // get the stored user
            // check every sellablestack in cart
            // if
            System.Console.WriteLine("success: " + success);
            return(success);
        }
Ejemplo n.º 2
0
 public SellableStack GetSellableStackById(Guid Id)
 {
     return(_toyRepository.GetSellableStackByIdDb(Id));
 }