Exemple #1
0
        /// <summary>
        /// This method returns top n (eg. n = 5) expensive bookings.
        /// </summary>
        public List <KeyValuePair <string, decimal> > Get_FiveMostExpensiveBookings(int topN = C.LIMIT)
        {
            try
            {
                Dictionary <string, decimal> bookingIdWithTotalPrice = RDM.Get_TotalPrice_For_BookingIds(RDM.Get_AllBookingIds());

                if (null != bookingIdWithTotalPrice && bookingIdWithTotalPrice.Count() >= topN)
                {
                    var topN_BookingIdWithTotalPrice = (from dic in bookingIdWithTotalPrice orderby dic.Value descending select dic).Take(topN).ToList();
                    return(topN_BookingIdWithTotalPrice);
                }
                else
                {
                    return(null);
                }
            }
            catch (FormatException ex1)
            {
                throw new Exception(C.DATA_CONVERSION_EXP + ex1.Message);
            }
            catch (Exception ex2)
            {
                throw new Exception(ex2.Message);
            }
        }