public IActionResult Create(Recipe recipe, IFormFile file) { RecipeDAO dao = new RecipeDAO(); var claim = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.Sid); recipe.Creator = int.Parse(claim.Value); string s = "kapa"; List <string> warnings = new List <string> { s }; recipe.Warnings = warnings; recipe.Duration = 5; int id = dao.Insert(recipe); if (file != null) { using (MemoryStream ms = new MemoryStream()) { file.CopyToAsync(ms); byte[] b = ms.ToArray(); dao.InsertImage(id, b); } } return(RedirectToAction("Index", "User")); }
public IActionResult Edit(Recipe recipe, IFormFile file) { RecipeDAO dao = new RecipeDAO(); if (file != null) { using (MemoryStream ms = new MemoryStream()) { file.CopyToAsync(ms); byte[] b = ms.ToArray(); dao.InsertImage(recipe.Id_Recipe, b); } } dao.Edit(recipe); return(RedirectToAction("Index", "Recipe")); }