Ejemplo n.º 1
0
        public void TestGetEventListingAccess()
        { //A test to retrieve a single listing by ID from the ItemListing table.
            ItemListingDetails details = BookingAccessor.GetItemListingDetails(itemID);
            int expected = 1234;

            Assert.AreEqual(expected, details.Price);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Pat Banks
        /// Created: 2015/03/11
        ///
        /// Retrieves Event Listing information for the one selected item listing
        /// Information is human readable with data from joined tables
        /// </summary>
        /// <param name="itemListID">ItemList ID matching an ItemListingDetails record</param>
        /// <returns>an ItemListingDetails containing the item listing information</returns>
        public ItemListingDetails RetrieveItemListingDetailsList(int itemListID)
        {
            var    now = DateTime.Now;
            double cacheExpirationTime = 5;

            try
            {
                if (DataCache._currentItemListingDetailsList == null)
                {
                    return(BookingAccessor.GetItemListingDetails(itemListID));
                }
                //check time. If less than 5 min, return event from cache
                if (now > DataCache._ItemListingDetailsListTime.AddMinutes(cacheExpirationTime))
                {
                    //get event from DB
                    var requestedEvent = BookingAccessor.GetItemListingDetails(itemListID);
                    return(requestedEvent);
                }
                else
                {
                    //get event from cached list
                    var list = DataCache._currentItemListingDetailsList;
                    ItemListingDetails requestedEvent = new ItemListingDetails();
                    requestedEvent = list.Where(e => e.ItemListID == itemListID).FirstOrDefault();

                    if (requestedEvent != null)
                    {
                        return(requestedEvent);
                    }
                    throw new ApplicationException("Event not found.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }