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)); }
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); }
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); } }
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); }