Exemple #1
0
 public void Exec(Action complete)
 {
     shoppingRepository.Find(specificationFactory.NewActiveShoppingSpec(), shoppings =>
     {
         if (shoppings.Count == 0 || shoppings[0].IsFinished)
         {
             shoppingRepository.Insert(entityFactory.NewShopping(), id => complete.Invoke(), err => complete.Invoke());
         }
         else
         {
             complete.Invoke();
         }
     }, error => complete.Invoke());
 }
Exemple #2
0
 public void Exec(Action <IProductAggregation> success, Action <Exception> error)
 {
     shoppingRepository.Find(shoppingRepositorySpecFactory.NewActiveShoppingSpec(), shoppings =>
     {
         if (shoppings.Count > 0 && !shoppings[0].IsFinished)
         {
             repository.GetById(factory.NewQuerySpec(shoppings[0], id), success, error);
         }
         else
         {
             repository.GetById(factory.NewQuerySpec(id), success, error);
         }
     }, error);
 }
 public void Exec(Action <IList <IProductAggregation> > success, Action <Exception> error)
 {
     shoppingRepository.Find(shoppingRepositorySpecFactory.NewActiveShoppingSpec(), shoppings =>
     {
         if (shoppings.Count == 0 || shoppings[0].IsFinished)
         {
             error(new NoActiveShoppingException());
         }
         else
         {
             repository.Find(specFactory.NewCatalogSpec(shoppings[0].Id), success, error);
         }
     }, error);
 }
Exemple #4
0
 public void Exec(Action <IList <IProductAggregation> > success, Action <Exception> error)
 {
     shoppingRepository.Find(shoppingQueryRepositorySpecificationFactory.NewActiveShoppingSpec(), shoppings =>
     {
         if (shoppings.Count == 0 || shoppings[0].IsFinished)
         {
             error.Invoke(new NoActiveShoppingException());
         }
         else
         {
             productRepository.Find(productQueryRepositorySpecificationFactory.NewCartSpec(shoppings[0].Id), success, error);
         }
     }, error);
 }
 public void Exec(Action complete)
 {
     shoppingRepository.Find(specificationFactory.NewActiveShoppingSpec(), shoppings =>
     {
         if (shoppings.Count == 0 || shoppings[0].IsFinished)
         {
             complete.Invoke();
         }
         else
         {
             shoppings[0].Finish();
             shoppingRepository.Update(shoppings[0], byIdSpecificationFactory.NewUpdateSpec(shoppings[0].Id), shopping => complete.Invoke(), err => complete.Invoke());
         }
     }, error => complete.Invoke());
 }
Exemple #6
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);
            });
        }