public async Task <IActionResult> OnPost() { var userId = HttpContext.Session.GetInt32("UserId"); if (userId == null) { Response.Redirect("Login"); } if (ModelState.IsValid) { var ticketController = new TicketController(_configRoot); var workerId = int.Parse(Request.Form["WorkerId"]); _Title = Request.Form["_Title"]; Description = Request.Form["Description"]; var loggerId = int.Parse(Request.Form["LoggerId"]); var ticket = new Models.Ticket(workerId, _Title, Description, null, loggerId, null, null); if (await ticketController.Insert(ticket)) { Response.Redirect("/Tickets"); } } return(Page()); }