Beispiel #1
0
        /// <summary>
        /// This method returns earliest check-in date for a given hotel id.
        /// </summary>
        public string Get_Earliest_CheckInDate_For_HotelId(long hotel_id)
        {
            try
            {
                var earliestCheckInDate = string.Empty;
                var allBookingIds       = RDM.Get_AllBookingIds_For_HotelId(hotel_id.ToString());

                if (null != allBookingIds && allBookingIds.Count() > 0)
                {
                    var allCheckInDate = RDM.Get_AllCheckInDate_For_BookingIds(allBookingIds);
                    if (null != allCheckInDate && allCheckInDate.Count() > 0)
                    {
                        earliestCheckInDate = allCheckInDate.Max().ToString();
                    }
                }
                return(earliestCheckInDate);
            }
            catch (FormatException ex1)
            {
                throw new Exception(C.DATA_CONVERSION_EXP + ex1.Message);
            }
            catch (Exception ex2)
            {
                throw new Exception(ex2.Message);
            }
        }
Beispiel #2
0
        /// <summary>
        /// This method returns total tax ABC owes in the system.
        /// </summary>
        public decimal Get_TotalTax_For_TheSystem()
        {
            try
            {
                decimal       totalTax      = 0;
                List <string> bookingIdList = new List <string>();
                Dictionary <string, decimal> bookingIdWithTotalPrice = new Dictionary <string, decimal>();

                var hotel_ids = RDM.Get_HotelIds_For_TaxableHotels();

                foreach (var hotel in hotel_ids)
                {
                    var booking_ids = RDM.Get_AllBookingIds_For_HotelId(hotel);
                    bookingIdList = RDM.Convert_RedisList_To_StringList(booking_ids);

                    bookingIdWithTotalPrice = RDM.Get_TotalPrice_For_BookingIds(bookingIdList);

                    foreach (var eachTotalPrice in bookingIdWithTotalPrice)
                    {
                        decimal eachTax = Math.Round((eachTotalPrice.Value * C.TAX_RATE), 2, MidpointRounding.AwayFromZero);
                        totalTax += eachTax;
                    }

                    bookingIdList.Clear();
                    bookingIdWithTotalPrice.Clear();
                }
                return(totalTax);
            }
            catch (ArgumentException ex1)
            {
                throw new Exception(C.ARGUMENT_EXP + ex1.Message);
            }
            catch (Exception ex2)
            {
                throw new Exception(ex2.Message);
            }
        }