Exemplo n.º 1
0
        /// <summary>
        /// Get a single recipe with a specified key
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public Recipe GetRecipe(string key)
        {
            Recipe newRecipe = null;

            try
            {
                using (SqlConnection con = new SqlConnection(conn))
                {
                    con.Open();

                    using (SqlCommand cmd = new SqlCommand("Select * from Recipes where Name = '" + key + "'", con))
                    {
                        SqlDataReader rd = cmd.ExecuteReader();
                        if (rd.Read())
                        {
                            newRecipe          = new Recipe();
                            newRecipe.RecipeID = Convert.ToInt32(rd["RecipeID"]);
                            newRecipe.Name     = rd["Name"].ToString();
                            if (!(rd["Description"] is DBNull))
                            {
                                newRecipe.Description = rd["Description"].ToString();
                            }
                            if (!(rd["Notes"] is DBNull))
                            {
                                newRecipe.Notes = rd["Notes"].ToString();
                            }

                            rd.Dispose();

                            using (SqlCommand cmd2 = new SqlCommand("Select * from RecipeIngredients where RecipeID = " + newRecipe.RecipeID, con))
                            {
                                SqlDataReader rd2 = cmd2.ExecuteReader();
                                if (rd2.HasRows)
                                {
                                    newRecipe.RecipeIngredients = new List <RecipeIngredient>();
                                }
                                while (rd2.Read())
                                {
                                    RecipeIngredient newIng = new RecipeIngredient();
                                    newIng.IngID      = Convert.ToInt32(rd2["IngID"]);
                                    newIng.Amount     = Convert.ToDouble(rd2["Amount"]);
                                    newIng.OtherNotes = rd2["Notes"].ToString();
                                    newRecipe.RecipeIngredients.Add(newIng);
                                }
                                rd2.Dispose();
                            }
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                Console.WriteLine("Query Recipes table failed.\n" + exp.Message);
            }
            return(newRecipe);
        }
Exemplo n.º 2
0
        public async Task <Recipe> CreateAsync(RecipeCreateInputModel model)
        {
            if (model.CategoryId == 0 || model.CookingTimeId == 0)
            {
                return(null);
            }

            var recipe = AutoMapper.Mapper.Map <Recipe>(model);

            if (model.IngredientQuantities != null)
            {
                if (model.IngredientQuantities.IngredientNames.Count() != model.IngredientQuantities.RecipeIngredientQuantity.Count())
                {
                    throw new ArgumentNullException();
                }

                for (int i = 0; i < model.IngredientQuantities.IngredientNames.Count(); i++)
                {
                    var ingredient = this.dbContext.Ingredients.FirstOrDefault(x => x.Name == model.IngredientQuantities.IngredientNames[i]);

                    if (ingredient == null)
                    {
                        return(null);
                    }

                    RecipeIngredient recipeIngredient = new RecipeIngredient
                    {
                        Recipe     = recipe,
                        Ingredient = ingredient,
                        Quantity   = model.IngredientQuantities.RecipeIngredientQuantity[i],
                    };

                    if (this.dbContext.IngredientAllergen.Any(x => x.Ingredient.Name == ingredient.Name &&
                                                              !recipe.RecipeAllergens.Any(y => y.AllergenId == x.AllergenId)))
                    {
                        RecipeAllergen recipeAllergen = new RecipeAllergen
                        {
                            Recipe   = recipe,
                            Allergen = this.dbContext.IngredientAllergen.Where(x => x.Ingredient.Name == model.IngredientQuantities.IngredientNames[i]).Select(x => x.Allergen).FirstOrDefault()
                        };

                        recipeAllergen = this.dbContext.RecipeAllergen.Add(recipeAllergen).Entity;
                        recipe.RecipeAllergens.Add(recipeAllergen);
                    }

                    recipeIngredient = this.dbContext.RecipeIngredient.Add(recipeIngredient).Entity;
                    recipe.RecipeIngredient.Add(recipeIngredient);
                }
            }

            recipe = this.dbContext.Recipes.Add(recipe).Entity;

            await this.dbContext.SaveChangesAsync();

            return(recipe);
        }
        public async Task <int> AddRecipeIngredient(int recipeId, int productId, int ingreditnId, double quantity)
        {
            if (!this.db.Products.Any(p => p.Id == productId) || !this.db.Ingredients.Any(i => i.Id == ingreditnId))
            {
                return(0);
            }
            else if (recipeId == 0)
            {
                Product product = await this.db.Products.FindAsync(productId);

                Recipe recipe = new Recipe()
                {
                    ProductId = productId
                };

                await this.db.Recipes.AddAsync(recipe);

                await this.db.SaveChangesAsync();

                product.RecipeId = recipe.Id;

                await this.db.RecipeIngredients.AddAsync(new RecipeIngredient
                {
                    RecipeId     = recipe.Id,
                    IngredientId = ingreditnId,
                    Quantity     = quantity
                });

                await this.db.SaveChangesAsync();

                return(recipe.Id);
            }
            else
            {
                if (this.db.RecipeIngredients.Any(ri => ri.IngredientId == ingreditnId && ri.RecipeId == recipeId))
                {
                    RecipeIngredient recipeIngredient = await this.db.RecipeIngredients
                                                        .FindAsync(recipeId, ingreditnId);

                    recipeIngredient.Quantity = quantity;
                }
                else
                {
                    await this.db.RecipeIngredients.AddAsync(new RecipeIngredient
                    {
                        RecipeId     = recipeId,
                        IngredientId = ingreditnId,
                        Quantity     = quantity
                    });
                }

                await this.db.SaveChangesAsync();

                return(recipeId);
            }
        }
Exemplo n.º 4
0
        public ActionResult Create()
        {
            RecipeIngredient recipeIngredient = new RecipeIngredient();
            Instruction      instruction      = new Instruction();
            Meal             meal             = new Meal();
            Image            image            = new Image();
            Video            video            = new Video();

            return(View());
        }
Exemplo n.º 5
0
 public RecipeIngredientViewModel(RecipeViewModel recipeDisplay, RecipeIngredient ingredient, bool isDone)
 {
     if (ingredient is null)
     {
         throw new ArgumentNullException(nameof(ingredient));
     }
     RecipeDisplay = recipeDisplay;
     Ingredient    = ingredient;
     _isDone       = isDone;
 }
Exemplo n.º 6
0
        // POST : Recipes/RemoveIngredient?recipedId & ingredientId
        public ActionResult RemoveIngredient(int recipeId, int ingredientId)
        {
            Recipe           recipe           = db.Recipes.Find(recipeId);
            RecipeIngredient recipeIngredient = db.RecipeIngredients.Find(recipeId, ingredientId);

            recipe.Ingredients.Remove(recipeIngredient);
            db.Entry(recipe).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Details", new { id = recipeId }));
        }
 public ActionResult Edit(RecipeIngredient recipeIngredient)
 {
     if (ModelState.IsValid)
     {
         _recipeIngredientService.Update(recipeIngredient);
         return(RedirectToAction("Index"));
     }
     PopulateSeletLists();
     return(View(recipeIngredient));
 }
        public RecipeIngredientViewModel(RecipeIngredient recipeIngredient)
        {
            ID     = recipeIngredient.ID;
            Amount = recipeIngredient.Amount;

            if (recipeIngredient.Ingredient != null)
            {
                Ingredient = new IngredientViewModel(recipeIngredient.Ingredient);
            }
        }
Exemplo n.º 9
0
        public void AddStuffIfDBEmpty()
        {
            if (_recipeRepository.GetAllRecipes().Count == 0)
            {
                Recipe aRecipe = new Recipe()
                {
                    Difficulty        = "ez",
                    RecipeName        = "tacos",
                    RecipeIngredients = new List <RecipeIngredient>()
                };

                Ingredient ing1 = new Ingredient()
                {
                    IngredientName    = "papa",
                    RecipeIngredients = new List <RecipeIngredient>()
                };
                Ingredient ing2 = new Ingredient()
                {
                    IngredientName    = "arroz",
                    RecipeIngredients = new List <RecipeIngredient>()
                };
                Ingredient ing3 = new Ingredient()
                {
                    IngredientName    = "manteca",
                    RecipeIngredients = new List <RecipeIngredient>()
                };

                RecipeIngredient rec1 = new RecipeIngredient()
                {
                    Recipe     = aRecipe,
                    Ingredient = ing1
                };
                RecipeIngredient rec2 = new RecipeIngredient()
                {
                    Recipe     = aRecipe,
                    Ingredient = ing2
                };
                RecipeIngredient rec3 = new RecipeIngredient()
                {
                    Recipe     = aRecipe,
                    Ingredient = ing3
                };

                aRecipe.RecipeIngredients.Add(rec1);
                aRecipe.RecipeIngredients.Add(rec2);
                aRecipe.RecipeIngredients.Add(rec3);

                ing1.RecipeIngredients.Add(rec1);
                ing2.RecipeIngredients.Add(rec2);
                ing3.RecipeIngredients.Add(rec3);


                _recipeRepository.AddRecipe(aRecipe);
            }
        }
Exemplo n.º 10
0
 public ActionResult Edit([Bind(Include = "RecipeIngredientId,RecipeId,Ingredient")] RecipeIngredient recipeIngredient)
 {
     if (ModelState.IsValid)
     {
         db.Entry(recipeIngredient).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.RecipeId = new SelectList(db.Recipes, "RecipeId", "Title", recipeIngredient.RecipeId);
     return(View(recipeIngredient));
 }
Exemplo n.º 11
0
 public bool Validate(RecipeIngredient recipeIngredient)
 {
     try
     {
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 12
0
        private static void _createRecipeIngredient(Recipe recipe, Ingredient dbIngredient)
        {
            RecipeIngredient recipeIngredient = new RecipeIngredient();

            recipeIngredient.Ingredient     = dbIngredient;
            recipeIngredient.IngredientId   = dbIngredient.IngredientId;
            recipeIngredient.Recipe         = recipe;
            recipeIngredient.RecipeId       = recipe.RecipeId;
            recipeIngredient.quantity_grams = 10;
            recipe.RecipeIngredients.Add(recipeIngredient);
        }
        public Task <List <Recipe> > SearchRecipeAsync(string IngredientName, string RecipeType)
        {
            var RecipeList = new List <Recipe>();

            if (String.IsNullOrEmpty(IngredientName))
            {
                return(Task.FromResult(RecipeList));
            }
            else
            {
                con.Open();
                Guid IngredientId = getId(IngredientName);

                if (RecipeType == "normal")
                {
                    q = "select * from RecipeIngredients ri join Recipes r on r.RecipeId = ri.RecipeId where ri.IngredientId = '" + IngredientId + "'and r.Status='Approved' ";
                }
                else if (RecipeType == "vegetarian")
                {
                    q = "select * from RecipeIngredients ri join Recipes r on r.RecipeId = ri.RecipeId where (ri.IngredientId = '" + IngredientId + "' and (r.RecipeType='Vegan' or r.RecipeType='Vegetarian')and r.Status='Approved') ";
                }
                else
                {
                    q = "select * from RecipeIngredients ri join Recipes r on r.RecipeId = ri.RecipeId where (ri.IngredientId = '" + IngredientId + "' and r.RecipeType='Vegan' and r.Status='Approved') ";
                }
                using (SqlCommand command = new SqlCommand(q, con))
                {
                    SqlDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        Recipe recipe = new Recipe(Guid.Parse(reader[0].ToString()), reader[5].ToString(), reader[8].ToString(), reader["RecipeType"].ToString());
                        RecipeList.Add(recipe);
                    }
                    reader.Close();
                    foreach (var recipe in RecipeList)
                    {
                        IngredientQuery = "select * from RecipeIngredients ri join Ingredients i on i.IngredientId = ri.IngredientId where ri.RecipeId = '" + recipe.Id + "' ";
                        using (SqlCommand cmd = new SqlCommand(IngredientQuery, con))
                        {
                            reader = cmd.ExecuteReader();
                            while (reader.Read())
                            {
                                RecipeIngredient recipeIngredient = new RecipeIngredient(reader[5].ToString(), reader[2].ToString(), reader[3].ToString());
                                recipe.RecipeIngredients.Add(recipeIngredient);
                            }
                            reader.Close();
                        }
                    }
                }
                con.Close();
                return(Task.FromResult(RecipeList));
            }
        }
Exemplo n.º 14
0
        /*
         * Adds a new ingredient to the ingredient list for this recipe
         * that's being added or edited in this form.
         */
        private async void addIngredient(object sender, RoutedEventArgs e)
        {
            IngredientDialog ingredientDialog = new IngredientDialog();
            await ingredientDialog.ShowAsync();

            if (ingredientDialog.NewIngredient != null)
            {
                RecipeIngredient newIngredient = ingredientDialog.NewIngredient;
                this.ingredients.Add(newIngredient);
            }
        }
Exemplo n.º 15
0
    void LoadIngredients(List <IngredientDetail> itemIngredients)
    {
        foreach (IngredientDetail ingredient in itemIngredients)
        {
            GameObject ingredientObj = (GameObject)GameObject.Instantiate(IngredientPrefab);
            ingredientObj.transform.SetParent(IngredientsGrid.transform);

            RecipeIngredient recipeIngredient = ingredientObj.GetComponent <RecipeIngredient>();
            recipeIngredient.LoadIngredient(ingredient);
        }
    }
Exemplo n.º 16
0
        public async Task <IActionResult> Create([Bind("Id")] RecipeIngredient recipeIngredient)
        {
            if (ModelState.IsValid)
            {
                _context.Add(recipeIngredient);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(recipeIngredient));
        }
Exemplo n.º 17
0
 public ActionResult Edit([Bind(Include = "ID,IngredientID")] RecipeIngredient recipeIngredient)
 {
     if (ModelState.IsValid)
     {
         db.Entry(recipeIngredient).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IngredientID = new SelectList(db.Ingredient, "ID", "Name", recipeIngredient.IngredientID);
     return(View(recipeIngredient));
 }
Exemplo n.º 18
0
        public ActionResult Create([Bind(Include = "RecipeIngredientId,RecipeId,Ingredient")] RecipeIngredient recipeIngredient)
        {
            if (ModelState.IsValid)
            {
                db.RecipeIngredients.Add(recipeIngredient);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RecipeId = new SelectList(db.Recipes, "RecipeId", "Title", recipeIngredient.RecipeId);
            return(View(recipeIngredient));
        }
        public void AddRecipeIngredient(Guid RecipeId, Guid IngredientId, string Quantity, string UnitOfMeasurement)
        {
            var recipeIngredient = new RecipeIngredient(RecipeId, IngredientId, Quantity, UnitOfMeasurement);

            q = "insert into RecipeIngredients(RecipeId,IngredientId,Quantity,MeasurementUnit)values('" + recipeIngredient.RecipeId + "','" + recipeIngredient.IngredientId + "','" + recipeIngredient.Quantity + "','" + recipeIngredient.UnitOfMeasurement + "')";
            SqlCommand cmd = new SqlCommand(q, con);

            cmd.ExecuteNonQuery();

            //_dataRepository.Insert(recipeIngredient);
            //_unitOfWork.Commit();
        }
Exemplo n.º 20
0
 public ActionResult Edit([Bind(Include = "recipeID,ingredientID,amount,amountUnits")] RecipeIngredient recipeIngredient)
 {
     if (ModelState.IsValid)
     {
         db.Entry(recipeIngredient).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ingredientID = new SelectList(db.Ingredients, "ingredientID", "groceryCode", recipeIngredient.ingredientID);
     ViewBag.recipeID     = new SelectList(db.Recipes, "recipeID", "recipeName", recipeIngredient.recipeID);
     return(View(recipeIngredient));
 }
Exemplo n.º 21
0
        public async Task <IActionResult> PostRecipeIngredient([FromBody] RecipeIngredient recipeIngredient)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.RecipeIngredients.Add(recipeIngredient);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetRecipeIngredient", new { id = recipeIngredient.RecipeIngredientID }, recipeIngredient));
        }
Exemplo n.º 22
0
        private void Seed()
        {
            using var context = new RecAPIContext(ContextOptions);
            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            var fusilli = new Ingredient
            {
                Id   = 1,
                Name = "Fusilli",
                RecipeIngredients = new List <RecipeIngredient>()
            };

            var garlic = new Ingredient
            {
                Id   = 2,
                Name = "Garlic",
                RecipeIngredients = new List <RecipeIngredient>()
            };

            var fugu = new Ingredient
            {
                Id   = 3,
                Name = "Fugu",
                RecipeIngredients = new List <RecipeIngredient>()
            };

            var recipe = new Recipe
            {
                Id                = 1,
                Name              = "Pure Garlic",
                Description       = "For the true fans of garlic",
                Instructions      = "Peel garlic. Consume garlic.",
                RecipeIngredients = new List <RecipeIngredient>()
            };

            var riGarlic = new RecipeIngredient
            {
                IngredientId = 1,
                Ingredient   = garlic,
                RecipeId     = 1,
                Recipe       = recipe,
                Amount       = 1000,
                Unit         = (Unit)5
            };

            garlic.RecipeIngredients.Add(riGarlic);

            context.Ingredients.Add(garlic);
            context.Ingredients.Add(fusilli);
            context.Ingredients.Add(fugu);
            context.SaveChanges();
        }
Exemplo n.º 23
0
 public RecipeIngredientViewModel Map(RecipeIngredient model)
 {
     return(new RecipeIngredientViewModel
     {
         RecipeId = model.RecipeId,
         IngredientId = model.IngredientId,
         Amount = model.Amount,
         G = model.G,
         Ml = model.Ml,
         IngredientName = model.Ingredient.Name
     });
 }
        public ActionResult EditIngredientRecipe(int recipeIngredientId)
        {
            RecipeIngredient recipeIngredient = _recipeIngredientService.GetById(recipeIngredientId);

            if (recipeIngredient == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound, "Recipe Ingredient could not be found with the id -" + recipeIngredientId.ToString()));
            }
            PopulateSeletLists();

            return(View("~/Views/RecipeIngredient/EditRecipeIngredient.cshtml", recipeIngredient));
        }
Exemplo n.º 25
0
        public ActionResult Create([Bind(Include = "ID,IngredientID")] RecipeIngredient recipeIngredient)
        {
            if (ModelState.IsValid)
            {
                db.RecipeIngredient.Add(recipeIngredient);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.IngredientID = new SelectList(db.Ingredient, "ID", "Name", recipeIngredient.IngredientID);
            return(View(recipeIngredient));
        }
Exemplo n.º 26
0
 public IngredientViewModel ToIngredientViewModel(RecipeIngredient ingredient)
 {
     return(new IngredientViewModel
     {
         Id = ingredient.Id,
         Amount = ingredient.Amount,
         Ingredient = ingredient.Ingredient,
         Recipe = ingredient.Recipe,
         Ingredients = _combosHelper.GetComboIngredients(),
         IngredientId = ingredient.Ingredient.Id,
         RecipeId = ingredient.Recipe.Id,
     });
 }
Exemplo n.º 27
0
        /// <summary>
        /// Method adds new ingredient to the list of ingredients in CommonMethodOfMenu
        /// </summary>
        private void AddIngredientToList()
        {
            temp = foodProductList.ElementAt(result - 1).Name;
            Console.WriteLine($"\nEnter the quantity of product {temp} and its measure:");
            FoodProduct foodProduct = new FoodProduct();

            foodProduct.Name = temp;
            RecipeIngredient recipeIngredient = new RecipeIngredient();

            recipeIngredient.FoodProduct           = foodProduct;
            recipeIngredient.QuantityOfFoodProduct = Console.ReadLine();
            ingredients.Add(recipeIngredient);
        }
Exemplo n.º 28
0
        public async Task <IActionResult> Create([Bind("Id,RecipeId,IngredientId,CaloriesPerRecipe,ProteinsPerRecipe")] RecipeIngredient recipeIngredient)
        {
            if (ModelState.IsValid)
            {
                _context.Add(recipeIngredient);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IngredientId"] = new SelectList(_context.Ingredient, "Id", "Name", recipeIngredient.IngredientId);
            ViewData["RecipeId"]     = new SelectList(_context.Recipe, "Id", "Description", recipeIngredient.RecipeId);
            return(View(recipeIngredient));
        }
Exemplo n.º 29
0
        public RecipeIngredient ToDomainModel(Recipe recipe)
        {
            var ri = new RecipeIngredient();

            ri.ID             = ID;
            ri.Amount         = Amount;
            ri.IngredientSlug = Ingredient.Slug;
            ri.Ingredient     = Ingredient.ToDomainModel();
            ri.RecipeSlug     = recipe.Slug;
            ri.Recipe         = recipe;

            return(ri);
        }
        public async Task CreateAsync(string ingredientId, string recipeId, string quantity)
        {
            var recipeIngredient = new RecipeIngredient()
            {
                IngredientId = ingredientId,
                RecipeId     = recipeId,
                Quantity     = quantity,
            };

            await this.recipeIngredientsRepository.AddAsync(recipeIngredient);

            await this.recipeIngredientsRepository.SaveChangesAsync();
        }
Exemplo n.º 31
0
        // clear the current list of ingredients for a given recipe and add the ones based on the file to ingest
        private static void addIngredients(RecipeObj recipe)
        {
            // clear the current list
            using (var context = new WoolworthsDBDataContext())
            {
                var ingredToDel = context.RecipeIngredients.Where(r => r.RecipeID == recipe.RecipeID);
                context.RecipeIngredients.DeleteAllOnSubmit(ingredToDel);
                context.SubmitChanges();
            }

            if (recipe.Ingredients == null)
                return;

            using (var context = new WoolworthsDBDataContext())
            {
                foreach (var obj in recipe.Ingredients)
                {
                    var ingred = new RecipeIngredient()
                    {
                        Description = obj.Ingredient,
                        Number = obj.IngredientID,
                        ProductArticle = obj.ProductID,
                        RecipeID = recipe.RecipeID
                    };
                    context.RecipeIngredients.InsertOnSubmit(ingred);
                }
                context.SubmitChanges();
            }
        }
Exemplo n.º 32
0
 public static void InsertRecipe(string name, string source, RecipeCategory category, string description, string prep, string cook, List<IngredientEntry> ingredients, out int recid)
 {
     int id;
     try
     {
         using (RecipeBook_DataModelDataContext db = new RecipeBook_DataModelDataContext())
         {
             Recipe rec = new Recipe();
             rec.rec_Name = name;
             rec.rec_Source = source;
             rec.rec_Description = description;
             rec.rec_PreparationInstructions = prep;
             rec.rec_CookingInstructions = cook;
             rec.rec_EntryDate = DateTime.Today;
             rec.cat_ID = category.cat_ID;
             db.Recipes.InsertOnSubmit(rec);
             db.SubmitChanges();
             id = rec.rec_ID;
         }
         using (RecipeBook_DataModelDataContext db = new RecipeBook_DataModelDataContext())
         {
             var recipe = (from rec in db.Recipes where rec.rec_ID == id select rec).First();
             foreach (IngredientEntry i in ingredients)
             {
                 RecipeIngredient recing = new RecipeIngredient();
                 recing.rec_ID = id;
                 recing.ing_ID = i.Ingredient.ing_ID;
                 recing.mes_ID = i.Measurement.mes_ID;
                 recing.ri_Amount = i.Amount;
                 recipe.RecipeIngredients.Add(recing);
             }
             db.SubmitChanges();
         }
         recid = id;
     }
     catch (Exception)
     {
         recid = -1;
         throw;
     }
 }
Exemplo n.º 33
0
 public static void UpdateRecipe(string name, string source, RecipeCategory category, string description, string prep, string cook, List<IngredientEntry> ingredients, int rec_ID)
 {
     try
     {
         using (RecipeBook_DataModelDataContext db = new RecipeBook_DataModelDataContext())
         {
             var original = (from rec in db.Recipes where rec.rec_ID == rec_ID select rec).First();
             original.rec_Name = name;
             original.rec_Source = source;
             original.rec_Description = description;
             original.rec_PreparationInstructions = prep;
             original.rec_CookingInstructions = cook;
             original.cat_ID = category.cat_ID;
             db.SubmitChanges();
         }
         using (RecipeBook_DataModelDataContext db = new RecipeBook_DataModelDataContext())
         {
             var original = (from rec in db.Recipes where rec.rec_ID == rec_ID select rec.RecipeIngredients).First();
             original.Clear();
             foreach (IngredientEntry i in ingredients)
             {
                 RecipeIngredient recTemp = new RecipeIngredient();
                 recTemp.ing_ID = i.Ingredient.ing_ID;
                 recTemp.mes_ID = i.Measurement.mes_ID;
                 recTemp.ri_Amount = i.Amount;
                 recTemp.rec_ID = rec_ID;
                 original.Add(recTemp);
             }
             db.SubmitChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
 public void Parse(GameBitBuffer buffer)
 {
     Name = buffer.ReadCharArray(256);
     Field1 = buffer.ReadInt(32);
     Field2 = buffer.ReadInt(32);
     Field3 = buffer.ReadInt(32);
     Field4 = buffer.ReadInt(32);
     Field5 = new AttributeSpecifier[16];
     for(int i = 0;i < _Field5.Length;i++)
     {
         _Field5[i] = new AttributeSpecifier();
         _Field5[i].Parse(buffer);
     }
     Field6 = buffer.ReadInt(32);
     Field7 = new RecipeIngredient[3];
     for(int i = 0;i < _Field7.Length;i++)
     {
         _Field7[i] = new RecipeIngredient();
         _Field7[i].Parse(buffer);
     }
 }
 public void Parse(GameBitBuffer buffer)
 {
     Name = buffer.ReadCharArray(256);
     snoRecipe = buffer.ReadInt(32);
     Field2 = buffer.ReadInt(2);
     Field3 = buffer.ReadInt(32);
     Field4 = buffer.ReadInt(32);
     Field5 = buffer.ReadInt(32);
     Field6 = buffer.ReadInt(32);
     Field7 = new RecipeIngredient[6];
     for(int i = 0;i < _Field7.Length;i++)
     {
         _Field7[i] = new RecipeIngredient();
         _Field7[i].Parse(buffer);
     }
 }