示例#1
0
        public IActionResult TeamProfile(string teamUrl)
        {
            var teamProfileUrl = _db.TeamProfileUrls.FirstOrDefault(tpu => tpu.Url == teamUrl);
            var team           = _db.Teams.FirstOrDefault(t => t.Id == teamProfileUrl.TeamId);

            if (team == null)
            {
                return(View());
            }
            var userTeams   = _db.UserTeams.Where(ut => ut.TeamId == team.Id);
            var teamMembers = new List <QueueItUserWithRole>();
            var queues      = _db.Queues.Where(q => q.TeamId == team.Id).ToList();

            foreach (var userTeam in userTeams)
            {
                var teamMember = new QueueItUserWithRole
                {
                    IsAdmin = userTeam.IsAdmin,
                    User    = _userDb.Users.FirstOrDefault(u => u.Id == userTeam.UserId)
                };

                teamMembers.Add(teamMember);
            }

            var teamProfileViewModel = new TeamProfileViewModel
            {
                TeamName        = team.Name,
                TeamDescription = team.Description,
                TeamCreatorId   = team.CreatorId,
                TeamMembers     = teamMembers,
                Queues          = queues,
            };

            return(View(teamProfileViewModel));
        }
        public ActionResult ViewTeamProfile(string id)
        {
            var team = _teamService.GetById(id);

            var employeesDTOs = _employeeService.GetEmployeesByTeamId(team.TeamID);

            var teamLead = _employeeService.GetUserById(team.TeamLeadID);

            var employees = Mapper.MapCollection <EmployeeDTO, EmployeeViewModel>(employeesDTOs.ToArray());

            var result = new TeamProfileViewModel
            {
                TeamID            = team.TeamID,
                TeamName          = team.TeamName,
                TeamLeadName      = teamLead.Name + " " + teamLead.Surname,
                TeamLeadID        = team.TeamLeadID,
                Status            = teamLead.Status,
                AmountOfEmployees = team.AmountOfEmployees,
                Employees         = employees
            };

            return(View(result));
        }