public async Task Should_Create_Product() { // Act var product = await _domainService.InsertProductAsync( Product.Create(LocalNotification) .WithDescription("Product @") .WithValue(20)); // Assert Assert.False(LocalNotification.HasNotification()); Assert.NotEqual(Guid.Empty, product.Id); Assert.Equal("Product @", product.Description); Assert.Equal(20, product.Value); }
public async Task <ProductDto> CreateProductAsync(ProductDto dto) { if (!ValidateDto <ProductDto>(dto)) { return(null); } var builder = Product.Create(Notification) .WithDescription(dto.Description) .WithValue(dto.Value); Product entity = null; using (var uow = _unitOfWorkManager.Begin()) { entity = await _domainService.InsertProductAsync(builder); await uow.CompleteAsync().ForAwait(); } if (Notification.HasNotification()) { return(null); } return(entity.MapTo <ProductDto>()); }
public async Task <ProductDto> CreateProductAsync(ProductDto dto) { if (!ValidateDto <ProductDto>(dto)) { return(null); } var builder = Product.Create(Notification) .WithDescription(dto.Description) .WithValue(dto.Value); var entity = await _domainService.InsertProductAsync(builder); if (Notification.HasNotification()) { return(null); } return(entity.MapTo <ProductDto>()); }
public async Task <ProductDto> CreateProductAsync(ProductDto dto) { if (!ValidateDto <ProductDto, Guid>(dto)) { return(ProductDto.NullInstance); } var builder = Product.Create(Notification) .WithDescription(dto.Description) .WithValue(dto.Value); var entity = await domainService.InsertProductAsync(builder); if (Notification.HasNotification()) { return(ProductDto.NullInstance); } dto.Id = entity.Id; return(dto); }