public User GetUserById(int id) { using (var context = new ProjectManagementContext()) { return(context.Users.Find(id)); } }
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)); } }
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)); } }
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)); } }
public Project GetProjectByKey(string key) { using (var context = new ProjectManagementContext()) { return(context.Projects.FirstOrDefault(project => project.Key == key)); } }
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)); } }
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)); } }
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()); } }
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); } }
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()); } }
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); } }
public void InsertUser(User user) { using (var context = new ProjectManagementContext()) { context.Users.Add(user); context.SaveChanges(); } }
public UserStory GetUserStoryById(int id) { using (var context = new ProjectManagementContext()) { var userStory = context.UserStories.Find(id); return(userStory); } }
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); } }
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(); } }
public void ApproveTask(int taskId) { using (var context = new ProjectManagementContext()) { var task = context.Tasks.Find(taskId); task.IsApproved = true; context.SaveChanges(); } }
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); } }
public void UpdateMemberRole(int memberId, Role role) { using (var context = new ProjectManagementContext()) { var updatingMember = context.Members.Find(memberId); updatingMember.Role = role; context.SaveChanges(); } }
public void DeleteProject(int projectId) { using (var context = new ProjectManagementContext()) { var project = context.Projects.Find(projectId); context.Projects.Remove(project); context.SaveChanges(); } }
public void DenyTask(int taskId) { using (var context = new ProjectManagementContext()) { var task = context.Tasks.Find(taskId); task.IsDone = false; context.SaveChanges(); } }
public void UpdateTaskCompletion(int taskId, bool completion) { using (var context = new ProjectManagementContext()) { var task = context.Tasks.Find(taskId); task.IsDone = completion; context.SaveChanges(); } }
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(); } }
public void InsertProject(Project project) { using (var context = new ProjectManagementContext()) { context.Users.Attach(project.CreatedUser); context.Projects.Add(project); context.SaveChanges(); } }
public void SetStartDate(int projectId, DateTime today) { using (var context = new ProjectManagementContext()) { var project = context.Projects.Find(projectId); project.StartDate = today; context.SaveChanges(); } }
public void UpdateUserStoryState(int id, UserStoryState state) { using (var context = new ProjectManagementContext()) { var userStory = context.UserStories.Find(id); userStory.State = state; context.SaveChanges(); } }