Exemple #1
0
        public void Handle(OrderPlacedEvent orderPlacedEvent)
        {
            Option <Tuple <OrderStatistics, OrderStatisticsRow> > repositoryResult =
                OrderStatisticsRepository.Get(OrderStatisticsRow.TotalOrdersId, _uow);

            var stats = repositoryResult.Map(x => x.Item1).ValueOr(new OrderStatistics());

            stats.TotalOrders++;

            var endResult = new Tuple <OrderStatistics, Option <OrderStatisticsRow> >(
                stats,
                repositoryResult.Select(r => r.Item2));

            OrderStatisticsRepository.UpdateOrInsert(
                _uow,
                endResult,
                OrderStatisticsRow.TotalOrdersId);
        }
Exemple #2
0
        public void Can_Create_New_OrderStatisticsRow()
        {
            using (var uow = new UnitOfWork(TestConfig.GetConnectionString(domain)))
            {
                Guid id = Guid.NewGuid();
                Option <Tuple <OrderStatistics, OrderStatisticsRow> > repositoryResult =
                    OrderStatisticsRepository.Get(id, uow);

                var stats = repositoryResult.Map(x => x.Item1).ValueOr(new OrderStatistics());
                stats.TotalOrders++;

                var endResult = new Tuple <OrderStatistics, Option <OrderStatisticsRow> >(
                    stats,
                    repositoryResult.Select(r => r.Item2));
                OrderStatisticsRepository.UpdateOrInsert(
                    uow,
                    endResult,
                    id);
                uow.Commit();
            }
        }