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); } }
public bool PayPenalty(int id) { PenaltyEntity penalty = _penaltyTable.Where(x => x.Id == id).First(); _penaltyTable.Remove(penalty); return(true); }
public PenaltyDto GetPenalty(string username, string bookTitle) { PenaltyEntity penaltyEntity = _dblibrary.GetPenalty(username, bookTitle); PenaltyDto PenaltyDto = new PenaltyDto(); PenaltyDto.BookId = penaltyEntity.BookId; PenaltyDto.BookingId = penaltyEntity.BookingId; PenaltyDto.Id = penaltyEntity.Id; PenaltyDto.LibraryAppUsername = penaltyEntity.LibraryAppUsername; return(PenaltyDto); }
public bool CreatePenalty(PenaltyEntity penalty) { int idCounter = 1; foreach (PenaltyEntity penaltyItem in _penaltyTable) { idCounter++; } penalty.Id = idCounter; _penaltyTable.Add(penalty); return(true); }