/**Returns the number of consecutive days the dvd_info is available, starting from the supplied date*/
        public int getDaysAvailableFromDate(DvdInfo dvd, DateTime startDate)
        {
            int days = -1;

            if (fullCopiesAvailable(dvd, startDate))
            {
                //there is at least 1 copy that is available for the full 14 days, no more checks are needed and the max number of days can be returned
                days = 14;
            }
            else
            {
                //all copies have some rent or reservations in the next 2 weeks, check their availability in detail

                Dictionary <int, DateTime> unavailableDatesMap = new Dictionary <int, DateTime>();

                //get all orderlines for copies that have some orderlines in the next 2 weeks
                List <OrderLine> orders = new OrderLineDAO().getAllByDvdAndStartdate(dvd, startDate);           //Throws NoRecordException

                foreach (OrderLine order in orders)
                {
                    if (!unavailableDatesMap.ContainsKey(order.dvdCopy.dvd_copy_id))
                    {
                        //set the default availability at 2 weeks from now
                        unavailableDatesMap.Add(order.dvdCopy.dvd_copy_id, order.startdate);
                    }
                    if (unavailableDatesMap.ContainsKey(order.dvdCopy.dvd_copy_id))
                    {
                        //if the order for the copy is unavailable sooner, add that one to the dictionary
                        if (order.startdate < unavailableDatesMap[order.dvdCopy.dvd_copy_id] && order.startdate > DateTime.Today)
                        {
                            unavailableDatesMap[order.dvdCopy.dvd_copy_id] = order.startdate;
                        }
                    }
                }

                //we now have a dictionary with the copies and the first date on which they'll be UNavailable again
                foreach (DateTime date in unavailableDatesMap.Values)
                {
                    //only allow orderLines that start after the supplied date
                    if (date > startDate)
                    {
                        if ((date - startDate).Days > days)
                        {
                            days = (date - startDate).Days;
                        }
                    }
                }
            }
            return(days);
        }
        /**Returns a dictionary with dvd_copy_id, List of dates where the copy is NOT available.*/
        public Dictionary <int, List <DateTime> > getAllUnavailableDaysPerCopyForDvdInfo(DvdInfo dvd, DateTime startdate)
        {
            Dictionary <int, List <DateTime> > dicCopyUnavailableDates = new Dictionary <int, List <DateTime> >();

            try
            {
                List <OrderLine> orders = new OrderLineDAO().getAllByDvdAndStartdate(dvd, startdate);           //Throws NoRecordException

                foreach (OrderLine order in orders)
                {
                    //add the copy to the list if needed
                    if (!dicCopyUnavailableDates.ContainsKey(order.dvdCopy.dvd_copy_id))
                    {
                        List <DateTime> bezettemomenten = new List <DateTime>();
                        dicCopyUnavailableDates.Add(order.dvdCopy.dvd_copy_id, bezettemomenten);
                    }

                    if (dicCopyUnavailableDates.ContainsKey(order.dvdCopy.dvd_copy_id))
                    {
                        for (int i = 0; i < 14; i++)
                        {
                            DateTime tempDate = DateTime.Now.Date.AddDays(i);
                            if (tempDate >= order.startdate && tempDate <= order.enddate)
                            {
                                if (!dicCopyUnavailableDates[order.dvdCopy.dvd_copy_id].Contains(tempDate))
                                {
                                    dicCopyUnavailableDates[order.dvdCopy.dvd_copy_id].Add(tempDate);
                                }
                            }
                        }
                    }
                }
            }
            catch (NoRecordException ex)
            {
            }

            return(dicCopyUnavailableDates);
        }