コード例 #1
0
        public IList <SelectListItem> GetDeveloperNames()
        {
            var _context     = new UsersManagementService();
            var context      = new ProjectManagementService();
            var projectUsers = context.GetProjectUsers(ProjectId).ToList().Where(e => e.ProjectRoleId == 1);

            var users = new List <User>();

            var currProjectUser =
                context.GetProjectUsers(ProjectId).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));
                }
            }

            return(users.Select(e => new SelectListItem
            {
                Text = context.GetCreatorName(e.Id),
                Value = e.Id.ToString(CultureInfo.InvariantCulture)
            }).ToList());
        }
コード例 #2
0
ファイル: BTSController.cs プロジェクト: ze333/lmsystem
        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
            });
        }
コード例 #3
0
ファイル: BTSController.cs プロジェクト: ze333/lmsystem
        public DataTablesResult <ProjectUserListViewModel> GetProjectUsers(DataTablesParam dataTablesParam)
        {
            var searchString = dataTablesParam.GetSearchString();
            var projectUsers = ProjectManagementService.GetProjectUsers(pageInfo: dataTablesParam.ToPageInfo(),
                                                                        searchString: searchString);
            var projectId = int.Parse(Request.QueryString["projectId"]);

            if (User.IsInRole("lector") && ProjectManagementService.GetProject(projectId).CreatorId == WebSecurity.CurrentUserId)
            {
                return(DataTableExtensions.GetResults(projectUsers.Items.Select(model => FromProjectUser(model, PartialViewToString("_ProjectUsersGridActions", FromProjectUser(model)))).Where(e => e.ProjectId == projectId && e.UserName != GetProjectCreatorName(projectId)), dataTablesParam, projectUsers.TotalCount));
            }

            return(DataTableExtensions.GetResults(projectUsers.Items.Select(FromProjectUser).Where(e => e.ProjectId == projectId && e.UserName != GetProjectCreatorName(projectId)), dataTablesParam, projectUsers.TotalCount));
        }
コード例 #4
0
ファイル: BTSController.cs プロジェクト: ze333/lmsystem
        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);
                }
            }
        }