public IActionResult Attend([FromForm] IFormCollection form, [FromForm] IFormFile picFile) //string name, string surname, string email, string telephone, string password) { int eventId = int.Parse(form["id"]); EventAccount eventAccount = new EventAccount { EventId = eventId, AccountId = int.Parse(Request.Cookies["user"]) }; try { //save _events.Attend(eventAccount); return(Redirect("/Events/Detail/" + eventId + "/")); } catch (Exception ex) { //return error if there was an exception return(BadRequest(new { message = ex.Message })); } }