Ejemplo n.º 1
0
        private IQueryable <Project> Filter(UserSessionModel currentUser, IQueryable <Project> query, ProjectExportParameter exportParam)
        {
            if (exportParam == null)
            {
                return(query);
            }

            if (exportParam.ProjectId != 0)
            {
                query = query.Where(s => s.ProjectId == exportParam.ProjectId);
            }

            if (exportParam.Filter != null)
            {
                Filter filter = JsonConvert.DeserializeObject <Filter>(exportParam.Filter);
                query = Filter(currentUser, query, filter);
            }

            if (exportParam.Sort != null)
            {
                List <Sort> sort = JsonConvert.DeserializeObject <List <Sort> >(exportParam.Sort);
            }

            return(query);
        }
Ejemplo n.º 2
0
 public IQueryable <Project> QueryProjectsExportViewableByParam(UserSessionModel user, ProjectExportParameter exportparam)
 {
     return(QueryProjectsExportViewableByParam(user, exportparam, false));
 }
Ejemplo n.º 3
0
        public IQueryable <Project> QueryProjectsExportViewableByParam(UserSessionModel user, ProjectExportParameter exportparam, bool noPaging)
        {
            IQueryable <Project> query;

            //specifc override for person's permissions / daikin user status
            query = QueryProjectsExportViewableByUser(user, exportparam);

            query = Filter(user, query, exportparam);

            if (!noPaging)
            {
                if (exportparam != null && exportparam.ReturnTotals)
                {
                    exportparam.TotalRecords = query.Count();
                }

                //query = Paging(user, query, exportparam);
            }

            return(query);
        }
Ejemplo n.º 4
0
        private IQueryable <Project> QueryProjectsExportViewableByUser(UserSessionModel user, ProjectExportParameter exportParam = null)
        {
            IQueryable <Project> query;

            if (user == null)
            {
                query = this.Projects;
            }
            else
            {
                // Does user have rights to see projects in his/her own group ?
                bool inclusive = user.HasAccess(SystemAccessEnum.ViewProjectsInGroup);

                query = from project in this.Projects
                        join owner in this.Context.Users on project.OwnerId equals owner.UserId
                        join groups in this.QueryGroupsViewableBelowByGroupId(user.GroupId.Value, inclusive) on owner.GroupId equals groups.GroupId into Lg
                        from groups in Lg.DefaultIfEmpty()

                        // Return any in group tree or the users own projects
                        where (owner.GroupId == groups.GroupId) || project.OwnerId == user.UserId
                        select project;

                // Get al projects which have been transferred
                var transfersQuery =
                    from project in this.Projects
                    join transfers in this.Context.ProjectTransfers on new { user.UserId, project.ProjectId } equals new { transfers.UserId, transfers.ProjectId }
                select project;

                // join the two
                query = query.Union(transfersQuery);

                bool removeDeletedProjects = false;

                //if user cannot see deleted projects to start with, filter them out
                if (!user.HasAccess(SystemAccessEnum.UndeleteProject))
                {
                    removeDeletedProjects = true;
                }
                else
                {
                    //I have permission, and a search project, and I chose to NOT show deleted projects
                    if (exportParam != null && exportParam.ShowDeletedProjects == false)
                    {
                        removeDeletedProjects = true;
                    }
                }

                if (removeDeletedProjects)
                {
                    query = query.Where(p => p.Deleted == false);
                }
            }

            return(query);
        }