示例#1
0
 public async Task <Core.Domain.Product.Product> FindAsync(Core.Domain.Product.Product product)
 {
     if (product == null)
     {
         throw new ArgumentNullException();
     }
     return(await _appDbContext.Products.FirstOrDefaultAsync((p) => p.Name.Equals(product.Name) && Math.Abs(p.Price - product.Price) < 0.001 && p.Quantity == product.Quantity));
 }
示例#2
0
        public async Task AddAsync(Core.Domain.Product.Product product)
        {
            if (product == null)
            {
                throw new ArgumentNullException();
            }
            var dbProduct = await this.FindAsync(product);

            if (dbProduct == null)
            {
                await _appDbContext.Products.AddAsync(product);

                await _appDbContext.Products.LoadAsync();
            }
        }
示例#3
0
        public async Task AddAsync(Core.Domain.Product.Product product)
        {
            await _appDbContext.Products.AddAsync(product);

            await _appDbContext.SaveChangesAsync();
        }