public async Task <ActionResult> Edit(int id, LtiMeetingViewModel ltiMeetingViewModel) { var ltiRequest = GetLtiRequestFromClaim(); if (ltiRequest == null) { return(RedirectToAction("BadRequest", "Error", new { error = "Invalid LTI request" })); } var consumer = _providerContext.Consumers.SingleOrDefault(c => c.Key.Equals(ltiRequest.ConsumerKey)); if (consumer == null) { return(RedirectToAction("BadRequest", "Error", new { error = "Invalid Consumer" })); } var meeting = Mapper.MapLtiMeetingViewModelToMeeting(ltiMeetingViewModel); var ltiMeeting = _providerContext.LtiMeetings.Find(id); var email = User.Identity.GetUserName(); var appUser = _applicationUserManager.GetUsers().FirstOrDefault(x => x.Email == email); await _apiClient.GetToken(appUser); var response = await _apiClient.UpdateMeeting(ltiMeeting.MeetingId, meeting); var bjnMeeting = JsonConvert.DeserializeObject <Meeting>(await response.Content.ReadAsStringAsync()); ltiMeeting.Title = bjnMeeting.title; ltiMeeting.MeetingId = bjnMeeting.id; _providerContext.Entry(ltiMeeting).State = EntityState.Modified; _providerContext.SaveChanges(); return(RedirectToAction("Details", new { id })); }
public static Meeting MapLtiMeetingViewModelToMeeting(LtiMeetingViewModel ltiMeetingViewModel) { var attendeeList = new List <Attendee>(); if (!String.IsNullOrEmpty(ltiMeetingViewModel.attendeesString)) { var attendeeArray = Array.ConvertAll(ltiMeetingViewModel.attendeesString.Split(','), a => a.Trim()); attendeeList = attendeeArray.Select(a => new Attendee() { email = a }).ToList(); } var meeting = new Meeting() { title = ltiMeetingViewModel.title, description = ltiMeetingViewModel.description, start = ltiMeetingViewModel.start, end = ltiMeetingViewModel.end, timezone = "America/Toronto", advancedMeetingOptions = new AdvancedMeetingOptions() { allowStream = ltiMeetingViewModel.advancedMeetingOptions.allowStream, autoRecord = ltiMeetingViewModel.advancedMeetingOptions.autoRecord, disallowChat = ltiMeetingViewModel.advancedMeetingOptions.disallowChat, encryptionType = /*ltiMeetingViewModel.advancedMeetingOptions.encryptionType*/ "NO_ENCRYPTION", moderatorLess = ltiMeetingViewModel.advancedMeetingOptions.moderatorLess, muteParticipantsOnEntry = ltiMeetingViewModel.advancedMeetingOptions.muteParticipantsOnEntry, publishMeeting = ltiMeetingViewModel.advancedMeetingOptions.publishMeeting, showAllAttendeesInMeetingInvite = ltiMeetingViewModel.advancedMeetingOptions.showAllAttendeesInMeetingInvite, videoBestFit = ltiMeetingViewModel.advancedMeetingOptions.videoBestFit }, addAttendeePasscode = ltiMeetingViewModel.addAttendeePasscode, deleted = false, allow720p = ltiMeetingViewModel.allow720p, sequenceNumber = 0, endPointType = "LTI", endPointVersion = "1.2", attendees = attendeeList, recurrencePattern = ltiMeetingViewModel.recurrencePattern.recurrenceType == null ? null : new RecurrencePattern() { dayOfMonth = ltiMeetingViewModel.recurrencePattern.dayOfMonth, daysOfWeekMask = ltiMeetingViewModel.recurrencePattern.daysOfWeekMask, endDate = ltiMeetingViewModel.recurrencePattern.endDate, frequency = ltiMeetingViewModel.recurrencePattern.frequency, monthOfYear = ltiMeetingViewModel.recurrencePattern.monthOfYear, recurrenceCount = ltiMeetingViewModel.recurrencePattern.recurrenceCount, recurrenceType = ltiMeetingViewModel.recurrencePattern.recurrenceType, weekOfMonth = ltiMeetingViewModel.recurrencePattern.weekOfMonth } }; return(meeting); }
public async Task <ActionResult> Create(LtiMeetingViewModel ltiMeetingViewModel) { var ltiRequest = GetLtiRequestFromClaim(); if (ltiRequest == null) { return(RedirectToAction("BadRequest", "Error", new { error = "Invalid LTI request" })); } var consumer = _providerContext.Consumers.SingleOrDefault(c => c.Key.Equals(ltiRequest.ConsumerKey)); if (consumer == null) { return(RedirectToAction("BadRequest", "Error", new { error = "Invalid Consumer" })); } var meeting = Mapper.MapLtiMeetingViewModelToMeeting(ltiMeetingViewModel); var email = User.Identity.GetUserName(); var appUser = _applicationUserManager.GetUsers().FirstOrDefault(x => x.Email == email); if (appUser == null) { return(RedirectToAction("BadRequest", "Error", new { error = "You do not have the correct permissions to access this feature" })); } await _apiClient.GetToken(appUser); var response = await _apiClient.ScheduleMeeting(meeting); var meetingResponse = JsonConvert.DeserializeObject <Meeting>(await response.Content.ReadAsStringAsync()); var ltiMeeting = new LtiMeeting { Consumer = consumer, CourseId = ltiRequest.ContextId, Title = ltiMeetingViewModel.title, MeetingId = meetingResponse.id, TeacherEmail = appUser.Email }; _providerContext.LtiMeetings.Add(ltiMeeting); _providerContext.SaveChanges(); return(RedirectToAction("Index")); }
// GET: BlueJeans/Tool/Create public ActionResult Create() { var ltiRequest = GetLtiRequestFromClaim(); if (ltiRequest == null) { return(RedirectToAction("BadRequest", "Error", new { error = "Invalid LTI request" })); } var consumer = _providerContext.Consumers.SingleOrDefault(c => c.Key.Equals(ltiRequest.ConsumerKey)); if (consumer == null) { return(RedirectToAction("BadRequest", "Error", new { error = "Invalid Consumer" })); } var ltiMeetingViewModel = new LtiMeetingViewModel(); return(View(ltiMeetingViewModel)); }