Ejemplo n.º 1
0
        private async Task <UserProfileProperty> GetUserProfileProperty(int userId, int profilePropertyId, string name, bool isAdmin)
        {
            using (var uow = new UnitOfWork(Context))
            {
                var repo = new UserProfilePropertyRepository(uow);

                IQueryable <UserProfileProperty> query;

                if (profilePropertyId == 0)
                {
                    query = repo.GetAllWithEmpty(userId, isAdmin).Where(c => c.ProfilePropertyName.ToUpper() == name.ToUpper());
                }
                else
                {
                    query = repo.GetAllWithEmpty(userId, isAdmin).Where(c => c.ProfilePropertyId == profilePropertyId);
                }

                return(await query.FirstOrDefaultAsync());
            }
        }
Ejemplo n.º 2
0
        // Gets a users profile. This will return empty values for Properties the user does not fill out.
        public async Task <List <UserProfileProperty> > GetUserProfileProperties(int userId, bool isAdmin)
        {
            var cache = new UserProfilePropertyCache(Cache);

            List <UserProfileProperty> userProfileProperties = await cache.GetUserProfilePropertiesFromCache(userId, isAdmin);

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

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

                var query = repo.GetAllWithEmpty(userId, isAdmin);

                userProfileProperties = await query.ToListAsync();
            }

            await cache.AddUserProfilePropertiesToCache(userId, isAdmin, userProfileProperties);

            return(userProfileProperties);
        }