コード例 #1
0
        public async Task <IEnumerable <ServiceEntities.Category> > GetUserCategories()
        {
            var categories = await _categoryRepo.FindByAsync(x => x.Id > -1).ConfigureAwait(false);

            var categoriesList = categories.ToList();

            return(categoriesList.Select(_categoryMapper.ToServiceEntity));
        }
コード例 #2
0
        public async Task UserCategoryCreateCommandTriggersEventToUpdateQueryDbWithCategory()
        {
            var name = "Test Category 1";

            //Arrange
            var command = new UserCategoryCreateCommand(name);
            await _commandBus.Send(command);

            //Act
            var cats = await _categoryRepo.FindByAsync(q => q.Id == 1).ConfigureAwait(false);

            var cat = cats.FirstOrDefault();

            //Act
            Assert.AreEqual(cat.Name, name);
        }
コード例 #3
0
        public async Task Handle(UserCategoryDeletedEvent handle)
        {
            var items = await _categoryRepo.FindByAsync(c => c.Id == handle.AggregateId).ConfigureAwait(false);

            var item = items.FirstOrDefault();

            _logger.Trace("UserCategoryDeletedEvent", handle.AggregateId);

            if (item != null)
            {
                await _categoryRepo.Delete(item).ConfigureAwait(false);
            }
        }
コード例 #4
0
        public async Task Handle(UserCategoryNameChangedEvent handle)
        {
            var items = await _categoryRepo.FindByAsync(c => c.Id == handle.AggregateId).ConfigureAwait(false);

            var item = items.FirstOrDefault();

            if (item != null)
            {
                item.Name         = handle.Name;
                item.Version      = handle.Version;
                item.ModifiedDate = handle.Timestamp;
            }

            await _categoryRepo.Update(item).ConfigureAwait(false);
        }