예제 #1
0
 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);
 }
예제 #2
0
 public void DeleteRecipe(Recipe entity)
 {
     _context.Recipies.Remove(entity);
 }
예제 #3
0
 public void CreateRecipe(Recipe entity)
 {
     _context.Recipies.Add(entity);
 }