Beispiel #1
0
        public List <ApiDashboard> GetDashboards(ApiUser user, List <ApiFilter> filters)
        {
            DashboardMapper.Update(user);
            var dashboards = DashboardMapper.ConvertToApiEntitiesCollection(DashboardAdapter.GetAll($"user_id={user.Id}")).ToList();
            var filter     = "";

            foreach (var dashboard in dashboards)
            {
                filter += $"dashboard_id={dashboard.Id} OR ";
            }
            if (filter.Length > 4)
            {
                filter = filter.Substring(0, filter.Length - 4);
            }

            DashboardFilterMapper.Update(filters, dashboards);
            var tmp = DashboardFilterRelationAdapter.GetAll(filter).GroupBy(t => t.DashboardId);

            foreach (var group in tmp)
            {
                dashboards.Where(t => t.Id == group.Key).FirstOrDefault().UpdateRelations(DashboardFilterMapper.ConvertToApiEntitiesCollection(group));
            }

            return(dashboards.OrderBy(o => o.Order).ToList());
        }