コード例 #1
0
        public async Task <IActionResult> SubmitLoanRequest(DTOs.LoanRequest req)
        {
            ILoan loan = new Loan(req.LenderId, req.BorrowerId, req.Message, req.StartDate, req.EndDate, req.AddressId, req.OwnedBookIds, LoanStatus.Requested);
            await _loanRepo.AddLoanAsync(loan);

            await _loanRepo.SaveChangesAsync();

            return(Ok());
        }
コード例 #2
0
        public async Task <ActionResult> PostLoan(ExpenseService.DataAccess.Model.Loan loan)
        {
            var newLoan = Mapper.MapLoan(loan);

            _ = _repo.AddLoanAsync(newLoan);

            await _repo.SaveAsync();

            return(CreatedAtAction("GetLoan", new { id = loan.Id }, loan));
        }
コード例 #3
0
 public async Task <IActionResult> InsertLoanAsync([FromBody] Loan loan)
 {
     try
     {
         return(StatusCode(StatusCodes.Status200OK, await _loan.AddLoanAsync(loan)));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex.Message);
         _logger.LogError(ex.StackTrace);
         return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
     }
 }
コード例 #4
0
        public async Task <ActionResult> PostLoan(ApiLoan loan)
        {
            try
            {
                var resource = new CoreLoan
                {
                    LoanId           = loan.LoanId,
                    Deposit          = loan.Deposit,
                    MonthlyAmountDue = loan.MonthlyAmountDue,
                    PaymentDueDate   = loan.PaymentDueDate,
                    TotalAmountDue   = loan.TotalAmountDue,
                    User             = (await _userRepo.GetUserById(loan.UserId)),
                    Union            = (await _unionRepo.GetCreditUnionById(loan.UnionId))
                };

                await _repo.AddLoanAsync(resource);

                return(Ok("Loan added!"));
            }
            catch (Exception e)
            {
                return(BadRequest($"Error! {e.Message}"));
            }
        }