/// <summary> /// View a team as an admin (will automatically grab the team of the logged in user) /// </summary> public ActionResult TeamAdmin() { // TODO: get the currently logged in user string loggedInGitUser = _loginUser.GetCurrentUserGithub(); if (string.IsNullOrEmpty(loggedInGitUser)) { // redirect to login page return(Redirect("/Login")); } else { var userTeam = _teamsRepository.GetMyTeam(loggedInGitUser); if (userTeam == null) { return(Redirect("/AssignTeam")); } // get team details var userTeamBuilt = _teamsRepository.GetTeamFromItem(userTeam); var viewModel = new TeamAdminViewModel() { Team = userTeamBuilt, SecretJoinString = userTeamBuilt.Slug }; return(View(viewModel)); } }
public async Task <IHttpActionResult> Team(TeamAdminViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _teamAdminBuilder.UpdateAsync(model); return(Ok()); }
public async Task AddAsync(TeamAdminViewModel model) { var record = MapAdd().CreateMapper().Map <TeamAdmin>(model); if (!_repo.RoleManager.RoleExists("TeamAdmin")) { var role = new ApplicationRole(); role.Name = "TeamAdmin"; role.DateCreatedUtc = DateTime.UtcNow; await _repo.RoleManager.CreateAsync(role); } if (model.AdminStatus == AdminStatus.Approved && (await _repo.UserManager.IsInRoleAsync(model.UserId, "TeamAdmin") == false)) { await _repo.UserManager.AddToRoleAsync(model.UserId, "TeamAdmin"); } if ((model.AdminStatus == AdminStatus.Denied || model.AdminStatus == AdminStatus.Pending) && (await _repo.UserManager.IsInRoleAsync(model.UserId, "TeamAdmin"))) { await _repo.UserManager.RemoveFromRoleAsync(model.UserId, "TeamAdmin"); } await _repo.TeamAdmins.AddOrUpdateAndSaveAsync(record); }