示例#1
0
 public User GetUserById(int id)
 {
     using (var context = new ProjectManagementContext())
     {
         return(context.Users.Find(id));
     }
 }
示例#2
0
 public List <User> GetAllUsers()
 {
     using (var context = new ProjectManagementContext())
     {
         return(context.Users.ToList());
     }
 }
 public Task GetTaskById(int taskId)
 {
     using (var context = new ProjectManagementContext())
     {
         return(context.Tasks.Find(taskId));
     }
 }
示例#4
0
 public User GetUserByUsername(string username)
 {
     using (var context = new ProjectManagementContext())
     {
         return(context.Users.FirstOrDefault(user => user.Username == username));
     }
 }
 public Member GetMemberById(int memberId)
 {
     using (var context = new ProjectManagementContext())
     {
         return(context.Members.Include(m => m.User).Include(m => m.Project).FirstOrDefault(m => m.Id == memberId));
     }
 }
 public bool CheckKey(string key)
 {
     using (var context = new ProjectManagementContext())
     {
         return(context.Projects.Any(project => project.Key == key));
     }
 }
示例#7
0
 public bool CheckUsername(string username)
 {
     using (var context = new ProjectManagementContext())
     {
         return(context.Users.Any(user => user.Username == username));
     }
 }
 public Member GetMemberByUserId(int projectId, int userId)
 {
     using (var context = new ProjectManagementContext())
     {
         return(context.Members.Include(member => member.User).Include(member => member.Project).FirstOrDefault(member => member.User.Id == userId && member.Project.Id == projectId));
     }
 }
 public Project GetProjectById(int projectId)
 {
     using (var context = new ProjectManagementContext())
     {
         return(context.Projects.Include(p => p.CreatedUser).Include(p => p.Members).Include(p => p.Sprints).Include(p => p.Epics).Include(p => p.Epics.Select(e => e.UserStories)).Include(p => p.Sprints.Select(sprint => sprint.UserStories)).Include(p => p.Members.Select(member => member.User)).Include(p => p.Epics.Select(epic => epic.UserStories.Select(u => u.Tasks))).FirstOrDefault(p => p.Id == projectId));
     }
 }
示例#10
0
 public Project GetProjectByKey(string key)
 {
     using (var context = new ProjectManagementContext())
     {
         return(context.Projects.FirstOrDefault(project => project.Key == key));
     }
 }
示例#11
0
 public bool CheckMember(int projectId, int userId)
 {
     using (var context = new ProjectManagementContext())
     {
         return(context.Members.Any(member => member.Project.Id == projectId && member.User.Id == userId));
     }
 }
示例#12
0
 public Epic GetEpicByTitle(int projectId, string title)
 {
     using (var context = new ProjectManagementContext())
     {
         return(context.Epics.Include(epic => epic.Project).FirstOrDefault(epic => epic.Title == title && epic.Project.Id == projectId));
     }
 }
示例#13
0
 public List <Project> GetAllProjects()
 {
     using (var context = new ProjectManagementContext())
     {
         var projects = context.Projects.Include(p => p.CreatedUser).Include(p => p.Members).Include(p => p.Sprints).Include(p => p.Epics).Include(p => p.Epics.Select(e => e.UserStories)).Include(p => p.Sprints.Select(sprint => sprint.UserStories)).Include(p => p.Members.Select(member => member.User)).Include(p => p.Epics.Select(epic => epic.UserStories.Select(u => u.Tasks.Select(t => t.AssignedMember))));
         return(projects.ToList());
     }
 }
示例#14
0
 public Epic GetEpicFromId(int id)
 {
     using (var context = new ProjectManagementContext())
     {
         var epic = context.Epics.Include(e => e.UserStories).FirstOrDefault(e => e.Id == id);
         return(epic);
     }
 }
示例#15
0
 public List <Project> GetAllProjectsBetweenDate(DateTime startDate, DateTime endDate)
 {
     using (var context = new ProjectManagementContext())
     {
         var projects = context.Projects.Include(p => p.CreatedUser).Include(p => p.Members).Include(p => p.Sprints).Include(p => p.Epics).Include(p => p.Epics.Select(e => e.UserStories)).Include(p => p.Sprints.Select(sprint => sprint.UserStories)).Include(p => p.Members.Select(member => member.User)).Include(p => p.Epics.Select(epic => epic.UserStories.Select(u => u.Tasks.Select(t => t.AssignedMember))));
         return(projects.Where(project => project.StartDate != null && project.StartDate >= startDate && project.StartDate <= endDate).ToList());
     }
 }
示例#16
0
 public User GetUserByMemberId(int memberId)
 {
     using (var context = new ProjectManagementContext())
     {
         var user = context.Members.Include(m => m.User).FirstOrDefault(m => m.Id == memberId).User;
         return(user);
     }
 }
示例#17
0
 public void InsertUser(User user)
 {
     using (var context = new ProjectManagementContext())
     {
         context.Users.Add(user);
         context.SaveChanges();
     }
 }
示例#18
0
 public UserStory GetUserStoryById(int id)
 {
     using (var context = new ProjectManagementContext())
     {
         var userStory = context.UserStories.Find(id);
         return(userStory);
     }
 }
示例#19
0
 public bool CheckTitle(int projectId, string epicTitle)
 {
     using (var context = new ProjectManagementContext())
     {
         var same = context.Epics.Include(epic => epic.Project).FirstOrDefault(epic => epic.Title == epicTitle && epic.Project.Id == projectId);
         return(same != null);
     }
 }
示例#20
0
 public void ResetAssignedMember(int id)
 {
     using (var context = new ProjectManagementContext())
     {
         var task = context.Tasks.Include(t => t.AssignedMember).FirstOrDefault(t => t.Id == id);
         task.AssignedMember = null;
         context.SaveChanges();
     }
 }
示例#21
0
 public void ApproveTask(int taskId)
 {
     using (var context = new ProjectManagementContext())
     {
         var task = context.Tasks.Find(taskId);
         task.IsApproved = true;
         context.SaveChanges();
     }
 }
示例#22
0
 public List <User> GetAllUsersNotInProject(int projectId)
 {
     using (var context = new ProjectManagementContext())
     {
         var membersInProject = context.Projects.Include(project => project.Members).Include(project => project.Members.Select(member => member.User)).FirstOrDefault(project => project.Id == projectId).Members.Select(member => member.User.Id);
         var users            = context.Users.Where(user => !membersInProject.Any(id => id == user.Id)).ToList();
         return(users);
     }
 }
示例#23
0
 public void UpdateMemberRole(int memberId, Role role)
 {
     using (var context = new ProjectManagementContext())
     {
         var updatingMember = context.Members.Find(memberId);
         updatingMember.Role = role;
         context.SaveChanges();
     }
 }
示例#24
0
 public void DeleteProject(int projectId)
 {
     using (var context = new ProjectManagementContext())
     {
         var project = context.Projects.Find(projectId);
         context.Projects.Remove(project);
         context.SaveChanges();
     }
 }
示例#25
0
 public void DenyTask(int taskId)
 {
     using (var context = new ProjectManagementContext())
     {
         var task = context.Tasks.Find(taskId);
         task.IsDone = false;
         context.SaveChanges();
     }
 }
示例#26
0
 public void UpdateTaskCompletion(int taskId, bool completion)
 {
     using (var context = new ProjectManagementContext())
     {
         var task = context.Tasks.Find(taskId);
         task.IsDone = completion;
         context.SaveChanges();
     }
 }
示例#27
0
 public void AddTask(int userStoryId, Task task)
 {
     using (var context = new ProjectManagementContext())
     {
         var userStory = context.UserStories.Include(u => u.Tasks).FirstOrDefault(u => u.Id == userStoryId);
         userStory.Tasks.Add(task);
         context.SaveChanges();
     }
 }
示例#28
0
 public void InsertProject(Project project)
 {
     using (var context = new ProjectManagementContext())
     {
         context.Users.Attach(project.CreatedUser);
         context.Projects.Add(project);
         context.SaveChanges();
     }
 }
示例#29
0
 public void SetStartDate(int projectId, DateTime today)
 {
     using (var context = new ProjectManagementContext())
     {
         var project = context.Projects.Find(projectId);
         project.StartDate = today;
         context.SaveChanges();
     }
 }
示例#30
0
 public void UpdateUserStoryState(int id, UserStoryState state)
 {
     using (var context = new ProjectManagementContext())
     {
         var userStory = context.UserStories.Find(id);
         userStory.State = state;
         context.SaveChanges();
     }
 }