private static ApiRequest?TryDeserializeRequest(string aliensRequestString) { try { var apiRequest = AlienSerializer.Deserialize <ApiRequest>(aliensRequestString); if (apiRequest == null) { throw new FormatException("apiRequest == null"); } return(apiRequest); } catch (FormatException) { return(null); } }
private ActionResult ToActionResult(ApiResponsePollResult pollResult) { if (pollResult.ResponseId != null) { return(Redirect($"~/aliens/{pollResult.ResponseId}")); } var aliensResponse = pollResult.Response; if (planetWarsServer.Settings.PwsMode == PlanetWarsServerMode.Local) { planetWarsServer.Logger.LogInformation(JsonConvert.SerializeObject(aliensResponse)); } var aliensResponseString = AlienSerializer.Serialize(aliensResponse); return(Content(aliensResponseString, MediaTypeNames.Text.Plain)); }