protected virtual ResponseGet <TResponse> HandleException <TResponse>(HttpContextException exception) where TResponse : class, IResponse, new() { ResponseGet <TResponse> response = new ResponseGet <TResponse>(); response.Code = exception.ResponseMessage.StatusCode.ToString("d"); response.Message = exception.Message; return(response); }
protected virtual async Task <ResponseGet <TResponse> > HandleResponse <TResponse>(HttpResponseMessage responseMessage) where TResponse : class, IResponse, new() { ResponseGet <TResponse> response = new ResponseGet <TResponse>(); response.Code = responseMessage.StatusCode.ToString("d"); response.Message = Enum.GetName(typeof(System.Net.HttpStatusCode), responseMessage.StatusCode); if (responseMessage.StatusCode == System.Net.HttpStatusCode.OK) { var data = await responseMessage.Content.ReadAsStringAsync(); response.Data = Newtonsoft.Json.JsonConvert.DeserializeObject <TResponse>(data); } return(response); }