public ProjectsController(IRepositary repositary)
     : base(repositary)
 {
     userService = new UserService(repo);
 }
 public ProjectsController(IProjectManager projectManager)
 {
     repo = new Repositary();
     userService = new UserService(repo);
     this.projectManager = projectManager;
 }
 public ProjectsController()
 {
     repo = new Repositary();
     userService = new UserService(repo);
 }
        public ActionResult JoinMyTeam(string id)
        {
            // For users who received an email with the join link to join a team.
            // The user must have created an account by now and coming back to this link after registration

            try
            {
                var teamMemberRequest = repo.GetTeamMemberRequest(id);
                if (teamMemberRequest != null)
                {
                    var user = repo.GetUser(teamMemberRequest.EmailAddress);
                    if (user.ID == UserID)
                    {
                        //Add to the team
                        var teamMember = new TeamMember { MemberID = UserID, TeamID = teamMemberRequest.TeamID, CreatedByID = teamMemberRequest.CreatedByID };
                        repo.SaveTeamMember(teamMember);
                       
                        //Keep that team as default team for the user 
                        SetUserIDToSession(UserID, teamMemberRequest.TeamID, user.FirstName);
                                                
                        var userService = new UserService(repo);
                        userService.SaveActivityForNewUserJoinedTeam(teamMemberRequest, user, UserID, TeamID);

                        //Correct user 
                        return View("WelcomeToTeam");
                    }
                }
                return View("NotFound");
            }
            catch(Exception ex)
            {
                log.Error(ex);
                return View("Error");
            }
        }