示例#1
0
        public double ComputeNecessaryFee(BookCopy bookCopy, TransactionInfo bookTransInfo)
        {
            var bookInfo = _BookCopyService.GetBookInfo(bookCopy);

            if (bookInfo == null)
            {
                throw new InvalidOperationException("Book copy has no known book information.");
            }

            var section = _SectionService.GetBookSection(bookInfo);

            if (section == null)
            {
                throw new InvalidOperationException("The book does not belong to a section.");
            }

            if (DateTime.Now.Date <= bookTransInfo.ExpectedReturnDate.Date)
            {
                return(0);
            }

            return((DateTime.Now.Date - bookTransInfo.ExpectedReturnDate.Date).Days * section.LateReturningFee);
        }
 private void LongRangeReader_TagRead(object sender, string e)
 {
     try
     {
         var bookCopy = _BookCopyService.FindByLongRange(e);
         if (bookCopy.IsBorrowed == false)
         {
             var handler = UnborrowedIsGoingOut;
             if (handler != null)
             {
                 handler(this, new Models.BookCopyWithInfo
                 {
                     BookCopy = bookCopy,
                     BookInfo = _BookCopyService.GetBookInfo(bookCopy)
                 });
             }
         }
     }
     catch (Exception)
     { }
 }