public async Task <Recipe> Post([FromBody] Recipe value) { var recipe = await Map(value); await _db.AddAsync(recipe); await _db.SaveChangesAsync(); // Pick up any changes that happen in the DB (triggers, etc) var dbRecipe = await _db.Recipes .Include(r => r.MakesUnit) .SingleOrDefaultAsync(r => r.Name == recipe.Name); return(Map(dbRecipe)); }
public async Task <RecipeIngredient> Post([FromBody] RecipeIngredient value) { var recipeIngredient = await Map(value); await _db.RecipeIngredients.AddAsync(recipeIngredient); await _db.SaveChangesAsync(); var dbRecipeIngredient = await _db.RecipeIngredients .Include(r => r.Ingredient) .Include(r => r.Unit) .SingleOrDefaultAsync(ri => ri.Ingredient.Name == value.IngredientName); return(Map(dbRecipeIngredient)); }