示例#1
0
 public static string GetProjectCreatorName(int projectId)
 {
     var context = new LmPlatformModelsContext();
     var _context = new ProjectManagementService();
     var project = context.Projects.Find(projectId);
     var creator = context.Users.Find(project.CreatorId);
     return _context.GetCreatorName(creator.Id);
 }
示例#2
0
 public BugListViewModel(int id)
 {
     CurrentProjectId = id;
     CurrentProjectName = string.Empty;
     if (id != 0)
     {
         var project = new ProjectManagementService().GetProject(id);
         CurrentProjectName = project.Title;
     }
 }
示例#3
0
        public bool IsUserAssignedOnProject(int userId, int projectId)
        {
            var isAssigned   = false;
            var projectUsers = new ProjectManagementService().GetProjectUsers(projectId);

            foreach (var user in projectUsers)
            {
                if (user.UserId == userId)
                {
                    isAssigned = true;
                }
            }

            return(isAssigned);
        }
示例#4
0
 public bool IsUserAnAssignedDeveloper()
 {
     var bug = new BugManagementService().GetBug(_currentBugId);
     var context = new ProjectManagementService();
     var projectRoleId = context.GetProjectUsers(bug.ProjectId).Single(e => e.UserId == WebSecurity.CurrentUserId).ProjectRoleId;
     if (bug.AssignedDeveloperId == 0 && projectRoleId == 1)
     {
         return true;
     }
     else
     {
         if (bug.AssignedDeveloperId != WebSecurity.CurrentUserId && projectRoleId == 1)
         {
             return false;
         }
         else
         {
             return true;
         }
     }
 }
示例#5
0
 public string GetProjectTitle(int id)
 {
     var projectManagementService = new ProjectManagementService();
     var project = projectManagementService.GetProject(id);
     return project.Title;
 }
示例#6
0
        public JsonResult GetDeveloperNames()
        {
            var _context = new UsersManagementService();
            var context = new ProjectManagementService();
            var projectUsers = context.GetProjectUsers(_currentProjectId).ToList().Where(e => e.ProjectRoleId == 1);

            var users = new List<User>();

             var currProjectUser =
                context.GetProjectUsers(_currentProjectId).Single(e => e.UserId == WebSecurity.CurrentUserId);
            if (currProjectUser.ProjectRoleId == 1)
            {
                users.Add(_context.GetUser(currProjectUser.UserId));
            }
            else
            {
                foreach (var user in projectUsers)
                {
                    users.Add(_context.GetUser(user.UserId));
                }
            }

            var userList = users.Select(e => new SelectListItem
            {
                Text = context.GetCreatorName(e.Id),
                Value = e.Id.ToString(CultureInfo.InvariantCulture)
            }).ToList();

            return Json(new SelectList(userList, "Value", "Text"));
        }
示例#7
0
        public ProjectUserListViewModel FromProjectUser(ProjectUser projectUser)
        {
            var context = new ProjectManagementService();

            return new ProjectUserListViewModel
            {
                Id = projectUser.Id,
                UserName = context.GetCreatorName(projectUser.User.Id),
                RoleName = GetRoleName(projectUser.ProjectRoleId),
                ProjectId = projectUser.ProjectId
            };
        }
示例#8
0
        public ProjectListViewModel FromProject(Project project)
        {
            var context = new LmPlatformModelsContext();
            var isAssigned = false;
            foreach (var user in context.ProjectUsers)
            {
                if (user.ProjectId == project.Id && user.UserId == WebSecurity.CurrentUserId)
                {
                    isAssigned = true;
                }
            }

            var _context = new ProjectManagementService();
            var creatorId = project.Creator.Id;

            return new ProjectListViewModel
            {
                Id = project.Id,
                Title =
                    string.Format("<a href=\"{0}\">{1}</a>", Url.Action("ProjectManagement", "BTS", new { id = project.Id }), project.Title),
                CreatorName = _context.GetCreatorName(creatorId),
                CreationDate = project.DateOfChange.ToShortDateString(),
                UserQuentity = _context.GetProjectUsers(project.Id).Count,
                IsAssigned = isAssigned
            };
        }
示例#9
0
        public ActionResult EditBug(int id)
        {
            var bug = BugManagementService.GetBug(id);
            _currentProjectId = bug.ProjectId;

            var bugViewModel = new AddOrEditBugViewModel(id);
            _prevBugStatus = bugViewModel.StatusId;
            var projectUser =
                new ProjectManagementService().GetProjectUsers(bug.ProjectId).Single(e => e.UserId == WebSecurity.CurrentUserId);
            if ((projectUser.ProjectRoleId == 1 && bug.StatusId == 2) ||
                (projectUser.ProjectRoleId == 3 && bug.StatusId == 1))
            {
                return PartialView("_EditBugFormWithAssignment", bugViewModel);
            }

            return PartialView("_EditBugFormWithAssignment", bugViewModel);
        }
示例#10
0
        public IList<SelectListItem> GetStatusNames()
        {
            var allStatuses = new LmPlatformModelsContext().BugStatuses.ToList();
            var statuses = new List<BugStatus>();

            var userRoleOnProject =
                new ProjectManagementService().GetProjectsOfUser(WebSecurity.CurrentUserId).Single(e => e.ProjectId == ProjectId).ProjectRoleId;

            switch (userRoleOnProject)
            {
                //Роль "Разработчик"
                case 1:
                    switch (StatusId)
                    {
                        //Статус "Обнаружена"
                        case 1:
                            statuses.Add(allStatuses[0]);
                            statuses.Add(allStatuses[1]);
                            statuses.Add(allStatuses[5]);
                            break;

                        //Статус "Назначена"
                        case 2:
                            statuses.Add(allStatuses[1]);
                            statuses.Add(allStatuses[2]);
                            statuses.Add(allStatuses[5]);
                            break;

                        //Статус "Исправлена"
                        case 3:
                            statuses.Add(allStatuses[2]);
                            break;

                        //Статус "Проверена"
                        case 4:
                            statuses.Add(allStatuses[3]);
                            statuses.Add(allStatuses[6]);
                            break;

                        //Статус "Отложена"
                        case 5:
                            statuses.Add(allStatuses[4]);
                            break;

                        //Статус "Отклонена"
                        case 6:
                            statuses.Add(allStatuses[5]);
                            statuses.Add(allStatuses[6]);
                            break;

                        //Статус "Открыта заново"
                        case 8:
                            if (AssignedDeveloperId == 0)
                            {
                                statuses.Add(allStatuses[1]);
                            }

                            statuses.Add(allStatuses[7]);
                            break;
                    }

                    break;

                //Роль "Тестировщик"
                case 2:
                    switch (StatusId)
                    {
                        //Статус "Обнаружена"
                        case 1:
                            statuses.Add(allStatuses[0]);
                            statuses.Add(allStatuses[1]);
                            statuses.Add(allStatuses[4]);
                            statuses.Add(allStatuses[5]);
                            break;

                        //Статус "Назначена"
                        case 2:
                            statuses.Add(allStatuses[1]);
                            break;

                        //Статус "Исправлена"
                        case 3:
                            statuses.Add(allStatuses[2]);
                            statuses.Add(allStatuses[3]);
                            statuses.Add(allStatuses[4]);
                            statuses.Add(allStatuses[7]);
                            break;

                        //Статус "Проверена"
                        case 4:
                            statuses.Add(allStatuses[3]);
                            break;

                        //Статус "Отложена"
                        case 5:
                            if (AssignedDeveloperId != 0)
                            {
                                statuses.Add(allStatuses[2]);
                            }

                            statuses.Add(allStatuses[4]);
                            statuses.Add(allStatuses[5]);
                            statuses.Add(allStatuses[7]);
                            break;

                        //Статус "Отклонена"
                        case 6:
                            statuses.Add(allStatuses[5]);
                            statuses.Add(allStatuses[7]);
                            break;

                        //Статус "Открыта заново"
                        case 8:
                            if (AssignedDeveloperId != 0)
                            {
                                statuses.Add(allStatuses[2]);
                            }

                            statuses.Add(allStatuses[4]);
                            statuses.Add(allStatuses[5]);
                            statuses.Add(allStatuses[7]);
                            break;
                    }

                    break;

                //Роль "Руководитель проекта"
                case 3:
                    switch (StatusId)
                    {
                        //Статус "Обнаружена"
                        case 1:
                            statuses.Add(allStatuses[0]);
                            statuses.Add(allStatuses[1]);
                            statuses.Add(allStatuses[4]);
                            statuses.Add(allStatuses[5]);
                            break;

                        //Статус "Назначена"
                        case 2:
                            statuses.Add(allStatuses[1]);
                            break;

                        //Статус "Исправлена"
                        case 3:
                            statuses.Add(allStatuses[2]);
                            statuses.Add(allStatuses[4]);
                            break;

                        //Статус "Проверена"
                        case 4:
                            statuses.Add(allStatuses[3]);
                            statuses.Add(allStatuses[6]);
                            break;

                        //Статус "Отложена"
                        case 5:
                            if (AssignedDeveloperId != 0)
                            {
                                statuses.Add(allStatuses[2]);
                            }

                            statuses.Add(allStatuses[4]);
                            statuses.Add(allStatuses[5]);
                            statuses.Add(allStatuses[7]);
                            break;

                        //Статус "Отклонена"
                        case 6:
                            statuses.Add(allStatuses[5]);
                            statuses.Add(allStatuses[6]);
                            statuses.Add(allStatuses[7]);
                            break;

                        //Статус "Открыта заново"
                        case 8:
                            statuses.Add(allStatuses[1]);
                            statuses.Add(allStatuses[4]);
                            statuses.Add(allStatuses[5]);
                            statuses.Add(allStatuses[7]);
                            break;
                    }

                    break;
            }

            return statuses.Select(e => new SelectListItem
            {
                Text = e.Name,
                Value = e.Id.ToString(CultureInfo.InvariantCulture)
            }).ToList();
        }
示例#11
0
        public IList<SelectListItem> GetProjectNames()
        {
            var projectUsers = new ProjectManagementService().GetProjectsOfUser(WebSecurity.CurrentUserId);
            var projects = new List<Project>();
            foreach (var projectUser in projectUsers)
            {
                projects.Add(new ProjectManagementService().GetProject(projectUser.ProjectId));
            }

            return projects.Select(e => new SelectListItem
            {
                Text = e.Title,
                Value = e.Id.ToString(CultureInfo.InvariantCulture)
            }).ToList();
        }
        public List<string> GetProjectRoleList(int studentId)
        {
            var projectUserList = new ProjectManagementService().GetProjectsOfUser(studentId).ToList();
            var projectRoleList = new List<string>();
            foreach (var project in projectUserList)
            {
                projectRoleList.Add(project.ProjectRole.Name);
            }

            return projectRoleList;
        }
        public List<string> GetProjectCreatorNameList(int studentId)
        {
            var context = new ProjectManagementService();
            var projectUserList = context.GetProjectsOfUser(studentId).ToList();
            var projectCreatorNameList = new List<string>();
            foreach (var project in projectUserList)
            {
                var creator =
                    new LmPlatformRepositoriesContainer().UsersRepository.GetBy(
                        new Query<User>(e => e.Id == project.Project.CreatorId));
                projectCreatorNameList.Add(context.GetCreatorName(creator.Id));
            }

            return projectCreatorNameList;
        }
        public bool IsUserAssignedOnProject(int userId, int projectId)
        {
            var isAssigned = false;
            var projectUsers = new ProjectManagementService().GetProjectUsers(projectId);
            foreach (var user in projectUsers)
            {
                if (user.UserId == userId)
                {
                    isAssigned = true;
                }
            }

            return isAssigned;
        }
示例#15
0
        public BugListViewModel FromBug(Bug bug)
        {
            var context = new ProjectManagementService();

            var isAssigned = false;
            var user = context.GetProjectsOfUser(WebSecurity.CurrentUserId).Count(e => e.ProjectId == bug.ProjectId && e.UserId == WebSecurity.CurrentUserId);
            if (user != 0)
            {
                isAssigned = true;
            }

            return new BugListViewModel
            {
                Id = bug.Id,
                Steps = bug.Steps,
                Symptom = GetSymptomName(bug.SymptomId),
                ProjectId = bug.ProjectId,
                ReporterName = context.GetCreatorName(bug.ReporterId),
                ReportingDate = bug.ReportingDate.ToShortDateString(),
                Summary = string.Format("<a href=\"{0}\">{1}</a>", Url.Action("BugDetails", "BTS", new { id = bug.Id }), bug.Summary),
                Severity = GetSeverityName(bug.SeverityId),
                Status = GetStatusName(bug.StatusId),
                StatusId = bug.StatusId,
                Project = GetProjectTitle(bug.ProjectId),
                ModifyingDate = bug.ModifyingDate.ToShortDateString(),
                AssignedDeveloperName = (bug.AssignedDeveloperId == 0) ? "отсутствует" : context.GetCreatorName(bug.AssignedDeveloperId),
                IsAssigned = isAssigned
            };
        }
示例#16
0
        public bool IsProjectManager()
        {
            var projectUser = new ProjectManagementService().GetProjectUsers(ProjectId).Count(e => e.UserId == WebSecurity.CurrentUserId && e.ProjectRoleId == 3);

            if (projectUser == 0)
            {
                return false;
            }

            return true;
        }
示例#17
0
        public void SetParams(Bug model)
        {
            var context = new ProjectManagementService();

            Steps = model.Steps;
            ExpectedResult = model.ExpectedResult;
            Symptom = GetSymptomName(model.SymptomId);
            EditorName = context.GetCreatorName(model.EditorId);
            ReporterName = context.GetCreatorName(model.ReporterId);
            Summary = model.Summary;
            Description = model.Description;
            Severity = GetSeverityName(model.SeverityId);
            Status = GetStatusName(model.StatusId);
            Project = GetProjectTitle(model.ProjectId);
            ProjectId = model.ProjectId;
            ModifyingDate = model.ModifyingDate.ToShortDateString();
            ReportingDate = model.ReportingDate.ToShortDateString();
            AssignedDeveloperId = model.AssignedDeveloperId;
            AssignedDeveloperName = (AssignedDeveloperId == 0) ? "-" : context.GetCreatorName(AssignedDeveloperId);
        }