public string Update(Recipe user) { RecipeDAL userdal = new RecipeDAL(); return(userdal.Update(user)); }
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(); }
public string Delete(long code) { RecipeDAL userdal = new RecipeDAL(); return(userdal.Delete(code)); }
public IActionResult Results(string i, string q) { List <Recipe> recipes = RecipeDAL.GetRecipe(i, q); if (recipes != null) { return(View(recipes)); } else { return(RedirectToAction("Index")); } }
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")); }
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); }
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)); }
//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; } }
//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; } }
/// <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); } }
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); }
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(); }
public string Insert(Recipe user) { RecipeDAL userdal = new RecipeDAL(); return(userdal.Insertar(user)); }
public ActionResult Index(string type = null, string input = null) { ViewBag.results = RecipeDAL.GetRecipes($"?{type}{input}")["results"]; return(View()); }
public Recipe GetByID(long ID) { RecipeDAL userdal = new RecipeDAL(); return(userdal.GetByID(ID)); }
public Recipe Get(string code) { RecipeDAL userdal = new RecipeDAL(); return(userdal.Get(code)); }
public List <Recipe> GetRecomendedRecipes(int countChildren) { RecipeDAL userdal = new RecipeDAL(); return(userdal.GetRecomendedRecipes(countChildren)); }
public List <Recipe> GetAll() { RecipeDAL userdal = new RecipeDAL(); return(userdal.GetAll()); }
/// <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)); }
/// <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()); }
/// <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); }
public void GetRecipeByUserIDTest() { RecipeDAL recipeDAL = new RecipeDAL(); recipeDAL.GetRecipeListByUserID(1); }
public Recipe GetById(long?code) { RecipeDAL userdal = new RecipeDAL(); return(userdal.GetById(code)); }
public RecipeController(IConfiguration configuration, APIProjectDBContext context) { _configuration = configuration.GetSection("APIKeys")[""]; RD = new RecipeDAL(configuration); _context = context; }
public HomeController(RecipeDAL dal) { _dal = dal; }