private IEnumerable <Discounts> GetAllSubscriptionDiscounts()
        {
            var entities = CacheLayer.Get <List <Discounts> >(CacheKeys.SubscriptionDiscountsCacheKey);

            if (entities != null)
            {
                return(entities.AsEnumerable());
            }

            entities = DayaxeDbContext.Discounts.Where(d => !d.IsDelete && d.PromoType == (int)Enums.PromoType.SubscriptionPromo).ToList();

            // Calculate Status and Count Uses
            entities.ForEach(item =>
            {
                item.DiscountUses = SubscriptionDiscountUsedList.Count(x => x.DiscountId == item.Id);
                item.Status       = Enums.DiscountStatus.Scheduled;

                if (item.StartDate.HasValue && item.EndDate.HasValue)
                {
                    DateTime dateNow = DateTime.UtcNow;
                    if (item.StartDate.Value <= dateNow.AddMinutes(5) && item.EndDate.Value >= dateNow.AddMinutes(-5))
                    {
                        item.Status = Enums.DiscountStatus.Active;
                    }
                    if (item.StartDate.Value < dateNow.AddMinutes(5) && item.EndDate.Value < dateNow.AddMinutes(-5))
                    {
                        item.Status = Enums.DiscountStatus.Ended;
                    }
                }
            });

            CacheLayer.Add(entities, CacheKeys.SubscriptionDiscountsCacheKey);
            return(entities.AsEnumerable());
        }
        private IEnumerable <Amenties> GetAllAmenties()
        {
            var entities = CacheLayer.Get <List <Amenties> >(CacheKeys.AmentiesCacheKey);

            if (entities != null)
            {
                return(entities.AsEnumerable());
            }
            entities = DayaxeDbContext.Amenties.ToList();
            CacheLayer.Add(entities, CacheKeys.AmentiesCacheKey);
            return(entities.AsEnumerable());
        }
        private IEnumerable <DiscountSubscriptions> GetAllDiscountSubscriptions()
        {
            var entities = CacheLayer.Get <List <DiscountSubscriptions> >(CacheKeys.DiscountSubscriptionsCacheKey);

            if (entities != null)
            {
                return(entities.AsEnumerable());
            }
            entities = DayaxeDbContext.DiscountSubscriptions.ToList();
            CacheLayer.Add(entities, CacheKeys.DiscountSubscriptionsCacheKey);
            return(entities.AsEnumerable());
        }
        private IEnumerable <SubsciptionDiscountUseds> GetAllSubscriptionDiscountUsed()
        {
            var entities = CacheLayer.Get <List <SubsciptionDiscountUseds> >(CacheKeys.SubsciptionDiscountUsedCacheKey);

            if (entities != null)
            {
                return(entities.AsEnumerable());
            }
            entities = DayaxeDbContext.SubsciptionDiscountUseds.ToList();
            CacheLayer.Add(entities, CacheKeys.SubsciptionDiscountUsedCacheKey);
            return(entities.AsEnumerable());
        }
        private IEnumerable <GiftCardBookings> GetAllGiftCardBookings()
        {
            var entities = CacheLayer.Get <List <GiftCardBookings> >(CacheKeys.GiftCardBookingCacheKey);

            if (entities != null)
            {
                return(entities.AsEnumerable());
            }
            entities = DayaxeDbContext.GiftCardBookings.ToList();
            CacheLayer.Add(entities, CacheKeys.GiftCardBookingCacheKey);
            return(entities.AsEnumerable());
        }
        private IEnumerable <CustomerCreditLogs> GetAllCustomerCreditLogs()
        {
            var entities = CacheLayer.Get <List <CustomerCreditLogs> >(CacheKeys.CustomerCreditLogsCacheKey);

            if (entities != null)
            {
                return(entities.AsEnumerable());
            }
            entities = DayaxeDbContext.CustomerCreditLogs.ToList();
            CacheLayer.Add(entities, CacheKeys.CustomerCreditLogsCacheKey);
            return(entities.AsEnumerable());
        }
        private IEnumerable <BlockedDatesCustomPrice> GetAllBlockedDatesCustomPrice()
        {
            var entities = CacheLayer.Get <List <BlockedDatesCustomPrice> >(CacheKeys.BlockedDatesCustomPricesCacheKey);

            if (entities != null)
            {
                return(entities.AsEnumerable());
            }
            entities = DayaxeDbContext.BlockedDatesCustomPrice.ToList();
            CacheLayer.Add(entities, CacheKeys.BlockedDatesCustomPricesCacheKey);
            return(entities.AsEnumerable());
        }
        private IEnumerable <CustomerInfosHotels> GetAllUserHotels()
        {
            var entities = CacheLayer.Get <List <CustomerInfosHotels> >(CacheKeys.CustomerInfosHotelsCacheKey);

            if (entities != null)
            {
                return(entities.AsEnumerable());
            }
            entities = DayaxeDbContext.CustomerInfosHotels.ToList();
            CacheLayer.Add(entities, CacheKeys.CustomerInfosHotelsCacheKey);
            return(entities.AsEnumerable());
        }
        private IEnumerable <CustomerInfoSearchCriteria> GetAllCustomerInfoSearchCriterias()
        {
            var entities = CacheLayer.Get <List <CustomerInfoSearchCriteria> >(CacheKeys.CustomerInfosSearchCriteriaCacheKey);

            if (entities != null)
            {
                return(entities.AsEnumerable());
            }
            entities = DayaxeDbContext.CustomerInfoSearchCriteria.ToList();
            CacheLayer.Add(entities, CacheKeys.CustomerInfosSearchCriteriaCacheKey);
            return(entities.AsEnumerable());
        }
        private IEnumerable <Products> GetAllProducts()
        {
            var entities = CacheLayer.Get <List <Products> >(CacheKeys.ProductsCacheKey);

            if (entities != null)
            {
                return(entities.AsEnumerable());
            }
            entities = DayaxeDbContext.Products.ToList();
            SetImagePathForProducts(ref entities);
            CacheLayer.Add(entities, CacheKeys.ProductsCacheKey);
            return(entities.AsEnumerable());
        }
        private IEnumerable <Hotels> GetAllHotels()
        {
            var entities = CacheLayer.Get <List <Hotels> >(CacheKeys.HotelsCacheKey);

            if (entities != null)
            {
                return(entities.AsEnumerable());
            }
            entities = DayaxeDbContext.Hotels.ToList();
            SetTotalTickets(ref entities);
            CacheLayer.Add(entities, CacheKeys.HotelsCacheKey);
            return(entities.AsEnumerable());
        }
        private IEnumerable <Policies> GetAllPolicies()
        {
            var entities = CacheLayer.Get <List <Policies> >(CacheKeys.PoliciesCacheKey);

            if (entities != null)
            {
                return(entities.AsEnumerable());
            }

            entities = DayaxeDbContext.Policies.Where(d => !d.IsDelete).ToList();
            CacheLayer.Add(entities, CacheKeys.PoliciesCacheKey);
            return(entities.AsEnumerable());
        }
        private IEnumerable <Subscriptions> GetAllSubscriptions()
        {
            var entities = CacheLayer.Get <List <Subscriptions> >(CacheKeys.SubscriptionsCacheKey);

            if (entities != null)
            {
                return(entities.AsEnumerable());
            }
            entities = DayaxeDbContext.Subscriptions.ToList();
            SetImagePathForSubscription(ref entities);
            CacheLayer.Add(entities, CacheKeys.SubscriptionsCacheKey);
            return(entities.AsEnumerable());
        }
        private IEnumerable <Discounts> GetAllDiscounts()
        {
            var entities = CacheLayer.Get <List <Discounts> >(CacheKeys.DiscountsCacheKey);

            if (entities != null)
            {
                return(entities.AsEnumerable());
            }

            entities = DayaxeDbContext.Discounts.Where(d => !d.IsDelete && d.PromoType != (int)Enums.PromoType.SubscriptionPromo).ToList();

            // Calculate Status and Count Uses
            entities.ForEach(item =>
            {
                int discountUsed;
                if (item.IsAllProducts)
                {
                    discountUsed = DiscountBookingList.Count(x => x.DiscountId == item.Id);
                }
                else
                {
                    var discountHotels = DiscountProductList.Where(dh => dh.DiscountId == item.Id).ToList();
                    var uses           = (from p in discountHotels
                                          join p1 in DiscountBookingList
                                          on new { p.DiscountId, p.ProductId } equals new { p1.DiscountId, p1.ProductId }
                                          select p1);
                    discountUsed = uses.Count();
                }
                item.DiscountUses = discountUsed;
                item.Status       = Enums.DiscountStatus.Scheduled;

                if (item.StartDate.HasValue && item.EndDate.HasValue)
                {
                    DateTime dateNow = DateTime.UtcNow.ToLosAngerlesTime().Date;
                    if (item.StartDate.Value.Date <= dateNow.Date && item.EndDate.Value.Date >= dateNow.Date)
                    {
                        item.Status = Enums.DiscountStatus.Active;
                    }
                    if (item.StartDate.Value.Date < dateNow.Date && item.EndDate.Value.Date < dateNow.Date)
                    {
                        item.Status = Enums.DiscountStatus.Ended;
                    }
                }
            });

            CacheLayer.Add(entities, CacheKeys.DiscountsCacheKey);
            return(entities.AsEnumerable());
        }
Example #15
0
 public void ResetCache()
 {
     Helper.ResetClientCache();
     CacheLayer.ClearAll();
 }