public CallbackRecordDto Callback([FromBody] CallbackRecaptcha pCallback) { if (ModelState.IsValid) { var loResult = RestCalls.SaveNewCallback(pCallback); return(loResult); } var loCallbackRecord = new CallbackRecordDto { id = -2 }; return(loCallbackRecord); }
public static CallbackRecordDto SaveNewCallback(CallbackRecaptcha pCallback) { var client = new RestClient(Common.ApiUrl + "/Customer/Callback"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.RequestFormat = DataFormat.Json; request.AddHeader("Authorization", "Bearer " + GetToken()); var loModel = JsonConvert.SerializeObject(pCallback); request.AddJsonBody(loModel); //var responseData = client.Execute(request).Content; var result = client.Execute(request); var loGenericResult = JsonConvert.DeserializeObject<GenericResponseModel>(result.Content); var loCustomer = new CallbackRecordDto(); if (loGenericResult != null && loGenericResult.Code == 200 && loGenericResult.Status.ToLower() == "ok") { loCustomer = JsonConvert.DeserializeObject<CallbackRecordDto>(loGenericResult.Data.ToString()); return loCustomer; } loCustomer.message = loGenericResult?.Message; return loCustomer; }