Пример #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());
     }
 }
Пример #3
0
 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));
     }
 }
Пример #5
0
 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));
     }
 }
Пример #6
0
 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));
     }
 }
Пример #8
0
 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));
     }
 }
Пример #9
0
 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();
     }
 }