コード例 #1
0
        public PenaltyDto ReturnBook(string Username, string BookName, DateTime returnDate) 
        {
            BookingDto NewBookingDto = this.GetBooking(Username, BookName);
            BookingEntity bookingEntity = new BookingEntity();

            bookingEntity.BookId = NewBookingDto.BookId;
            bookingEntity.EndBookingDate = NewBookingDto.EndBookingDate;
            bookingEntity.LibraryAppUsername = NewBookingDto.LibraryAppUsername;
            bookingEntity.StartBookingDate = NewBookingDto.StartBookingDate;
            _dblibrary.ReturnBook(bookingEntity);

            if (NewBookingDto.EndBookingDate < returnDate)
            {
                PenaltyEntity penalty = new PenaltyEntity();
                penalty.BookingId = bookingEntity.Id;
                penalty.BookId = bookingEntity.BookId;
                penalty.LibraryAppUsername = bookingEntity.LibraryAppUsername;
                _dblibrary.CreatePenalty(penalty);

                PenaltyDto penaltyDto = new PenaltyDto();
                penaltyDto.Id = penalty.Id;
                penaltyDto.BookId = penalty.BookId;
                penaltyDto.BookingId = penalty.BookingId;
                penaltyDto.LibraryAppUsername = penalty.LibraryAppUsername;
                return(penaltyDto);
            }
            else 
            {
                _dblibrary.ReturnBook(bookingEntity);             
                return null;
            }
        }
コード例 #2
0
 public bool CreatePenalty(PenaltyEntity penalty) 
 {
     int idCounter = 1;
     foreach (PenaltyEntity penaltyItem in _penaltyTable)
     {
         idCounter++;
     }
     penalty.Id = idCounter;
     _penaltyTable.Add(penalty);
     return true;
 }