public Charge Add(int idUser, Charge charge) { var request = new AddChargeRequest(); request.IdUser = idUser; request.Charge = charge; var response = HttpPost <AddChargeRequest>("api/Charge/Add", request, MediaType.Json); return(response.Charge); }
public AddChargeResponse Add(AddChargeRequest request) { try { var response = new AddChargeResponse(); var bc = new ChargeComponent(); response.Result = bc.Add(request.IdUser, request.Charge); return(response); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, // UNPROCESSABLE ENTITY ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }