protected static async Task <string> getBadRequestMessage(HttpResponseMessage httpResponseMessage, string defaultUserErrorMessage)
        {
            string result = defaultUserErrorMessage;

            if (httpResponseMessage.StatusCode == System.Net.HttpStatusCode.BadRequest)
            {
                var badRequestResultContent = await httpResponseMessage.Content.ReadAsStringAsync();

                BadRequestResultObject badRequestResultObject =
                    Json.Decode <BadRequestResultObject>(badRequestResultContent);
                result = badRequestResultObject.Message;
            }
            return(result);
        }
        //recieves HttpResponseMessage,  returns a ResultBase with message as in httpResponseMessage or defaultUserErrorMessage
        //depending on if status code is BadRequest or not, respectively.
        //and then casts the result to a ResultModel
        protected static async Task <ResultModel> ReturnErrorResult <ResultModel>(HttpResponseMessage httpResponseMessage, string defaultUserErrorMessage) where ResultModel : ResultBase, new()
        {
            ResultModel result = new ResultModel {
                Success = false, UserErrorMessage = defaultUserErrorMessage
            };

            if (httpResponseMessage.StatusCode == System.Net.HttpStatusCode.BadRequest)
            {
                var badRequestResultContent = await httpResponseMessage.Content.ReadAsStringAsync();

                BadRequestResultObject badRequestResultObject =
                    Json.Decode <BadRequestResultObject>(badRequestResultContent);
                result.UserErrorMessage = badRequestResultObject.Message;
            }
            return(result);
        }