public IActionResult AddOCRToRec() { // Laver et RecipeDb objekt med de værdier fundet igennem OCR RecipeDb recipe = new RecipeDb(TempData["Title"] as string, TempData["Description"] as string, TempData["Ingredients"] as string, TempData["Steps"] as string); return(View("../Recipe/Addrecipe", recipe)); }
public IActionResult EditResult(string id, RecipeDb rDb, string save) { if (id != rDb.Id) { return(NotFound()); } if (ModelState.IsValid) { switch (save) { case "Save Recipe": tCrud.Update(rDb, id); break; case "Save as new": rDb.Id = GetRandomHexNumber(24); tCrud.AddRecipe(rDb); break; } // rDbService.Update(id, rDb); return(RedirectToAction(nameof(Index))); } else { return(View(rDb)); } }
public IActionResult NewRecipe(RecipeDb recDb) { if (ModelState.IsValid) { rDbService.Create(recDb); return(RedirectToAction(nameof(Index))); } return(View("AddRecipe", recDb)); }
public IActionResult AddRecToUser(RecipeDb rDb) { if (ModelState.IsValid) { rDb.Id = GetRandomHexNumber(24); tCrud.AddRecipe(rDb); return(View("Index", tCrud.GetRecipes())); } return(View("AddRecipe", rDb)); }
public string CheckFav(RecipeDb rDb, string id) { int favIndex = user.favorites.FindIndex(i => i.Id == id); if (favIndex >= 0) { user.favorites.Add(rDb); return($"{rDb.Name} has been added to favorites"); } else { user.favorites.Remove(rDb); return($"{rDb.Name} has been removed from favorites"); } }
public RecipeDb Update(RecipeDb rDb, string id) { RecipeDb x = user.recipeDbs.First(i => i.Id == id); var index = user.recipeDbs.IndexOf(x); // Vend tilbage senere if (index != -1) { testing.FindOneAndUpdate(Builders <TestUser> .Filter.Eq("Id", user.Id), Builders <TestUser> .Update.Pull("Recipes", id)); string a = GetRandomHexNumber(24); testing.FindOneAndUpdate(Builders <TestUser> .Filter.Eq("Id", user.Id), Builders <TestUser> .Update.AddToSet("Recipes", a)); } int favIndex = user.favorites.FindIndex(i => i.Id == id); if (favIndex >= 0) { user.favorites[favIndex] = rDb; } return(rDb); }
public void Update(string id, RecipeDb recDbIn) { recipes.ReplaceOne(rec => rec.Id == id, recDbIn); }
public RecipeDb Create(RecipeDb recDb) { recipes.InsertOne(recDb); return(recDb); }
// Fjern opskrift (Ikke brugt i projektet noget sted) public void Remove(RecipeDb recDbIn) { recipes.DeleteOne(rec => rec.Id == recDbIn.Id); }
public IngredientRepository(RecipeDb db) { _db = db; }
public RecipeRepository(RecipeDb db, IMapper mapper) { _db = db; _mapper = mapper; }
public TestUser AddRecipe(RecipeDb rDb) { user = testing.FindOneAndUpdate(Builders <TestUser> .Filter.Eq("Id", user.Id), Builders <TestUser> .Update.AddToSet("Recipes", rDb)); return(user); }