Ejemplo n.º 1
0
        public async Task <IActionResult> CreateMeeting(int id, MeetingRequest request)
        {
            try
            {
                Optional <int> meetingId;

                if (request.DateTime != new DateTime().ToUniversalTime())
                {
                    meetingId = await _meetingService.CreateMeeting(request.DateTime.ToUniversalTime(), id);
                }
                else
                {
                    meetingId = await _meetingService.CreateMeeting(id);
                }


                if (meetingId.IsEmpty)
                {
                    return(StatusCode(500));
                }

                int meeting = meetingId.Value;

                int rowsAffected = await _meetingService.AddAllTasks(meeting, request.Tasks);

                if (rowsAffected < 0)
                {
                    return(StatusCode(500));
                }

                rowsAffected = await _meetingService.InviteAllUsers(meeting, request.InvitedUsers);

                if (rowsAffected < 0)
                {
                    return(StatusCode(500));
                }

                return(Ok(new MeetingIdResponse {
                    MeetingId = meeting
                }));
            }
            catch (UnauthorizedAccessException)
            {
                return(Forbid());
            }
            catch (InvalidOperationException e)
            {
                return(BadRequest(new ErrorResponse {
                    Message = e.Message
                }));
            }
        }
Ejemplo n.º 2
0
        public IActionResult CreateMeeting()
        {
            var userInfo = User.ToRest();

            _logger.LogInformation(Core.LogProvider.LoggingEvents.InsertItem, "CreateMeeting - entry point {ID}", 1);

            _logger.LogInformation(Core.LogProvider.LoggingEvents.InsertItem, "CreateMeeting - token {ID}", 1);
            var data = new MeetingViewModel
            {
                Id = Guid.NewGuid().ToString(),
                AvailableAttendeeCollection = new List <MeetingAttendee>(),
                Date                        = DateTime.UtcNow,
                Duration                    = 60,
                IsFormal                    = false,
                IsLocked                    = false,
                IsPrivate                   = true,
                Time                        = $"{DateTime.UtcNow.Hour.ToString()}:00",
                TimeZoneOffSet              = 2,
                IsRecurrence                = false,
                Location                    = "Durban",
                Status                      = "create",
                MeetingActionCollection     = new List <MinutzAction>(),
                MeetingAgendaCollection     = new List <MeetingAgenda>(),
                MeetingAttachmentCollection = new List <MeetingAttachment>(),
                MeetingAttendeeCollection   = new List <MeetingAttendee>(),
                MeetingNoteCollection       = new List <MeetingNote>(),
                MeetingDecisionCollection   = new List <MinutzDecision>(),
                Outcome                     = string.Empty,
                Purpose                     = string.Empty,
                RecurrenceType              = 0,
                UpdatedDate                 = DateTime.UtcNow
            };

            _logger.LogInformation(Core.LogProvider.LoggingEvents.InsertItem, "CreateMeeting - created viewmodel {ID}", 1);

            var result = _meetingService.CreateMeeting(
                userInfo,
                data.ToEntity(),
                data.MeetingAttendeeCollection,
                data.MeetingAgendaCollection,
                data.MeetingNoteCollection,
                data.MeetingAttachmentCollection,
                data.MeetingActionCollection, userInfo.InstanceId);

            result.Value.Status = "create";
            if (result.Key)
            {
                return(new OkObjectResult(result.Value));
            }
            return(new BadRequestResult());
        }
Ejemplo n.º 3
0
        public MeetingModule(IMeetingService meetingService) : base("/meetings")
        {
            Get["/{id}", true] = async(ctx, cancel) =>
            {
                var request = this.Bind <GetMeetingByIdRequest>();

                var meeting = await meetingService.GetMeetingById(new GetMeetingById()
                {
                    Id = request.Id
                });

                var utcNow   = DateTime.UtcNow;
                var response = new
                {
                    id             = meeting.Id,
                    startUtc       = meeting.StartUtc,
                    endUtc         = meeting.EndUtc,
                    total          = meeting.Total,
                    active         = meeting.Active,
                    attendees      = meeting.Attendees.Select(p => p.Id),
                    elapsedSeconds = GetElapsedSeconds(meeting.StartUtc, utcNow),
                    elapsedMinutes = GetElapsedMinutes(meeting.StartUtc, utcNow),
                    elapsedHours   = GetElapsedHours(meeting.StartUtc, utcNow)
                };

                return(Response.AsJson(response));
            };

            Post["/", true] = async(ctx, cancel) =>
            {
                var meeting = await meetingService.CreateMeeting(new CreateMeeting()
                {
                });

                return(Response.AsJson(meeting));
            };

            Put["/_join", true] = async(ctx, cancel) =>
            {
                var request = this.Bind <JoinMeetingRequest>();

                var meeting = await meetingService.JoinMeeting(new JoinMeeting()
                {
                    UserId    = request.UserId,
                    MeetingId = request.MeetingId
                });

                return(Response.AsJson(meeting));
            };

            Put["/_leave", true] = async(ctx, cancel) =>
            {
                var request = this.Bind <LeaveMeetingRequest>();

                var meeting = await meetingService.LeaveMeeting(new LeaveMeeting()
                {
                    UserId    = request.UserId,
                    MeetingId = request.MeetingId
                });

                return(Response.AsJson(meeting));
            };

            Put["/_start", true] = async(ctx, cancel) =>
            {
                var request = this.Bind <StartMeetingRequest>();

                var meeting = await meetingService.StartMeeting(new StartMeeting()
                {
                    MeetingId = request.MeetingId
                });

                return(Response.AsJson(meeting));
            };

            Put["/_end", true] = async(ctx, cancel) =>
            {
                var request = this.Bind <EndMeetingRequest>();

                var meeting = await meetingService.EndMeeting(new EndMeeting()
                {
                    MeetingId = request.MeetingId
                });

                return(Response.AsJson(meeting));
            };
        }
Ejemplo n.º 4
0
        public MeetingModule(IMeetingService meetingService):base("/meetings")
        {
            Get["/{id}", true] = async (ctx, cancel) =>
                {
                    var request = this.Bind<GetMeetingByIdRequest>();

                    var meeting = await meetingService.GetMeetingById(new GetMeetingById()
                        {
                            Id = request.Id
                        });

                    var utcNow = DateTime.UtcNow;
                    var response = new
                        {
                            id = meeting.Id,
                            startUtc = meeting.StartUtc,
                            endUtc = meeting.EndUtc,
                            total = meeting.Total,
                            active = meeting.Active,
                            attendees = meeting.Attendees.Select(p => p.Id),
                            elapsedSeconds = GetElapsedSeconds(meeting.StartUtc,utcNow),
                            elapsedMinutes = GetElapsedMinutes(meeting.StartUtc,utcNow),
                            elapsedHours = GetElapsedHours(meeting.StartUtc,utcNow)
                        };

                    return Response.AsJson(response);
                };

            Post["/", true] = async (ctx, cancel) =>
                {
                    var meeting = await meetingService.CreateMeeting(new CreateMeeting()
                        {

                        });

                    return Response.AsJson(meeting);
                };

            Put["/_join", true] = async (ctx, cancel) =>
                {
                    var request = this.Bind<JoinMeetingRequest>();

                    var meeting = await meetingService.JoinMeeting(new JoinMeeting()
                        {
                            UserId = request.UserId,
                            MeetingId = request.MeetingId
                        });

                    return Response.AsJson(meeting);
                };

            Put["/_leave", true] = async (ctx, cancel) =>
                {
                    var request = this.Bind<LeaveMeetingRequest>();

                    var meeting = await meetingService.LeaveMeeting(new LeaveMeeting()
                        {
                            UserId = request.UserId,
                            MeetingId = request.MeetingId
                        });

                    return Response.AsJson(meeting);
                };

            Put["/_start", true] = async (ctx, cancel) =>
                {
                    var request = this.Bind<StartMeetingRequest>();

                    var meeting = await meetingService.StartMeeting(new StartMeeting()
                        {
                            MeetingId = request.MeetingId
                        });

                    return Response.AsJson(meeting);
                };

            Put["/_end", true] = async (ctx, cancel) =>
                {
                    var request = this.Bind<EndMeetingRequest>();

                    var meeting = await meetingService.EndMeeting(new EndMeeting()
                        {
                            MeetingId = request.MeetingId
                        });

                    return Response.AsJson(meeting);
                };

        }