public async Task <TEntity> InsertAsync <TEntity>(TEntity dto) where TEntity : class { var inserted = await _dbContext.Set <TEntity>().AddAsync(dto); await _dbContext.SaveChangesAsync(); return(inserted.Entity); }
public async Task <AddFoodItemPayload> AddFoodItemAsync( AddFoodItemInput input, [ScopedService] GraphqlDbContext context ) { var foodItem = new FoodItem { Name = input.Name, Amount = input.Amount, Unit = input.Unit, Price = input.Price }; context.FoodItems.Add(foodItem); await context.SaveChangesAsync(); return(new AddFoodItemPayload(foodItem)); }