Beispiel #1
0
 /// <summary>
 /// Création d'un ingrédient
 /// </summary>
 public static string NewIngredient(DBO.Ingredient ingredient)
 {
     try
     {
         using (CuisineEntities cuisineEntities = new CuisineEntities())
         {
             T_Ingredient item = cuisineEntities.T_Ingredient.SingleOrDefault(e => e.nom == ingredient.Nom);
             if (item == null)
             {
                 cuisineEntities.T_Ingredient.AddObject(ConvertToEntity(ingredient));
                 cuisineEntities.SaveChanges();
             }
             T_RecetteIngredient ring = new T_RecetteIngredient();
             ring.ingredientID = cuisineEntities.T_Ingredient.SingleOrDefault(e => e.nom == ingredient.Nom).id;
             ring.recetteID = ingredient.idRecette;
             cuisineEntities.T_RecetteIngredient.AddObject(ring);
             cuisineEntities.SaveChanges();
             return string.Empty;
         }
     }
     catch (Exception e)
     {
         Console.Out.WriteLine(e.Message);
         return e.Message;
     }
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the T_RecetteIngredient EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToT_RecetteIngredient(T_RecetteIngredient t_RecetteIngredient)
 {
     base.AddObject("T_RecetteIngredient", t_RecetteIngredient);
 }
 /// <summary>
 /// Create a new T_RecetteIngredient object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="recetteID">Initial value of the recetteID property.</param>
 /// <param name="ingredientID">Initial value of the ingredientID property.</param>
 public static T_RecetteIngredient CreateT_RecetteIngredient(global::System.Int64 id, global::System.Int64 recetteID, global::System.Int64 ingredientID)
 {
     T_RecetteIngredient t_RecetteIngredient = new T_RecetteIngredient();
     t_RecetteIngredient.id = id;
     t_RecetteIngredient.recetteID = recetteID;
     t_RecetteIngredient.ingredientID = ingredientID;
     return t_RecetteIngredient;
 }