public ServiceCollectionResult <WorkItem> GetIssueWorkItems(long issueId, string userId) { var result = new ServiceCollectionResult <WorkItem>(); //check can user get access to project var issue = _context.Issues .SingleOrDefault(i => i.Id == issueId); if (issue != null) { //does user have any binding with project var projUserRef = _accessService.GetAccessByIssue(issue, userId); if (projUserRef == null) { result.HandleError(ErrorMessagesDict.AccessDenied); } else { result.TargetCollection = issue.WorkItems; //get issue workitems } return(result); } result.HandleError(ErrorMessagesDict.NotFoundResource); return(result); }
public ServiceCollectionResult <Report> GetIssueReports(long issueId, string userId) { var result = new ServiceCollectionResult <Report>(); //check can user get access to project var issue = _context.Issues .SingleOrDefault(i => i.Id == issueId); if (issue != null) { var projUserRef = _accessService.GetAccessByIssue(issue, userId); if (projUserRef == null) { result.HandleError(ErrorMessagesDict.AccessDenied); } else { result.TargetCollection = issue.Reports; } return(result); } result.HandleError(ErrorMessagesDict.NotFoundResource); return(result); }
public ServiceCollectionResult <Issue> GetIssuesPaged(string userId, string summaryPart = null, int page = 1, int pageSize = 10) { var result = new ServiceCollectionResult <Issue>(); if (!Inspector.IsValidPageSize(pageSize)) { result.HandleError(ErrorMessagesDict.InvalidPageSize); return(result); } //get accessible issues var accessibleIssues = _accessService.GetAccessibleIssues(userId); //filter issues if (summaryPart != null) { accessibleIssues = accessibleIssues .Where(i => i.Summary.Contains(summaryPart.ToLower())); } result.TargetCollection = accessibleIssues .Skip((page - 1) * pageSize) .Take(pageSize); return(result); }
public ServiceCollectionResult <Project> GetProjectsPaged(string userId, ProjectFilter filter = ProjectFilter.All, int page = 1, int pageSize = 10) { var result = new ServiceCollectionResult <Project>(); if (!Inspector.IsValidPageSize(pageSize)) { result.HandleError(ErrorMessagesDict.InvalidPageSize); return(result); } IEnumerable <Project> targetProjects; if (filter != ProjectFilter.All) { if (filter == ProjectFilter.CreatedByMe) { targetProjects = GetProjectsUserCreated(userId); } else { targetProjects = GetProjectsUserInvolvedOnly(userId); } } else { targetProjects = _accessService.GetAccessibleProjects(userId); } result.TargetCollection = targetProjects .Skip((page - 1) * pageSize) .Take(pageSize); return(result); }
public ServiceCollectionResult <ProjectLog> GetItemHistory(long projectId, string userId) { var result = new ServiceCollectionResult <ProjectLog>(); var project = _context.Projects.SingleOrDefault(p => p.Id == projectId); if (project != null) { //find issue history var projectLogs = _context.ProjectsHistory .Where(ph => ph.ProjectId == projectId); if (_accessService.GetAccessByProject(projectId, userId) != null) { result.TargetCollection = projectLogs; return(result); } result.HandleError(ErrorMessagesDict.AccessDenied); return(result); } result.HandleError(ErrorMessagesDict.NotFoundResource); return(result); }
public ServiceCollectionResult<IssueLog> GetItemHistory(long issueId, string userId) { var result = new ServiceCollectionResult<IssueLog>(); var issue = _context.Issues.SingleOrDefault(i => i.Id == issueId); if (issue != null) { //find issue history var issueLogs = _context.IssuesHistory .Where(ih => ih.IssueId == issueId); if (_accessService.GetAccessByIssue(issue, userId) != null) { result.TargetCollection = issueLogs; return result; } result.HandleError(ErrorMessagesDict.AccessDenied); return result; } result.HandleError(ErrorMessagesDict.NotFoundResource); return result; }