コード例 #1
0
 private void UpdateRecipe(Recipe recipe, UpdateRecipeCommand cmd)
 {
     recipe.Name         = cmd.Name;
     recipe.TimeToCook   = new TimeSpan(cmd.TimeToCookHrs, cmd.TimeToCookMins, 0);
     recipe.Method       = cmd.Method;
     recipe.IsVegetarian = cmd.IsVegetarian;
     recipe.IsVegan      = cmd.IsVegan;
     recipe.LastModified = DateTimeOffset.UtcNow;
 }
コード例 #2
0
        public void UpdateRecipe(UpdateRecipeCommand cmd)
        {
            var recipe = _context.Recipes.Find(cmd.Id);

            if (recipe == null)
            {
                throw new Exception("Unable to find the recipe");
            }
            UpdateRecipe(recipe, cmd);
            _context.SaveChanges();
        }