Exemplo n.º 1
0
        private IQueryable <Board> Where(string role, IDictionary <string, string> @params)
        {
            var queries = @params.ToObject <BoardQuery>();

            // get all the boards if user is admin
            if (role == DefaultRole.Admin)
            {
                return(Where(x => x.EntityStatus == EntityStatus.Activated));
            }

            // get the involved boards of the user
            if (!string.IsNullOrEmpty(queries.UserId))
            {
                var userId = Guid.Parse(queries.UserId);
                return(_boardUserService.Include(x => x.Board)
                       .Where(x => x.EntityStatus == EntityStatus.Activated && x.UserId == userId)
                       .Select(x => x.Board)
                       .Where(x => x.EntityStatus == EntityStatus.Activated));
            }

            return(Where(x => x.EntityStatus == EntityStatus.Activated));
        }