public async Task Should_Update_Product() { // Act var product = await _domainService.UpdateProductAsync( Product.Create(LocalNotification) .WithId(ProductRepositoryMock.productGuid) .WithDescription("Product @") .WithValue(20)); // Assert Assert.False(LocalNotification.HasNotification()); Assert.Equal(product.Id, ProductRepositoryMock.productGuid); Assert.Equal("Product @", product.Description); Assert.Equal(20, product.Value); }
public async Task <ProductDto> UpdateProductAsync(Guid id, ProductDto dto) { if (!ValidateDtoAndId(dto, id)) { return(null); } var builder = Product.Create(Notification) .WithId(id) .WithDescription(dto.Description) .WithValue(dto.Value); await _domainService.UpdateProductAsync(builder); dto.Id = id; return(dto); }
public async Task <ProductDto> UpdateProductAsync(Guid id, ProductDto dto) { if (!ValidateDtoAndId(dto, id)) { return(null); } var builder = Product.Create(Notification) .WithId(id) .WithDescription(dto.Description) .WithValue(dto.Value); using (var uow = _unitOfWorkManager.Begin()) { await _domainService.UpdateProductAsync(builder); await uow.CompleteAsync().ForAwait(); } dto.Id = id; return(dto); }