Exemple #1
0
        public bool AddNewRental(Book book, Customer user)
        {
            Rental rental;

            DateTime dateRented = DateTime.Now;
            DateTime dateDue    = dateRented.AddDays(14);

            rental = new Rental()
            {
                CustomerID = user.CustomerID,
                DateRented = dateRented,
                DateDue    = dateDue,
                LateFee    = dailyLateFee
            };

            try
            {
                if (RentalAccessor.InsertRental(rental, book.ISBN))
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(false);
        }
Exemple #2
0
        public Rental GetRentalByCustomerID(int customerID, string isbn)
        {
            try
            {
                var rental = RentalAccessor.FetchRentalByCustomerID(customerID, isbn);

                return(rental);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #3
0
        public bool DeleteRental(Book book, Customer user)
        {
            try
            {
                if (RentalAccessor.InactivateRental(book, user))
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(false);
        }
Exemple #4
0
        public List <Rental> GetRentalListByCustomerID(int customerID)
        {
            try
            {
                var rentalList = RentalAccessor.FetchRentalListByCustomerID(customerID);

                if (rentalList.Count > 0)
                {
                    return(rentalList);
                }
                else
                {
                    throw new ApplicationException("There were no records found.");
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #5
0
        public List <Rental> GetRentalList(Active group = Active.active)
        {
            try
            {
                var rentalList = RentalAccessor.FetchRentalList(group);

                if (rentalList.Count > 0)
                {
                    return(rentalList);
                }
                else
                {
                    throw new ApplicationException("There were no records found.");
                }
            }
            catch (Exception)
            {
                throw;
            }
        }