public async Task <ActionResult> ListUserInMeeting(DataSourceRequest command, int Id)
        {
            if (!_permissionService.Authorize(PermissionProvider.ManageUser))
            {
                return(AccessDeniedView());
            }

            var meeting = await _meetingService.GetByIdAsync(Id);

            var userInMeetings = new PagedList <UserInMeeting>(meeting.UserInMeetings.OrderBy(um => um.Order).AsQueryable(), command.Page - 1, command.PageSize);

            var gridModel = new DataSourceResult
            {
                Data = userInMeetings.Select(x => new UserInMeetingModel
                {
                    Id        = x.Id,
                    MeetingId = x.MeetingId,
                    User      = new UserForMeetingViewModel()
                    {
                        Id = x.User == null ? 0 : x.User.Id, Name = x.User == null ? "" : x.User.Username
                    },
                    IsLeader        = x.IsLeader,
                    IsCurrentLeader = x.UserId == x.Meeting.CurrentLeaderId,
                    Order           = x.Order
                }),
                Total = userInMeetings.TotalCount
            };

            return(Json(gridModel));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> GetAsync(int meetingId)
        {
            var result = await _meetingService.GetByIdAsync(meetingId);

            if (!result.Success)
            {
                return(BadRequest(result.Message));
            }
            var meetingResource = _mapper.Map <Meeting, MeetingResource>(result.Resource);//de Entity a Resource

            return(Ok(meetingResource));
        }