Esempio n. 1
0
        public CookingStep DeleteCookingStep(int csId)
        {
            CookingStep stepEntry = context.CookingSteps.FirstOrDefault(c => c.CookingStepId == csId);

            if (stepEntry != null)
            {
                context.CookingSteps.Remove(stepEntry);
                context.SaveChanges();
            }
            return(stepEntry);
        }
Esempio n. 2
0
 public void SaveCookingStep(CookingStep cookingStep)
 {
     if (cookingStep.CookingStepId == 0) // New product
     {
         context.CookingSteps.Add(cookingStep);
     }
     else // update
     {
         CookingStep stepEntry = context.CookingSteps.FirstOrDefault(s => s.CookingStepId == cookingStep.CookingStepId);
         if (stepEntry != null)
         {
             stepEntry.CookingStepId     = cookingStep.CookingStepId;
             stepEntry.CookingStepNumber = cookingStep.CookingStepNumber;
             stepEntry.Description       = cookingStep.Description;
             stepEntry.RecipeId          = cookingStep.RecipeId;
         }
     }
     context.SaveChanges();
 }