Ejemplo n.º 1
0
        public static async Task <CommonDropdowns> FillAsync(SqlConnection connection, int orgId, int responsibilities)
        {
            var result = new CommonDropdowns();

            result.Activities = await new Activities()
            {
                OrgId = orgId, IsActive = true
            }.ExecuteAsync(connection);

            result.Applications = await new AppSelect()
            {
                OrgId = orgId
            }.ExecuteAsync(connection);
            var allProjects = await new AllProjects()
            {
                OrgId = orgId
            }.ExecuteAsync(connection);

            result.AllProjects = allProjects.ToLookup(row => row.ApplicationId, row => row.ToSelectListItem());
            result.Sizes       = await new SizeSelect()
            {
                OrgId = orgId
            }.ExecuteAsync(connection);
            result.CloseReasons = await new CloseReasonSelect().ExecuteAsync(connection);
            result.Milestones   = await new MilestoneSelect()
            {
                OrgId = orgId
            }.ExecuteAsync(connection);
            result.Labels = await new Labels()
            {
                OrgId = orgId, IsActive = true
            }.ExecuteAsync(connection);
            var allModels = await new DataModels()
            {
                OrgId = orgId, IsActive = true
            }.ExecuteAsync(connection);

            result.AllDataModels = allModels.ToLookup(row => row.ApplicationId, row => new SelectListItem()
            {
                Value = row.Id.ToString(), Text = row.Name
            });
            return(result);
        }
Ejemplo n.º 2
0
        public static async Task <CommonDropdowns> FillAsync(SqlConnection connection, int orgId)
        {
            var result = new CommonDropdowns();

            // org-scoped items
            result.Teams = await new TeamSelect()
            {
                OrgId = orgId
            }.ExecuteAsync(connection);
            result.Activities = await new Activities()
            {
                OrgId = orgId, IsActive = true
            }.ExecuteAsync(connection);
            result.Sizes = await new SizeSelect()
            {
                OrgId = orgId
            }.ExecuteAsync(connection);
            result.CloseReasons = await new CloseReasonSelect().ExecuteAsync(connection);
            result.Labels       = await new Labels()
            {
                OrgId = orgId, IsActive = true
            }.ExecuteAsync(connection);

            var allApps = await new Applications()
            {
                OrgId = orgId, IsActive = true
            }.ExecuteAsync(connection);

            result.AllApps = allApps.ToLookup(row => row.TeamId ?? 0, row => new SelectListItem()
            {
                Value = row.Id.ToString(), Text = row.Name
            });

            // app-scoped items
            var allProjects = await new AllProjects()
            {
                OrgId = orgId
            }.ExecuteAsync(connection);

            result.ProjectsByApp       = allProjects.ToLookup(row => row.ApplicationId, row => row.ToSelectListItem());
            result.ProjectsWithoutApps = allProjects.Where(row => row.ApplicationId == 0).ToLookup(row => row.TeamId, row => row.ToSelectListItem());
            result.ProjectsByTeam      = allProjects.ToLookup(row => row.TeamId, row => row.ToSelectListItem());

            var allMilestones = await new AllMilestones()
            {
                OrgId = orgId
            }.ExecuteAsync(connection);

            result.AllMilestones    = allMilestones.Select(item => item.ToSelectListItem());
            result.MilestonesByTeam = allMilestones.ToLookup(row => row.TeamId ?? 0, row => row.ToSelectListItem());

            var allModels = await new DataModels()
            {
                OrgId = orgId, IsActive = true
            }.ExecuteAsync(connection);

            result.AllDataModels = allModels.ToLookup(row => row.ApplicationId, row => new SelectListItem()
            {
                Value = row.Id.ToString(), Text = row.Name
            });

            return(result);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> OnGetAsync()
        {
            using (var cn = Data.GetConnection())
            {
                var redirect = await GetRedirectAsync(cn);

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

                await InitializeAsync(cn);

                var query = GetQuery();
                if (query != null)
                {
                    WorkItems = await query.ExecuteAsync(cn);

                    ItemsInPastMilestone = WorkItems.Where(wi => wi.MilestoneDate < DateTime.Today).ToArray();
                    if (ItemsInPastMilestone.Any())
                    {
                        var teamId = CurrentOrgUser.CurrentTeamId ?? 0;
                        if (teamId != 0)
                        {
                            NextSoonestMilestone = await Milestone.GetSoonestNextAsync(cn, teamId) ?? await Milestone.CreateNextAsync(cn, teamId);
                        }
                    }

                    int[] itemIds     = WorkItems.Select(wi => wi.Id).ToArray();
                    var   labelsInUse = await new LabelsInUse()
                    {
                        WorkItemIds = itemIds, OrgId = OrgId
                    }.ExecuteAsync(cn);
                    SelectedLabels = labelsInUse.ToLookup(row => row.WorkItemId);
                    LabelFilter    = labelsInUse.GroupBy(row => row.Id);

                    var comments = await new Comments()
                    {
                        OrgId = OrgId, ObjectIds = itemIds, ObjectType = ObjectType.WorkItem
                    }.ExecuteAsync(cn);
                    Comments = comments.ToLookup(row => row.ObjectId);

                    WorkDays = await new WorkDays()
                    {
                        OrgId = OrgId
                    }.ExecuteAsync(cn);

                    if (ClosedItemGrouping != null)
                    {
                        var closedItems = await new ClosedWorkItems()
                        {
                            OrgId = OrgId, AppId = CurrentOrgUser.CurrentAppId
                        }.ExecuteAsync(cn);
                        ClosedItems = closedItems.ToLookup(row => ClosedItemGrouping(row));
                    }

                    var milestoneIds     = WorkItems.GroupBy(row => row.MilestoneId).Select(grp => grp.Key).ToArray();
                    var milestoneMetrics = await new MilestoneMetrics()
                    {
                        OrgId = OrgId, MilestoneIds = milestoneIds
                    }.ExecuteAsync(cn);
                    MilestoneMetrics = milestoneMetrics.ToDictionary(row => row.Id);
                }

                Dropdowns = await CommonDropdowns.FillAsync(cn, OrgId);

                await OnGetInternalAsync(cn);

                OnGetInternal(cn);
            }

            return(Page());
        }