Example #1
0
        public async Task <List <SiteListEntry> > GetListEntries(int listId, bool isAdmin)
        {
            if (listId == 0)
            {
                throw new CallerException("Must Pass Valid ListId");
            }

            var siteListCache = new SiteListEntryCache(Cache);

            var cacheResult = await siteListCache.GetSiteEntriesFromCache(listId, isAdmin);

            if (cacheResult != null)
            {
                return(cacheResult);
            }

            List <SiteListEntry> listOfEntries;

            using (var uow = new UnitOfWork(Context))
            {
                var repo = new SiteListEntryRepository(uow);

                listOfEntries = await repo.GetAll(isAdmin).Where(x => x.SiteListId == listId).ToListAsync();
            }

            if (listOfEntries != null)
            {
                await siteListCache.AddListEntryToCache(listId, listOfEntries, isAdmin);
            }

            return(listOfEntries);
        }
Example #2
0
        public async Task <SiteListEntry> GetListEntryById(int id, bool isAdmin)
        {
            using (var uow = new UnitOfWork(Context))
            {
                var repo = new SiteListEntryRepository(uow);

                return(await repo.GetAll(isAdmin).Where(x => x.SiteListEntryId == id).FirstOrDefaultAsync());
            }
        }