Example #1
0
 public HttpResponseMessage GetLoans([FromUri] int?from = null, [FromUri] int?amount = null)
 {
     try
     {
         LoanSupportRequests loans    = LoanManager.GetLoans(from, amount);
         List <LoansDto>     loansDto = Converters.Convert(loans);
         return(Request.CreateResponse(HttpStatusCode.OK, loansDto));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"Failed to load loans"));
     }
 }
Example #2
0
 public static LoanSupportRequests GetLoans(int?from, int?amount)
 {
     try
     {
         LoanSupportRequests loans = LoanDataManager.GetAllLoans(from, amount);
         return(loans);
     }
     catch (Exception ex)
     {
         _logger.Debug($"Failed to load loans.", ex);
         throw;
     }
 }
Example #3
0
        public static LoanSupportRequests TableToLoan(DataTable table)
        {
            if (table == null)
            {
                return(null);
            }
            LoanSupportRequests loans = new LoanSupportRequests();
            var loanList = table.AsEnumerable().GroupBy(row => DataRowHelper.GetValue <int>(row, Tables.LoanSupportRequest.Id.Name),
                                                        (key, group) => RowToLoan(group));

            loans.AddRange(loanList.ToList());
            return(loans);
        }
Example #4
0
 public static List <LoansDto> Convert(LoanSupportRequests loans)
 {
     if (loans != null)
     {
         List <LoansDto> loansDto = new List <LoansDto>();
         foreach (LoanSupportRequest loan in loans)
         {
             LoansDto item = ConvertToDto(loan);
             loansDto.Add(item);
         }
         return(loansDto);
     }
     return(null);
 }