コード例 #1
0
        public async Task TestAddUpdatDelete()
        {
            ProjectManagementMilestoneModule ProjectManagementMilestoneMod = new ProjectManagementMilestoneModule();
            ProjectManagementMilestone       milestone = await ProjectManagementMilestoneMod.Milestone.Query().GetEntityById(1);

            ProjectManagementProject project = await ProjectManagementMilestoneMod.Project.Query().GetEntityById(1);

            RollupTaskToMilestoneView rollup = await ProjectManagementMilestoneMod.Milestone.Query().GetTaskToMilestoneRollupViewById(milestone.MilestoneId);

            ProjectManagementMilestoneView view = new ProjectManagementMilestoneView()
            {
                MilestoneName      = "fluent code refactor",
                ProjectId          = project.ProjectId,
                ProjectName        = project.ProjectName,
                EstimatedHours     = rollup.EstimatedHours,
                EstimatedDays      = rollup.EstimatedDays,
                ActualDays         = rollup.ActualDays,
                ActualHours        = rollup.ActualHours,
                ActualStartDate    = rollup.ActualStartDate,
                ActualEndDate      = rollup.ActualEndDate,
                EstimatedStartDate = rollup.EstimatedStartDate,
                EstimatedEndDate   = rollup.EstimatedEndDate,
                Cost = rollup.Cost,
                Wbs  = "2.1"
            };
            NextNumber nnNextNumber = await ProjectManagementMilestoneMod.Milestone.Query().GetNextNumber();

            view.MileStoneNumber = nnNextNumber.NextNumberValue;

            ProjectManagementMilestone projectManagementMilestone = await ProjectManagementMilestoneMod.Milestone.Query().MapToEntity(view);

            ProjectManagementMilestoneMod.Milestone.AddProjectManagementMilestone(projectManagementMilestone).Apply();

            ProjectManagementMilestone newProjectManagementMilestone = await ProjectManagementMilestoneMod.Milestone.Query().GetEntityByNumber(view.MileStoneNumber);

            Assert.NotNull(newProjectManagementMilestone);

            newProjectManagementMilestone.MilestoneName = "MS Name Update";

            ProjectManagementMilestoneMod.Milestone.UpdateProjectManagementMilestone(newProjectManagementMilestone).Apply();

            ProjectManagementMilestoneView updateView = await ProjectManagementMilestoneMod.Milestone.Query().GetViewById(newProjectManagementMilestone.MilestoneId);

            Assert.Same(updateView.MilestoneName, "MS Name Update");
            ProjectManagementMilestoneMod.Milestone.DeleteProjectManagementMilestone(newProjectManagementMilestone).Apply();
            ProjectManagementMilestone lookupProjectManagementMilestone = await ProjectManagementMilestoneMod.Milestone.Query().GetEntityById(view.MilestoneId);

            Assert.Null(lookupProjectManagementMilestone);
        }
コード例 #2
0
        public async Task <RollupTaskToMilestoneView> GetTaskToMilestoneRollupViewById(long?milestoneId)
        {
            RollupTaskToMilestoneView view = await(from e in _dbContext.ProjectManagementMilestone
                                                   join f in _dbContext.ProjectManagementTask
                                                   on e.MilestoneId equals f.MileStoneId
                                                   where e.MilestoneId == milestoneId
                                                   group f by f.MileStoneId into pg

                                                   select new RollupTaskToMilestoneView
            {
                MilestoneId        = milestoneId ?? 0,
                EstimatedHours     = pg.Sum(e => e.EstimatedHours),
                ActualDays         = pg.Sum(e => e.ActualDays),
                EstimatedDays      = pg.Sum(e => e.EstimatedDays),
                ActualHours        = pg.Sum(e => e.ActualHours),
                ActualStartDate    = pg.Min(e => e.ActualStartDate),
                ActualEndDate      = pg.Max(e => e.ActualEndDate),
                EstimatedStartDate = pg.Min(e => e.EstimatedStartDate),
                EstimatedEndDate   = pg.Max(e => e.EstimatedEndDate),
                Cost = pg.Sum(e => e.Cost)
            }).FirstOrDefaultAsync <RollupTaskToMilestoneView>();

            return(view);
        }