public IActionResult Create(RecipeFormVM model) { if (ModelState.IsValid) { var entity = new Recipe { CategoryId = model.CategoryId, Title = model.Title, CoockTime = model.CoockTime, Content = model.Content, Portions = model.Portions }; entity.CreatedAt = DateTime.Now; _recipeRepository.CreateRecipe(entity); _recipeRepository.Commit(); //TempData["FlashMessage"] = "Рецепт создан"; //TempData["FlashType"] = FlashMessageType.Success; return RedirectToAction("Detail", new { id = entity.Id }); } ViewBag.Categories = new SelectList(_categoryRepository.GetAllCategories(), "Id", "Name"); return View(model); }
public void DeleteRecipe(Recipe entity) { _context.Recipies.Remove(entity); }
public void CreateRecipe(Recipe entity) { _context.Recipies.Add(entity); }