Exemple #1
0
 public BikeController(IProductRepository productRepository, IShoppingItemRepository shoppingItemRepository, ICustomerRepository customerRepository, IShoppingBagRepository shoppingBagRepository)
 {
     _productRepository      = productRepository;
     _shoppingItemRepository = shoppingItemRepository;
     _customerRepository     = customerRepository;
     _shoppingBagRepository  = shoppingBagRepository;
 }
 public DecProductQuantityService(IProductDetailCommandFactory commandFactory, IShoppingRepository shoppingRepository, IShoppingQueryRepositorySpecificationFactory shoppingRepositorySpecFactory, IShoppingItemRepository shoppingItemRepository, IShoppingItemByIdRepositorySpecificationFactory shoppingItemRepositorySpecFactory)
 {
     this.commandFactory                    = commandFactory;
     this.shoppingRepository                = shoppingRepository;
     this.shoppingRepositorySpecFactory     = shoppingRepositorySpecFactory;
     this.shoppingItemRepository            = shoppingItemRepository;
     this.shoppingItemRepositorySpecFactory = shoppingItemRepositorySpecFactory;
 }
Exemple #3
0
 public BikeController(IProductRepository productRepository, IShoppingItemRepository shoppingItemRepository,
                       ICustomerRepository customerRepository, IShoppingBagRepository shoppingBagRepository, UserManager <Customer> userManager)
 {
     _productRepository      = productRepository;
     _shoppingItemRepository = shoppingItemRepository;
     _customerRepository     = customerRepository;
     _shoppingBagRepository  = shoppingBagRepository;
     _userManager            = userManager;
 }
 public ShoppingItemController(IShoppingItemRepository shoppingItemRepository)
 {
     _shoppingItemRepository = shoppingItemRepository;
 }
 public ShoppingBagService(IShoppingBagRepository _repository, IShoppingItemRepository _shoppingItemRepository)
 {
     repository             = _repository;
     shoppingItemRepository = _shoppingItemRepository;
 }
 public HomeController(IShoppingItemRepository repository)
 {
     _shoppingRepository = repository;
 }
Exemple #7
0
 public ShoppingItemService(IShoppingItemRepository _repository)
 {
     repository = _repository;
 }
Exemple #8
0
        public void IncQuantity(IShoppingRepository shoppingQueryRepository, IShoppingQueryRepositorySpecificationFactory shoppingQueryRepositorySpecificationFactory, IShoppingItemRepository shoppingItemRepository, IShoppingItemByIdRepositorySpecificationFactory shoppingItemByIdRepositorySpecificationFactory, Action <IProductAggregation> success, Action <Exception> error)
        {
            ++Quantity;
            UpdateDiscount();

            Persist(shoppingQueryRepository, shoppingQueryRepositorySpecificationFactory, shoppingItemRepository, shoppingItemByIdRepositorySpecificationFactory, success, error);
        }
Exemple #9
0
        public void DecQuantity(IShoppingRepository shoppingQueryRepository, IShoppingQueryRepositorySpecificationFactory shoppingQueryRepositorySpecificationFactory, IShoppingItemRepository shoppingItemRepository, IShoppingItemByIdRepositorySpecificationFactory shoppingItemByIdRepositorySpecificationFactory, Action <IProductAggregation> success, Action <Exception> error)
        {
            --Quantity;
            if (Quantity < 0)
            {
                Quantity = 0;
                Discount = 0;
            }
            else
            {
                UpdateDiscount();
            }

            Persist(shoppingQueryRepository, shoppingQueryRepositorySpecificationFactory, shoppingItemRepository, shoppingItemByIdRepositorySpecificationFactory, success, error);
        }
Exemple #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="shoppingQueryRepository"></param>
        /// <param name="shoppingQueryRepositorySpecificationFactory"></param>
        /// <param name="shoppingItemRepository"></param>
        /// <param name="shoppingItemByIdRepositorySpecificationFactory"></param>
        /// <param name="success"></param>
        /// <param name="error"></param>
        private void Persist(IShoppingRepository shoppingQueryRepository, IShoppingQueryRepositorySpecificationFactory shoppingQueryRepositorySpecificationFactory, IShoppingItemRepository shoppingItemRepository, IShoppingItemByIdRepositorySpecificationFactory shoppingItemByIdRepositorySpecificationFactory, Action <IProductAggregation> success, Action <Exception> error)
        {
            shoppingQueryRepository.Find(shoppingQueryRepositorySpecificationFactory.NewActiveShoppingSpec(), shoppings =>
            {
                if (shoppings.Count == 0 || shoppings[0].IsFinished)
                {
                    error.Invoke(new NoActiveShoppingException());
                    return;
                }

                var shopping = shoppings[0];

                shoppingItemRepository.GetById(shoppingItemByIdRepositorySpecificationFactory.NewQuerySpec(shopping, Id), shoppingItem =>
                {
                    if (shoppingItem == ShoppingItemEntity.Empty)
                    {
                        shoppingItemRepository.Insert(new ShoppingItemEntity(shopping, this), id => {
                            success.Invoke(this);
                        }, err => {
                            error(err);
                        });
                    }
                    else
                    {
                        shoppingItemRepository.Update(new ShoppingItemEntity(shopping, this), shoppingItemByIdRepositorySpecificationFactory.NewUpdateSpec(shopping, Id), id =>
                        {
                            success.Invoke(this);
                        }, err =>
                        {
                            error(err);
                        });
                    }
                }, err =>
                {
                    error(err);
                });
            }, err =>
            {
                error(err);
            });
        }