public async Task <IActionResult> OnPostSave(string id) { try { InitializeAll(id); HttpContext.Session.SetString("recipeId", Recipe.Id.ToString()); HttpContext.Session.SetString("userId", Recipe.UserId.ToString()); string title = Request.Form["name"]; string ingredients = Request.Form["ing"]; string preparation = Request.Form["prep"]; string link = Request.Form["link"]; Recipe.ChangeTitle(title); Recipe.ChangeIngredients(ingredients); Recipe.ChangePreparationInstructions(preparation); Recipe.ChangeLink(link); Inf.EditRecipe(Recipe); if (Request.Form.TryGetValue("comments", out var commentsText)) { Inf.EditComments(Comments, commentsText); } return(RedirectToPage("RecipePage")); } catch (Exception) { HttpContext.Session.SetString("errorMsg", "שגיאה בעריכת המתכון"); return(RedirectToPage("ErrorPage")); } }