示例#1
0
        public void Save(int reporterId, int projectId)
        {
            if (projectId != 0)
            {
                ProjectId = projectId;
            }

            var bug = new Bug
            {
                Id                  = BugId,
                ReporterId          = CreatorId,
                ProjectId           = ProjectId,
                SeverityId          = SeverityId,
                StatusId            = StatusId,
                SymptomId           = SymptomId,
                Steps               = Steps,
                ExpectedResult      = ExpectedResult,
                Description         = Description,
                Summary             = Summary,
                ModifyingDate       = DateTime.Today,
                EditorId            = reporterId,
                AssignedDeveloperId = AssignedDeveloperId
            };

            if (BugId == 0)
            {
                bug.ReportingDate       = DateTime.Today;
                bug.StatusId            = 1;
                bug.AssignedDeveloperId = 0;
                bug.ReporterId          = WebSecurity.CurrentUserId;
            }
            else
            {
                bug.ReportingDate = BugManagementService.GetBug(BugId).ReportingDate;
                if (StatusId != 2 && SavedAssignedDeveloperId != AssignedDeveloperId)
                {
                    bug.AssignedDeveloperId = SavedAssignedDeveloperId;
                }
            }

            if (bug.StatusId == 1 || bug.StatusId == 8)
            {
                bug.AssignedDeveloperId = 0;
            }

            BugManagementService.SaveBug(bug);
        }
示例#2
0
        public void DeleteUserFromProject(int userId, int projectId)
        {
            var project = this.GetProject(projectId, includeBugs: true, includeUsers: true);

            if (project.CreatorId == userId)
            {
                this.DeleteProject(projectId);
                return;
            }

            var projectUsers = project.ProjectUsers.Where(e => e.UserId == userId).ToList();

            foreach (var projectUser in projectUsers)
            {
                this.DeleteProjectUser(projectUser.Id);
            }

            var reportedBugs = project.Bugs.Where(e => e.ReporterId == userId);

            foreach (var bug in reportedBugs)
            {
                bug.ReporterId = project.CreatorId;
                bug.EditorId   = WebSecurity.CurrentUserId;

                BugManagementService.SaveBug(bug);
            }

            var bugs = project.Bugs.Where(e => e.AssignedDeveloperId == userId || e.EditorId == userId);

            foreach (var bug in bugs)
            {
                if (bug.EditorId == userId)
                {
                    bug.EditorId = 0;
                }
                else
                {
                    bug.AssignedDeveloperId = 0;
                    bug.EditorId            = WebSecurity.CurrentUserId;
                }

                BugManagementService.SaveBug(bug);
            }
        }