/// <summary> /// Lazy loading is not currently available with EF 7.0, so this loads the Store/Product/Category information /// </summary> private async Task FillRaincheckValuesAsync(Raincheck raincheck) { raincheck.IssuerStore = await _context.Stores.AsAsyncEnumerable().First(s => s.StoreId == raincheck.StoreId); raincheck.Product = this.productsRepository.Find(p => p.ProductId == raincheck.ProductId).First(); raincheck.Product.Category = await _context.Categories.AsAsyncEnumerable().First(c => c.CategoryId == raincheck.Product.CategoryId); }
public async Task <int> AddAsync(Raincheck raincheck) { var addedRaincheck = _context.RainChecks.Add(raincheck); await _context.SaveChangesAsync(CancellationToken.None); return(addedRaincheck.Entity.RaincheckId); }
/// <summary> /// Lazy loading is not currently available with EF 7.0, so this loads the Store/Product/Category information /// </summary> private async Task FillRaincheckValuesAsync(Raincheck raincheck) { raincheck.IssuerStore = await _context.Stores.FirstAsync(s => s.StoreId == raincheck.StoreId); raincheck.Product = await _context.Products.FirstAsync(p => p.ProductId == raincheck.ProductId); raincheck.Product.Category = await _context.Categories.FirstAsync(c => c.CategoryId == raincheck.Product.CategoryId); }
public Task <int> Post([FromBody] Raincheck raincheck) { return(_query.AddAsync(raincheck)); }