public async Task <IActionResult> Requests()
        {
            var userRequests = await _unitOfWork.Requests.GetAllRequestsForUser(_userManager.GetUserId(HttpContext.User));

            var requests = userRequests
                           .Where(r => r.Type == RequestType.FromMember);
            var invitations = userRequests
                              .Where(r => r.Type == RequestType.FromTeam && r.Status == RequestStatus.Pending);

            var viewModel = new MembersRequestsViewModel
            {
                Requests    = _mapper.Map <IEnumerable <Request>, IEnumerable <JoinRequestViewModel> >(requests),
                Invitations = _mapper.Map <IEnumerable <Request>, IEnumerable <JoinRequestViewModel> >(invitations)
            };

            return(View(viewModel));
        }
Exemple #2
0
        public async Task <IActionResult> Requests(int id)
        {
            var teamRequests = await _unitOfWork.Requests.GetAllRequestsForTeam(id);

            var requests = teamRequests
                           .Where(r => r.Type == RequestType.FromMember && r.Status == RequestStatus.Pending);
            var invitations = teamRequests
                              .Where(r => r.Type == RequestType.FromTeam);

            var viewModel = new MembersRequestsViewModel
            {
                Requests    = _mapper.Map <IEnumerable <Request>, IEnumerable <JoinRequestViewModel> >(requests),
                Invitations = _mapper.Map <IEnumerable <Request>, IEnumerable <JoinRequestViewModel> >(invitations)
            };

            return(View(viewModel));
        }