コード例 #1
0
 /// <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);
     }
 }
コード例 #2
0
        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 });
        }
コード例 #3
0
        public void Delete(User user)
        {
            using (var ctx = new WcfEntityContext())
            {
                ctx.AttachTo("Users", user);
                ctx.Users.DeleteObject(user);

                ctx.SaveChanges();
            }
        }
コード例 #4
0
        public User Update(User user)
        {
            using (var ctx = new WcfEntityContext())
            {
                ctx.AttachModify("Users", user);

                ctx.SaveChanges();

                return user;
            }
        }
コード例 #5
0
        public User Create(User user)
        {
            using (var ctx = new WcfEntityContext())
            {
                ctx.Users.AddObject(user);

                ctx.SaveChanges();

                return user;
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 public void SaveUserCredentials(User user)
 {
     if (CustomPrincipal.Current.Identity.Name == user.Username)
     {
         new UserRepository().Update(user);
     }
 }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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);
            }
        }
コード例 #11
0
 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();
 }
コード例 #12
0
        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();
        }
コード例 #13
0
        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();
        }
コード例 #14
0
 public int GetNumberOfBugsAssignedToUserInProject(Project project, User user)
 {
     return new BugRepository().GetAll().Where(p => p.Project.Id == project.Id && p.AssignedUser.Id == user.Id).Count();
 }
コード例 #15
0
 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();
 }