Beispiel #1
0
        public async Task <LoanDto> Handle(EndLoanCommand request, CancellationToken cancellationToken)
        {
            var loan = await _context.Loans
                       .OrderByDescending(x => x.Id)
                       .Include(l => l.Friend)
                       .Include(l => l.Game)
                       .FirstOrDefaultAsync(l => l.FriendId == request.FriendId && l.GameId == request.GameId);

            if (loan == null)
            {
                _notification.AddNotification("Loan", "This loan does not exist");
                return(null);
            }

            loan.EndLoan();

            await _context.Commit();

            return(_mapper.Map <LoanDto>(loan));
        }
Beispiel #2
0
 public async Task <IActionResult> EndLoan(EndLoanCommand command)
 {
     return(Ok(await Mediator.Send(command)));
 }