示例#1
0
        public void Import(IEnumerable <RecipeIngredients> data)
        {
            using (var transaction = session.BeginTransaction())
            {
                var d = data.ToArray();
                foreach (var row in d)
                {
                    var dbRow = new Models.RecipeIngredients
                    {
                        RecipeIngredientId = row.RecipeIngredientId,
                        Recipe             = Models.Recipes.FromId(row.RecipeId),
                        Ingredient         = Models.Ingredients.FromId(row.IngredientId),
                        IngredientForm     = row.IngredientFormId.HasValue ? Models.IngredientForms.FromId(row.IngredientFormId.Value) : null,
                        Unit         = row.Unit,
                        QtyLow       = row.QtyLow,
                        DisplayOrder = row.DisplayOrder,
                        PrepNote     = row.PrepNote,
                        Qty          = row.Qty,
                        Section      = row.Section
                    };

                    session.Save(dbRow, row.RecipeIngredientId);
                }

                Log.DebugFormat("Created {0} row(s) in RecipeIngredients", d.Count());
                transaction.Commit();
                session.Flush();
            }
        }
        public static void UpdateRecipeIngredients(Models.RecipeIngredients recipeIngredients)
        {
            using (var conn = DataService.CreateConnection())
            {
                var command = DataService.CreateSqlStoredProcCommand(conn, "sp_UpdateRecipeIngredients");
                command.Parameters.Add(new SqlParameter("@Id", recipeIngredients.Id));
                command.Parameters.Add(new SqlParameter("@RecipeId", recipeIngredients.RecipeId));
                command.Parameters.Add(new SqlParameter("@IngredientId", recipeIngredients.IngredientId));
                command.Parameters.Add(new SqlParameter("@IngredientAmount", recipeIngredients.IngredientAmount));
                command.Parameters.Add(new SqlParameter("@IngredientUnitId", recipeIngredients.RecipeIngredientUnitId));

                conn.Open();
                command.ExecuteNonQuery();
            }
        }
示例#3
0
 public void UpdateRecipeIngredients(Models.RecipeIngredients ingredient)
 {
     throw new System.NotImplementedException();
 }
示例#4
0
 public void AddRecipeIngredients(Models.RecipeIngredients recipeIngredients)
 {
     throw new System.NotImplementedException();
 }
        public void Import(IEnumerable<RecipeIngredients> data)
        {
            using (var transaction = this.session.BeginTransaction())
            {
                var recipeIngredientsArray = data.ToArray();
                foreach (var recipeIngredients in recipeIngredientsArray)
                {
                    var databaseRecipeIngredients = new Models.RecipeIngredients
                                                  {
                                                      RecipeIngredientId =
                                                          recipeIngredients.RecipeIngredientId,
                                                      Recipe =
                                                          Models.Recipes.FromId(
                                                              recipeIngredients.RecipeId),
                                                      Ingredient =
                                                          Models.Ingredients.FromId(
                                                              recipeIngredients.IngredientId),
                                                      IngredientForm =
                                                          recipeIngredients.IngredientFormId
                                                              .HasValue
                                                              ? Models.IngredientForms.FromId(
                                                                  recipeIngredients
                                                                    .IngredientFormId.Value)
                                                              : null,
                                                      Unit = recipeIngredients.Unit,
                                                      QtyLow = recipeIngredients.QtyLow,
                                                      DisplayOrder =
                                                          recipeIngredients.DisplayOrder,
                                                      PrepNote = recipeIngredients.PrepNote,
                                                      Qty = recipeIngredients.Qty,
                                                      Section = recipeIngredients.Section
                                                  };

                    this.session.Save(databaseRecipeIngredients, recipeIngredients.RecipeIngredientId);
                }

                this.Log.DebugFormat("Created {0} row(s) in RecipeIngredients", recipeIngredientsArray.Count());
                transaction.Commit();
                this.session.Flush();
            }
        }
        public void Import(IEnumerable<RecipeIngredients> data)
        {
            using (var transaction = session.BeginTransaction())
             {
            var d = data.ToArray();
            foreach (var row in d)
            {
               var dbRow = new Models.RecipeIngredients
               {
                  RecipeIngredientId = row.RecipeIngredientId,
                  Recipe = Models.Recipes.FromId(row.RecipeId),
                  Ingredient = Models.Ingredients.FromId(row.IngredientId),
                  IngredientForm = row.IngredientFormId.HasValue ? Models.IngredientForms.FromId(row.IngredientFormId.Value) : null,
                  Unit = row.Unit,
                  QtyLow = row.QtyLow,
                  DisplayOrder = row.DisplayOrder,
                  PrepNote = row.PrepNote,
                  Qty = row.Qty,
                  Section = row.Section
               };

               session.Save(dbRow, row.RecipeIngredientId);
            }

            Log.DebugFormat("Created {0} row(s) in RecipeIngredients", d.Count());
            transaction.Commit();
            session.Flush();
             }
        }