public async Task ChangeProductType(Product prod, ProductTypeId productTypeId) { var product = await _context.Products.FindAsync(prod.Id); product.UpdateProductType(await GetProductTypeAsync(productTypeId)); await _context.SaveChangesAsync(); }
public static async Task <bool> CheckIfProductTypeExists(ProductTypeId id) { var connectionString = ConnectivityService.GetConnectionString("TEMP"); var context = new SplurgeStopDbContext(connectionString); var repository = new ProductTypeRepository(context); return(await repository.ExistsAsync(id)); }
public void Brand_created() { var productTypeId = new ProductTypeId(SequentialGuid.NewSequentialGuid()); var sut = ProductType.Create(productTypeId, "New ProductType"); Assert.NotNull(sut); Assert.Contains("New ProductType", sut.Name); }
public void SetProductTypeId(Guid productTypeId) { if (ProductTypeId.IsNull() || productTypeId == Guid.Empty) { throw new ArgumentNullException(nameof(productTypeId)); } ProductTypeId = productTypeId; }
public static async Task RemoveProductType(ProductTypeId id) { var connectionString = ConnectivityService.GetConnectionString("TEMP"); var context = new SplurgeStopDbContext(connectionString); var repository = new ProductTypeRepository(context); var unitOfWork = new EfCoreUnitOfWork(context); var service = new ProductTypeService(repository, unitOfWork); var productTypeController = new ProductTypeController(service); var updateCommand = new Commands.DeleteProductType { Id = id }; await productTypeController.DeleteProductType(updateCommand); }
public void ProductType_not_created(ProductTypeId id, string name) { Action sut = () => ProductType.Create(id, name); Assert.Throws <ArgumentNullException>(sut.Invoke); }
public async Task <ProductType> GetProductTypeAsync(ProductTypeId productTypeId) { return(await _context.ProductTypes.FindAsync(productTypeId)); }