public async Task Update(Recipe recipe) { recipe.UpdateDateTime = DateTime.UtcNow; using (var db = new MySqlDbContext(_options.MySqlConnectionString)) { var updatededRecipe = await db.AddAsync(recipe); await db.SaveChangesAsync(); } }
public async Task <int> Create(Recipe recipe) { recipe.CreateDateTime = recipe.UpdateDateTime = DateTime.UtcNow; using (var db = new MySqlDbContext(_options.MySqlConnectionString)) { var addedRecipe = await db.AddAsync(recipe); await db.SaveChangesAsync(); return(addedRecipe.Entity.RecipeId); } }