public IActionResult Index() { TempData["SubCategory"] = (from subcatgry in _dbContext.SubCategories select new SelectListItem { Text = subcatgry.Category, Value = subcatgry.Id.ToString() }).ToList(); TempData["Category"] = (from catgry in _dbContext.Categories select new SelectListItem { Text = catgry.Category1, Value = catgry.Id.ToString() }).ToList(); var recipe = new AddRecipe(); recipe.Ings = (from ing in _dbContext.Ingredients select new DishIng { IngName = ing.IngName + ing.Qty, Id = ing.Id, Qty = ing.Qty }).ToList(); return(View(recipe)); }
public AddRecipeViewModel(AddRecipe open, tblUser user) { addRecipe = open; recipe = new tblRecipe(); author = user; recipe.authorId = user.userId; }
public IActionResult AddRecipe(AddRecipe recipe) { recipe.Img = Utils.GetByteArrayFromImage(recipe.Image); recipe.AddedDate = DateTime.Now; recipe.AddedBy = "Nupoor Prashant"; _dbContext.Dishes.Add(recipe); _dbContext.SaveChanges(); foreach (var ing in recipe.Ings) { if (ing.isChecked) { _dbContext.DishIngMaps.Add( new DishIngMap() { DishId = recipe.Id, IngId = ing.Id }); _dbContext.SaveChanges(); } } ViewBag.Success = "Successfully added the recipe"; _hubContext.Clients.All.SendAsync("ReceiveMessage", string.Empty, string.Concat("<a style='color:white;' href='/Recipe/Recipe/", recipe.Id, "'>", "A new recipe '", recipe.DishName, "' has just been added.</a>")); Utils.Create(string.Concat("dish_", recipe.Id.ToString()), recipe.Img); return(RedirectToAction("Index")); }
public IActionResult AddCategory(AddRecipe catgry) { if (catgry.Category != null) { _dbContext.Categories.Add(catgry.Category); _dbContext.SaveChanges(); } return(RedirectToAction("Index")); }
/// <summary> /// Method for edit the selected item from the list /// </summary> public void EditRecipeExecute() { tblRecipe tempRecipe = new tblRecipe { RecipeID = 0, RecipeName = Recipe.RecipeName, RecipeType = Recipe.RecipeType, NoPeople = Recipe.NoPeople, RecipeDescription = Recipe.RecipeDescription, CreationDate = Recipe.CreationDate, UserID = Recipe.UserID, Changed = Recipe.Changed }; List <tblIngredientAmount> tempRecipeIngrediantAmountList = recipeData.GetAllSelectedRecipeIngrediantAmount(recipe.RecipeID).ToList(); try { MessageBoxResult dialogDelete = Xceed.Wpf.Toolkit.MessageBox.Show($"Da li zelite da azurirate ovaj recept iz liste?\n\nRecept: {Recipe.RecipeName}", "Azuriraj recept", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (dialogDelete == MessageBoxResult.Yes) { if (Recipe != null) { AddRecipe addRecipeWindow = new AddRecipe(Recipe); addRecipeWindow.ShowDialog(); // Checks if the recipe did not get updated if (isRecipeNotUpdated == true) { recipeData.AddRecipe(tempRecipe); for (int i = 0; i < tempRecipeIngrediantAmountList.Count; i++) { tempRecipeIngrediantAmountList[i].IngredientAmountID = 0; tempRecipeIngrediantAmountList[i].RecipeID = tempRecipe.RecipeID; recipeData.AddIngredientAmount(tempRecipeIngrediantAmountList[i]); } isRecipeNotUpdated = false; } else { // Save recipe changes recipeData.AddRecipe(Recipe); } RecipeList = recipeData.GetAllRecipes().ToList(); allReciperWindow.DataGridOrder.ItemsSource = RecipeList; AllRecipesWindow.filteredList = new List <tblRecipe>(); allReciperWindow.filteredRecipes = new List <tblRecipe>(); } } } catch (Exception) { MessageBoxResult dialog = Xceed.Wpf.Toolkit.MessageBox.Show("Trenutno je nemoguce obrisati recept...", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public IActionResult AddSubCategory(AddRecipe subcatgry) { if (subcatgry.Subcategory != null) { _dbContext.Add(subcatgry.Subcategory); _dbContext.SaveChanges(); } return(RedirectToAction("Index")); }
private void InitCommands() { AddRecipe = new AddRecipe(this); RemoveRecipe = new RemoveCommand <Recipe>(this); AddIngredience = new AddIngredience(this); RemoveIngredience = new RemoveIngredience(this); PlanRecipe = new PlanRecipe(this); StornoPlanning = new StornoPlanning(this); SavePlanning = new SavePlanning(this); }
public IActionResult Delete(int recipeId) { AddRecipe deletedRecipe = repository.DeleteRecipe(recipeId); if (deletedRecipe != null) { TempData["message"] = $"{deletedRecipe.Name} was deleted!"; } return(RedirectToAction(nameof(Index))); }
public ViewResult AddRecipe(AddRecipe addRecipe, Cuisine cuisine) { if (ModelState.IsValid) { repository1.SaveRecipe(addRecipe, cuisine); return(View("Thanks", addRecipe)); } else { return(View()); } }
public IActionResult Edit(AddRecipe addRecipe, Cuisine cuisine) { if (ModelState.IsValid) { repository.SaveRecipe(addRecipe, cuisine); TempData["message"] = $"{addRecipe.Name} Recipe has been saved!"; return(RedirectToAction(nameof(Index))); } else { return(View(addRecipe)); } }
/// <summary> /// Method for adding the selected item from the list /// </summary> public void AddRecipeExecute() { try { AddRecipe addRecipeWindow = new AddRecipe(); addRecipeWindow.ShowDialog(); RecipeList = recipeData.GetAllRecipes().ToList(); allReciperWindow.DataGridOrder.ItemsSource = RecipeList; AllRecipesWindow.filteredList = new List <tblRecipe>(); allReciperWindow.filteredRecipes = new List <tblRecipe>(); } catch (Exception) { MessageBoxResult dialog = Xceed.Wpf.Toolkit.MessageBox.Show("Trenutno je nemoguce dodati recept...", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void AddRecipeExecute() { try { AddRecipe addView = new AddRecipe(currentUser); addView.ShowDialog(); if ((addView.DataContext as AddRecipeViewModel).isUpdated == true) { RecipeList = service.GetAllRecipes(); selectedTitle = null; selectedType = null; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void AddRecipeShouldBeValid() { // Should be valid var test1 = new AddRecipe { Title = "test", Description = "test", Notes = "test" }; var test1Validator = new AddRecipeValidator(); Assert.True(test1Validator.Validate(test1).IsValid); // Should require title var test2 = new AddRecipe { Description = "test", Notes = "test" }; var test2Validator = new AddRecipeValidator(); test2Validator.ShouldHaveValidationErrorFor(c => c.Title, test2); var longTitle = "test"; while (longTitle.Length <= 100) { longTitle += $"{longTitle}{longTitle}{longTitle}{longTitle}"; } // title should be 100 in length var test3 = new AddRecipe { Description = longTitle, Notes = "test" }; var test3Validator = new AddRecipeValidator(); test3Validator.ShouldHaveValidationErrorFor(c => c.Title, test2); }
public void AddRecipeShouldAddNewRecipe() { // Arrange var addNew = new AddRecipe { Title = "test" }; autoMoqer.GetMock <IRecipeBookDataManager>().Setup(c => c.Recipes.CreateItemAsync(It.IsAny <RecipeEntry>())).Returns(Task.FromResult(Guid.NewGuid().ToString())); // Act var response = recipeBookRequestHandler.Handle(addNew, cancellationToken).Result; // Assert Assert.NotNull(response); Assert.IsType <RecipeEntry>(response); Assert.True(response.Title == addNew.Title); autoMoqer.GetMock <IRecipeBookDataManager>().Verify(c => c.Recipes.CreateItemAsync(It.IsAny <RecipeEntry>()), Times.Once); }
/// <summary> /// Opens the Edit Recipe Window /// </summary> /// <param name="addRecipeOpen">opens the edit recipe window</param> /// <param name="recipeEdit">gets the recipe info that is being edited</param> public AddRecipeViewModel(AddRecipe addRecipeOpen, tblRecipe recipeEdit) { recipe = recipeEdit; addRecipe = addRecipeOpen; addRecipe.btnDodaj.IsEnabled = true; AddIngredientToRecipe addIngredientWindow = new AddIngredientToRecipe(Recipe.RecipeID); addIngredientWindow.Height = 450; addRecipe.border.Width = 1000; ViewIngredinet = Visibility.Visible; addRecipe.btnDodajSastojak.Visibility = Visibility.Collapsed; //AddIngredientToRecipe addIngredientToRecipe = new AddIngredientToRecipe(); UserControl screen = ((UserControl)addIngredientWindow); addRecipe.StackPanelMain.Children.Clear(); addRecipe.StackPanelMain.Children.Add(screen); AddIngredientToRecipeViewModel.IngrediantAmountListCount = ingrediantsData.GetAllIngredients().Count(); }
public IActionResult Post([FromBody, Required] AddRecipe command) { return(CreatedAtRoute("GetRecipe", new { id = Guid.NewGuid() }, null)); }
public async Task <RecipeEntry> Post([FromBody] AddRecipe value) { return(await _mediator.Send(value)); }
private void AddToolStripMenuItem_Click(object sender, EventArgs e) { Form addRecipe = new AddRecipe(); addRecipe.Show(); }
public MainWindow() { InitializeComponent(); AddRecipe.Focus(); }
/// <summary> /// Opens the Add recipe window /// </summary> /// <param name="addRecipeOpen">Window that we open</param> public AddRecipeViewModel(AddRecipe addRecipeOpen) { recipe = new tblRecipe(); addRecipe = addRecipeOpen; IngredientList = ingrediantsData.GetAllIngredients().ToList(); }
public IActionResult AddIng(AddRecipe ing) { _dbContext.Ingredients.Add(ing.Ingredient); _dbContext.SaveChanges(); return(RedirectToAction("Index")); }