示例#1
0
        public async Task ChangeProductType(Product prod, ProductTypeId productTypeId)
        {
            var product = await _context.Products.FindAsync(prod.Id);

            product.UpdateProductType(await GetProductTypeAsync(productTypeId));
            await _context.SaveChangesAsync();
        }
示例#2
0
        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;
        }
示例#5
0
        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);
        }
示例#7
0
 public async Task <ProductType> GetProductTypeAsync(ProductTypeId productTypeId)
 {
     return(await _context.ProductTypes.FindAsync(productTypeId));
 }