public async Task <object> GetAllLoans() { try { var result = dataContext.loans.Select(x => new Loans { AmountRequested = x.AmountRequested, Email = x.Email, FirstName = x.FirstName, LastName = x.LastName, LoanDocument = x.LoanDocument, Location = x.Location, PhoneNumber = x.PhoneNumber, Purpose = x.Purpose, Repaymentsource = x.Repaymentsource, Tenor = x.Tenor, }); var LoanList = new LoansListDTO { loan = result.ToList() }; res.Data = LoanList; res.Message = "List of Loans"; res.Success = true; return(res); } catch (Exception ex) { throw; } }
public async Task <object> GetLoanByUserId(Guid UserId) { try { var result = dataContext.loans.Where(x => x.UserId == UserId.ToString()).Include(p => p.LoanDocument).AsQueryable().Select(x => new Loans { AmountRequested = x.AmountRequested, FirstName = x.FirstName, Email = x.Email, LastName = x.LastName, LoanDocument = x.LoanDocument, Location = x.Location, PhoneNumber = x.PhoneNumber, Purpose = x.Purpose, Repaymentsource = x.Repaymentsource, Tenor = x.Tenor, UserId = x.UserId }); var loanList = new LoansListDTO { loan = result.ToList() }; res.Data = loanList; res.Message = "List of Loans For this user found"; res.Success = true; return(res); } catch (Exception ex) { throw; } }