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")); } }
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; } }
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); }
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); }