コード例 #1
0
        public void Execute()
        {
            var meetings = _meetingService.GetAllAsync();

            foreach (var meeting in meetings.Result)
            {
                if (meeting.CurrentLeaderId > 0)
                {
                    // find current in meeting
                    var currentLeaderId = meeting.CurrentLeaderId;
                    var currentLeader   = meeting.UserInMeetings.FirstOrDefault(x => x.UserId == currentLeaderId);
                    if (currentLeader == null)
                    {
                        continue;
                    }
                    var query = meeting.UserInMeetings.Where(um => um.IsLeader).OrderBy(um => um.Order);

                    var nextLeader = query.FirstOrDefault(um => um.Order > currentLeader.Order) ??
                                     query.FirstOrDefault();

                    if (nextLeader == null)
                    {
                        continue;
                    }

                    _meetingService.UpdateMeetingLeader(meeting.Id, meeting.CurrentLeaderId, nextLeader.UserId);

                    meeting.CurrentLeaderId         = nextLeader.UserId;
                    meeting.UpdateCurrentLeaderDate = DateTime.Now.Date;
                    _meetingService.UpdateAsync(meeting);
                }
            }
        }
コード例 #2
0
        public async Task <ActionResult> List(DataSourceRequest command)
        {
            if (!_permissionService.Authorize(PermissionProvider.ManageUser))
            {
                return(AccessDeniedView());
            }

            var meetings = await _meetingService.GetAllAsync(command.Page - 1, command.PageSize);

            var gridModel = new DataSourceResult
            {
                Data = meetings.Select(x => new MeetingModel
                {
                    Id         = x.Id,
                    Department = new DepartmentViewModel()
                    {
                        Id = x.Department.Id, Name = x.Department.Name
                    },
                    CurrentLeader = PrepareCurrentLeaderForViewMeeting(x.CurrentLeaderId),
                    Leaders       = PrepareLeadersForViewMeeting(x),
                    Members       = PrepareMembersForViewMeeting(x)
                }),
                Total = meetings.TotalCount
            };

            return(Json(gridModel));
        }
コード例 #3
0
        public async Task <ActionResult <MeetingDto[]> > Get()
        {
            try
            {
                var results = await meetingService.GetAllAsync();

                return(results.Select(x => new MeetingDto
                {
                    Id = x.Id,
                    Topic = x.Topic,
                    Date = x.Date.Value.ToString("d"),
                    StartTime = x.Date.Value.ToString("HH:mm"),
                    EndTime = x.EndTime,
                    Participants = x.Participants.Select(y => new ParticipantDto {
                        Id = y.Id, Fullname = y.Fullname
                    }).ToArray()
                }).ToArray());
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Database Failure"));
            }
        }
コード例 #4
0
        public async Task <ActionResult <List <MeetingModel> > > GetAllMeetings()
        {
            var meetings = await meetingService.GetAllAsync();

            return(Ok(meetings));
        }