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)); }
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(); } }
public async Task AddAsync(Core.Domain.Product.Product product) { await _appDbContext.Products.AddAsync(product); await _appDbContext.SaveChangesAsync(); }