public async Task<Loan> LoanDocument(Loan loan)
 {
     try
     {
         var entity = this.ctx.Loans.Add(loan);
         await this.ctx.SaveChangesAsync();
         return entity;
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        public async Task<Loan> SetProperties(ILoanDataService loanDataService, int documentId, int userId, DateTime lentDate)
        {
            var loan = new Loan()
            {
                CreateDate = DateTime.Now,
                CreateUser = Constants.DefaultUser,
                LoanDate = lentDate,
                DueData = lentDate.AddDays(Constants.BooksPropertyForLoan.LoanDays),
                DocumentId = documentId,
                UserId = userId
            };

            return await loanDataService.LoanDocument(loan);
        }
 private async Task GetReturnedDate(Loan loan)
 {
     Console.WriteLine(Display.IntroduzceReturnDate);
     var value = Console.ReadLine();
     DateTime returnDate;
     if(DateTime.TryParse(value, out returnDate))
     {
         await CheckReturnedWithLoan(loan, returnDate);
     }
     else
     {
         Console.WriteLine(Exceptions.DateException);
         await GetReturnedDate(loan);
     }
 }
        private async Task HasBookLent(Loan loan)
        {
            var hasLent = await this.loanService.HasBookLent(user.Id, loan.DocumentId);
            if (!hasLent)
            {
                Console.WriteLine(Exceptions.NotLentBookException);
                await GetBookTitle();
            }

            await GetReturnedDate(loan);
        }
 private async Task HasFineForReturningLate(Loan loan, DateTime returnDate)
 {
     if (loan.DueData < returnDate)
     {
         await this.userService.SetFine(user.Id);
         Console.WriteLine(Display.NotReturnOnTime);
         await this.fineManager.AskPaidFine();
     }
 }
 private async Task ReturnBookToLibrary(Loan loan, DateTime returnDate)
 {
     await this.loanService.ReturnBook(loan.DocumentId, returnDate);
     Console.WriteLine(Display.BookIsAvailable, loan.Documents.Title);
     await HasFineForReturningLate(loan, returnDate);
 }
        private async Task CheckReturnedWithLoan(Loan loan, DateTime returnDate)
        {
            if (loan.LoanDate > returnDate)
            {
                Console.WriteLine(Exceptions.ReturnLoanDateException);
                await GetReturnedDate(loan);
            }

            await ReturnBookToLibrary(loan, returnDate);
        }