コード例 #1
0
        public async Task <List <ProfileProperty> > GetProfileProperties(bool requiredOnly, bool isAdmin)
        {
            ProfilePropertyCache profilePropertyCache = new ProfilePropertyCache(Cache);

            List <ProfileProperty> profileProperties = await profilePropertyCache.GetProfilePropertiesFromCache(requiredOnly, isAdmin);

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

            using (UnitOfWork uow = new UnitOfWork(Context))
            {
                ProfilePropertyRepository repo = new ProfilePropertyRepository(uow);

                IQueryable <ProfileProperty> query = repo.GetAll();

                if (!isAdmin)
                {
                    query = query.Where(c => c.Visibility != ProfilePropertyVisibility.Admin);
                }

                if (requiredOnly)
                {
                    query = query.Where(c => c.Required);
                }

                profileProperties = await query.ToListAsync();
            }

            await profilePropertyCache.AddProfilePropertiesToCache(profileProperties, requiredOnly, isAdmin);

            return(profileProperties);
        }
コード例 #2
0
        public async Task <ProfileProperty> GetProfileProperty(string name, bool isAdmin)
        {
            using (var uow = new UnitOfWork(Context))
            {
                var repo = new ProfilePropertyRepository(uow);

                var query = repo.GetAll().Where(c => c.Name.ToUpper() == name.ToUpper());

                if (!isAdmin)
                {
                    query = query.Where(c => c.Visibility != ProfilePropertyVisibility.Admin);
                }

                return(await query.FirstOrDefaultAsync());
            }
        }
コード例 #3
0
        public async Task <Page <ProfileProperty> > GetGrid(GridRequest gridRequest)
        {
            var data = new Page <ProfileProperty>();

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

                var query = repo.GetAll();

                var dataGridLogic = new DataGridLogic <ProfileProperty>(gridRequest, query);

                data.Records = await dataGridLogic.GetResults();

                data.PageSize         = dataGridLogic.PageSize;
                data.PageOffset       = dataGridLogic.PageOffset;
                data.TotalRecordCount = dataGridLogic.TotalRecordCount;
                data.SortExpression   = dataGridLogic.SortExpression;
            }

            return(data);
        }