コード例 #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 RegisterBooking(BookingEntity newBookingEntity) 
 {
     int idCounter = 1;
     foreach (BookingEntity booking in _bookingTable)
     {
         idCounter++;
     }
     newBookingEntity.Id = idCounter;
     _bookingTable.Add(newBookingEntity);
     return true;
 }
コード例 #3
0
        public void RegisterBooking(BookingDto NewBookingDto)
        {
            //Console.ForegroundColor = ConsoleColor.DarkYellow;
            //Console.WriteLine("LibraryService - Reservando libro para su préstamo \n");
            //Console.ForegroundColor = ConsoleColor.White;
            
            BookingEntity bookingEntity = new BookingEntity();

            bookingEntity.BookId = NewBookingDto.BookId;
            bookingEntity.EndBookingDate = NewBookingDto.EndBookingDate;
            bookingEntity.LibraryAppUsername = NewBookingDto.LibraryAppUsername;
            bookingEntity.StartBookingDate = NewBookingDto.StartBookingDate;
            _dblibrary.RegisterBooking(bookingEntity);
        }
コード例 #4
0
 public void ReturnBook(BookingEntity booking) 
 {
     booking.UserReturnDate = DateTime.Today;
 }