예제 #1
0
        public string Update(Recipe user)
        {
            RecipeDAL userdal = new RecipeDAL();


            return(userdal.Update(user));
        }
예제 #2
0
        private void ShowAllRecipes()
        {
            Console.WriteLine("SHOWING RECIPES");

            RecipeDAL dal = new RecipeDAL(connectionString);

            List <Recipe> allRecipes = dal.GetAllRecipes();

            foreach (Recipe r in allRecipes)
            {
                Console.WriteLine();
                Console.WriteLine(r.Id + ")" + r.Name + " - " + r.CookTimeInMinutes + " minutes");
                Console.WriteLine("DESCRIPTION: " + r.Description);

                IngredientDAL ingredientDal = new IngredientDAL(connectionString);

                List <Ingredient> recipeIngredients = ingredientDal.GetIngredientsForRecipe(r.Id);

                Console.WriteLine("INGREDIENTS");
                foreach (Ingredient i in recipeIngredients)
                {
                    Console.WriteLine(" - " + i.Name + " (" + i.Quantity + ")");
                }
            }

            Console.ReadLine();
        }
예제 #3
0
        public string Delete(long code)
        {
            RecipeDAL userdal = new RecipeDAL();


            return(userdal.Delete(code));
        }
예제 #4
0
        public IActionResult Results(string i, string q)
        {
            List <Recipe> recipes = RecipeDAL.GetRecipe(i, q);

            if (recipes != null)
            {
                return(View(recipes));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
예제 #5
0
        public IActionResult AddFavorite(string title, string href, string thumbnail)
        {
            var dbModel = new RecipeDAL();

            dbModel.title     = title;
            dbModel.href      = href;
            dbModel.thumbnail = thumbnail;

            _recipeDbContext.Favorites.Add(dbModel);
            _recipeDbContext.SaveChanges();

            return(RedirectToAction("HomePage"));
        }
예제 #6
0
        private ResultsViewModel GetRecipeWhereIdIsFirstOrDefault(int id)
        {
            RecipeDAL recipeDAL = _recipeDbContext.Favorites
                                  .Where(recipe => recipe.ID == id)
                                  .FirstOrDefault();

            var recipe = new ResultsViewModel();

            recipe.ID        = recipeDAL.ID;
            recipe.title     = recipeDAL.title;
            recipe.href      = recipeDAL.href;
            recipe.thumbnail = recipeDAL.thumbnail;

            return(recipe);
        }
예제 #7
0
        public IActionResult FavoritesIndex()
        {
            var dbModel = new RecipeDAL();

            var RecipeList = _recipeDbContext.Favorites
                             .Select(recipeDAL => new ResultsViewModel()
            {
                ID = recipeDAL.ID, title = recipeDAL.title, href = recipeDAL.href, thumbnail = recipeDAL.thumbnail
            })
                             .ToList();

            var viewModel = new FavoritesViewModel();

            viewModel.results = RecipeList;

            return(View(viewModel));
        }
예제 #8
0
 //get recipe list in combobox
 public DataTable GetRecipeListBL()
 {
     try
     {
         RecipeDAL recipeDAL = new RecipeDAL();
         //call the RecipeDAL function
         DataTable dt = recipeDAL.GetRecipeListDAL();
         return(dt);
     }
     catch (RecipeIngredientSystemExceptions)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #9
0
 //view selected recipe details
 public DataTable ViewRecipeBL(int recipeid)
 {
     try
     {
         RecipeDAL recipeDAL = new RecipeDAL();
         //call the RecipeDAL function
         DataTable dt = recipeDAL.ViewRecipeDAL(recipeid);
         return(dt);
     }
     catch (RecipeIngredientSystemExceptions)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #10
0
        /// <summary>
        /// Save the recipe information to the database.
        /// </summary>
        /// <param name="recipe">Recipe information that will be saved.</param>
        public void SaveRecipe(Recipe recipe, Amount amount)
        {
            ICollection <ValidationResult> validationResults;

            if (!recipe.Validate(out validationResults))
            {
                var ex = new ValidationException(Validation_Object_Error);
                ex.Data.Add("ValidationResult", validationResults);
                throw ex;
            }

            // Create a new entry if RecipeID is equal to zero.
            if (recipe.RecipeID == 0)
            {
                RecipeDAL.InsertRecipe(recipe, amount);
            }
            else
            {
                RecipeDAL.UpdateRecipe(recipe);
            }
        }
예제 #11
0
        public void AddRecipeToDatabaseTest()
        {
            //Arrange
            // - Fake Recipe
            Recipe r = new Recipe();

            r.CookTimeInMinutes = 10;
            r.Description       = "FAKE DESCRIPTION";
            r.Instructions      = "FAKE INSTRUCTIONS";
            r.Name = "FAKE NAME";

            // - DAL to Insert the Fake Recipe
            RecipeDAL dal = new RecipeDAL(connectionString);

            //Act
            // - Call AddRecipe using the Fake Recipe
            bool output = dal.AddRecipe(r);

            //Assert
            // - Validatea that AddRecipe returned TRUE
            Assert.IsTrue(output);
        }
예제 #12
0
        private void AddARecipe()
        {
            string name         = CLIHelper.GetString("NAME OF RECIPE: ");
            string description  = CLIHelper.GetString("DESCRIPTION: ");
            string instructions = CLIHelper.GetString("INSTRUCTIONS: ");
            int    cookTime     = CLIHelper.GetInteger("How long does it take to cook");

            Recipe r = new Recipe();

            r.Name              = name;
            r.Description       = description;
            r.Instructions      = instructions;
            r.CookTimeInMinutes = cookTime;

            RecipeDAL dal = new RecipeDAL(connectionString);

            dal.AddRecipe(r);


            Console.WriteLine("Sucessfully added!");

            Console.ReadLine();
        }
예제 #13
0
        public string Insert(Recipe user)
        {
            RecipeDAL userdal = new RecipeDAL();

            return(userdal.Insertar(user));
        }
예제 #14
0
 public ActionResult Index(string type = null, string input = null)
 {
     ViewBag.results = RecipeDAL.GetRecipes($"?{type}{input}")["results"];
     return(View());
 }
예제 #15
0
        public Recipe GetByID(long ID)
        {
            RecipeDAL userdal = new RecipeDAL();

            return(userdal.GetByID(ID));
        }
예제 #16
0
        public Recipe Get(string code)
        {
            RecipeDAL userdal = new RecipeDAL();

            return(userdal.Get(code));
        }
예제 #17
0
        public List <Recipe> GetRecomendedRecipes(int countChildren)
        {
            RecipeDAL userdal = new RecipeDAL();

            return(userdal.GetRecomendedRecipes(countChildren));
        }
예제 #18
0
        public List <Recipe> GetAll()
        {
            RecipeDAL userdal = new RecipeDAL();

            return(userdal.GetAll());
        }
예제 #19
0
 /// <summary>
 /// Retrieving a recipe entry with a specific recipe number from the database.
 /// </summary>
 /// <param name="recipeId">The recipes Recipe Number.</param>
 /// <returns>A Recipe-object containing information about the recipes.</returns>
 public Recipe GetRecipe(int recipeId)
 {
     return(RecipeDAL.GetRecipeById(recipeId));
 }
예제 #20
0
 /// <summary>
 /// Gets all the recipes stored in the database.
 /// </summary>
 /// <returns>List of references to Recipe-objects containing information about the recipes.</returns>
 public IEnumerable <Recipe> GetRecipes()
 {
     return(RecipeDAL.GetRecipes());
 }
예제 #21
0
 /// <summary>
 /// Removes the specified recipe from the database.
 /// </summary>
 /// <param name="recipeId">The recipe to be deleted.</param>
 public void DeleteRecipe(int recipeId)
 {
     RecipeDAL.DeleteRecipe(recipeId);
 }
예제 #22
0
        public void GetRecipeByUserIDTest()
        {
            RecipeDAL recipeDAL = new RecipeDAL();

            recipeDAL.GetRecipeListByUserID(1);
        }
예제 #23
0
        public Recipe GetById(long?code)
        {
            RecipeDAL userdal = new RecipeDAL();

            return(userdal.GetById(code));
        }
예제 #24
0
 public RecipeController(IConfiguration configuration, APIProjectDBContext context)
 {
     _configuration = configuration.GetSection("APIKeys")[""];
     RD             = new RecipeDAL(configuration);
     _context       = context;
 }
예제 #25
0
 public HomeController(RecipeDAL dal)
 {
     _dal = dal;
 }