public IActionResult CreateSessionId() { Random rnd = new Random(); int newSessionId = rnd.Next(10000000, 99999999); bool resStatus = false; try { resStatus = SQLConnections.CreateSessionId(newSessionId); } catch { Console.WriteLine("Error creating session id"); } if (resStatus) { // sucessfully created that session return(Ok(new SessionId() { sessionId = newSessionId, })); } // unable to create that session return(BadRequest()); }