示例#1
0
        public bool Insert(HUTModels.Recipe model)
        {
            try
            {
                Recipe recipe = new Recipe()
                {
                    Archived = model.Archived, DateEntered = model.DateEntered, Description = model.Description
                };

                repo.Create(recipe);
                repo.Save();

                if (model.Ingredients?.Count > 0)
                {
                    int?recipeId = GetIdByDescriptionAndDateEntered(model.Description, model.DateEntered);

                    if (recipeId != null)
                    {
                        IngredientBLL bll = new IngredientBLL(this.repo);

                        foreach (HUTModels.Ingredient ingredient in model.Ingredients)
                        {
                            ingredient.RecipeId = (int)recipeId;
                            bll.Insert(ingredient);
                        }
                    }
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#2
0
        public bool Insert(HUTModels.Food model)
        {
            try
            {
                Food food = new Food()
                {
                    CaloriesPer100Grams = model.CaloriesPer100Grams, Description = model.Description, PhotoURL = model.PhotoURL
                };

                repo.Create(food);
                repo.Save();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#3
0
        public bool Insert(HUTModels.FreezerInventory model)
        {
            try
            {
                FreezerInventory inventory = new FreezerInventory()
                {
                    ItemName = model.ItemName, Quantity = model.Quantity
                };

                repo.Create(inventory);
                repo.Save();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#4
0
        public bool Insert(HUTModels.Weight model)
        {
            try
            {
                Weight weight = new Weight()
                {
                    PersonId = model.PersonId, DateEntered = model.DateEntered, WeightAmount = model.WeightAmount
                };

                repo.Create(weight);
                repo.Save();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#5
0
        public bool Insert(HUTModels.CalorieCount model)
        {
            try
            {
                CalorieCount count = new CalorieCount()
                {
                    PersonId = model.PersonId, DatetimeEntered = model.DatetimeEntered, Calories = model.Calories
                };

                repo.Create(count);
                repo.Save();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#6
0
        public bool Insert(HUTModels.CalorieCountOffDay model)
        {
            try
            {
                CalorieCountOffDay countOffDay = new CalorieCountOffDay()
                {
                    PersonId = model.PersonId, DateEntered = model.DateEntered
                };

                repo.Create(countOffDay);
                repo.Save();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#7
0
        public bool Insert(HUTModels.Ingredient model)
        {
            try
            {
                Ingredient ingredient = new Ingredient()
                {
                    FoodId = model.FoodId, RecipeId = model.RecipeId, Weight = model.Weight
                };

                repo.Create(ingredient);
                repo.Save();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#8
0
        public bool Insert(HUTModels.Size model)
        {
            try
            {
                Size size = new Size()
                {
                    PersonId    = model.PersonId,
                    DateEntered = model.DateEntered,
                    Bicep       = model.Bicep,
                    Stomach     = model.Stomach
                };

                repo.Create(size);
                repo.Save();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }