/// <summary> /// Creates a new system user. /// </summary> /// <param name="user">New user object.</param> public void Register(User user) { if (!UserExists(user.Username)) { new UserRepository().Create(user); } }
public static void LogEvent(Project project, User user, int actionConst, Bug bug) { var action = new BugActionRepository().GetAll().Where(p => p.Id == actionConst).SingleOrDefault(); var proj = new ProjectRepository().GetAll().Where(p => p.Id == project.Id).SingleOrDefault(); new BugActionLogRepository().Create(new BugActionLog { Project = proj, Action = action, BugName = bug.Name, UserName = user.FirstName.Substring(0, 1) + "." + user.Surname }); }
public void Delete(User user) { using (var ctx = new WcfEntityContext()) { ctx.AttachTo("Users", user); ctx.Users.DeleteObject(user); ctx.SaveChanges(); } }
public User Update(User user) { using (var ctx = new WcfEntityContext()) { ctx.AttachModify("Users", user); ctx.SaveChanges(); return user; } }
public User Create(User user) { using (var ctx = new WcfEntityContext()) { ctx.Users.AddObject(user); ctx.SaveChanges(); return user; } }
public void AcceptUserOnProject(User user, Project project, String rolename) { UserProjectSignupRepository signUpRepo = new UserProjectSignupRepository(); Role acceptedRole = new RoleRepository().GetAll().Where(p => p.RoleName == rolename).SingleOrDefault(); UserProjectSignup request = signUpRepo.GetAll() .Where(p => p.UserId == user.Id && p.ProjectId == project.Id).SingleOrDefault(); new ProjectRoleRepository().Create (new ProjectRole { UserId = request.UserId, ProjectId = request.ProjectId, RoleId = acceptedRole.Id }); signUpRepo.Delete(request); }
public void SaveUserCredentials(User user) { if (CustomPrincipal.Current.Identity.Name == user.Username) { new UserRepository().Update(user); } }
public void RequestProjectAssignment(String code, User user, Role role) { Project proj = new ProjectRepository().GetAll().Where(p => p.Code == code).SingleOrDefault(); if (proj == null) throw new FaultException("A project with this code does not exist."); var existingRequest = new UserProjectSignupRepository().GetAll().Where( p => p.ProjectId == proj.Id && p.UserId == user.Id).SingleOrDefault(); if (existingRequest != null) { new UserProjectSignupRepository().Delete(existingRequest); } UserProjectSignup ass = new UserProjectSignup { ProjectId = proj.Id, UserId = user.Id, RoleId = role.Id }; new UserProjectSignupRepository().Create(ass); }
public void RejectUserFromProject(User user, Project project) { UserProjectSignupRepository signUpRepo = new UserProjectSignupRepository(); UserProjectSignup request = signUpRepo.GetAll() .Where(p => p.UserId == user.Id && p.ProjectId == project.Id).SingleOrDefault(); signUpRepo.Delete(request); }
public void LeaveProject(Project project, User user) { ProjectRoleRepository projRoleRepo = new ProjectRoleRepository(); var associations = projRoleRepo.GetAll().Where(p => p.User.Id == user.Id && p.Project.Id == project.Id); foreach (var ass in associations) { projRoleRepo.Delete(ass); } }
public string GetUsersRequestedRoleForProject(User user, Project project) { return new UserProjectSignupRepository().GetAll() .Where(p => p.ProjectId == project.Id && user.Id == p.UserId).Select(p => p.Role.RoleName).SingleOrDefault(); }
public IList<Project> GetProjectsManagedBy(User user) { ProjectRoleRepository projRoleRepo = new ProjectRoleRepository(); RoleRepository roleRepo = new RoleRepository(); Role manager = roleRepo.GetAll().Where(r => r.RoleName == "Project Manager").SingleOrDefault(); return projRoleRepo.GetAll().Where(p => p.User.Id == user.Id && p.Role.Id == manager.Id).Select(c => c.Project).Distinct().ToList(); }
public IList<Project> GetProjectsAssignedTo(User user) { ProjectRoleRepository projRoleRepo = new ProjectRoleRepository(); return projRoleRepo.GetAll().Where(p => p.User.Id == user.Id) .Select(c => c.Project).Distinct().ToList(); }
public int GetNumberOfBugsAssignedToUserInProject(Project project, User user) { return new BugRepository().GetAll().Where(p => p.Project.Id == project.Id && p.AssignedUser.Id == user.Id).Count(); }
public IList<Bug> GetBugsAssignedToProjectAndUser(Project project, User user) { return new BugRepository().GetAll().Where(p => p.Project.Id == project.Id && p.AssignedUser.Id == user.Id).ToList(); }