Exemplo n.º 1
0
 public HttpResponseMessage InsertLoans([FromBody] LoansDto loanDto)
 {
     try
     {
         LoanSupportRequest loan = Converters.Convert(loanDto);
         if (!ValidateModel.IsValid(new List <object>()
         {
             loan
         }))
         {
             return(Request.CreateResponse(HttpStatusCode.BadRequest, ValidateModel.ModelsResults));
         }
         LoanManager.InsertLoan(loan);
         return(Request.CreateResponse(HttpStatusCode.OK, loan.Id));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"Failed to insert the loan, {ex.Message}"));
     }
 }