public IActionResult SelectHero(Hero model) { if (!CheckLogin()) { if (ModelState.IsValid) { int?userId = HttpContext.Session.GetInt32("UserId"); int userid = userId ?? default(int); herofactory.CreateNewHero(model, userid); } } ViewBag.Errors = ModelState.Values; return(Json("something")); }