protected override async Task <ICommandResult> Handle(ZoomDeActivateUserCommand command) { ZoomDeActivateUserCommandResult zoomDeActivateUserCommandResult = new ZoomDeActivateUserCommandResult(); var zoomUserModel = _zoomUserRepository.GetByAltId(command.AltId); if (zoomUserModel != null && zoomUserModel.UniqueId == command.UniqueId) { zoomUserModel.UniqueId = String.Empty; zoomUserModel.IsActive = false; _zoomUserRepository.Save(zoomUserModel); } zoomDeActivateUserCommandResult.success = true; return(zoomDeActivateUserCommandResult); }
protected override async Task <ICommandResult> Handle(ZoomValidateUserCommand command) { ZoomValidateUserCommandResult zoomValidateUserCommandResult = new ZoomValidateUserCommandResult(); try { var zoomUserModel = _zoomUserRepository.GetByAltId(command.AltId); var getTimeStamp = GetTimeStamp(zoomUserModel); zoomValidateUserCommandResult.timeStamp = getTimeStamp; //var checkTimeStamp = CheckValidTimeStamp(zoomUserModel); //if (!checkTimeStamp.IsValid) //{ // zoomValidateUserCommandResult.message = checkTimeStamp.Message; // zoomValidateUserCommandResult.success = false; // return zoomValidateUserCommandResult; //} if (zoomUserModel == null) { if (zoomUserModel == null) { zoomValidateUserCommandResult.message = Constant.Zoom.Message.Invalid; } else { zoomValidateUserCommandResult.message = Constant.Zoom.Message.Active; } zoomValidateUserCommandResult.success = false; return(zoomValidateUserCommandResult); } else { string apikey = _settings.GetConfigSetting <string>(SettingKeys.Integration.Zoom.API_Key); string apiSecret = _settings.GetConfigSetting <string>(SettingKeys.Integration.Zoom.Secret_key); var zoomMeetingModel = _zoomMeetingRepository.GetByEventId(zoomUserModel.EventId); //Interactivity levels available zoomValidateUserCommandResult.isAudioAvailable = true; zoomValidateUserCommandResult.isVideoAvailable = true; zoomValidateUserCommandResult.isChatAvailable = true; bool isHost = false; var access = Access.None; var eventHostModel = new EventHostMapping(); if (zoomUserModel.RoleId != 21 && zoomUserModel.RoleId != 26) // If the user is attendee { var userModel = _userRepository.Get(zoomUserModel.UserId); zoomValidateUserCommandResult.email = userModel.Email; zoomValidateUserCommandResult.userName = userModel.FirstName + " " + userModel.LastName; zoomValidateUserCommandResult.UserAltId = userModel.AltId; var transactionDetailsModel = _transactionRepository.GetFeelOnlineDetails(zoomUserModel.TransactionId).Where(s => s.TransactionType == Contracts.Enums.TransactionType.LiveOnline).FirstOrDefault(); if (transactionDetailsModel == null) { return(zoomValidateUserCommandResult); } //interactivity levels available based on ticket cat. if (transactionDetailsModel.TicketCategoryId == 1360) { access = Access.GA; zoomValidateUserCommandResult.isAudioAvailable = false; zoomValidateUserCommandResult.isVideoAvailable = false; zoomValidateUserCommandResult.isChatAvailable = false; } if (transactionDetailsModel.TicketCategoryId == 606) { access = Access.VIP; zoomValidateUserCommandResult.isAudioAvailable = false; zoomValidateUserCommandResult.isVideoAvailable = false; } if (transactionDetailsModel.TicketCategoryId == 12080 || transactionDetailsModel.TicketCategoryId == 19352) { zoomValidateUserCommandResult.isVideoAvailable = false; } } else // Host user { eventHostModel = _eventHostMappingRepository.Get(zoomUserModel.EventHostUserId); zoomValidateUserCommandResult.email = eventHostModel.Email; zoomValidateUserCommandResult.userName = eventHostModel.FirstName + " " + eventHostModel.LastName; isHost = true; } zoomValidateUserCommandResult.meetingNumber = zoomMeetingModel.MeetingNumber.ToString(); zoomValidateUserCommandResult.apikey = apikey; zoomValidateUserCommandResult.secretkey = apiSecret; zoomValidateUserCommandResult.success = true; zoomValidateUserCommandResult.roleId = (zoomUserModel.RoleId == 21 || zoomUserModel.RoleId == 26) ? "1" : "0"; if (!zoomUserModel.IsActive && command.IsZoomLandingPage) { zoomUserModel.UniqueId = command.UniqueId; zoomUserModel.IsActive = true; _zoomUserRepository.Save(zoomUserModel); } var eventDetail = _eventDetailRepository.GetAllByEventId(zoomUserModel.EventId).FirstOrDefault(); zoomValidateUserCommandResult.eventName = eventDetail.Name; if (!command.IsZoomLandingPage) { zoomValidateUserCommandResult.EventAttribute = _eventAttributeRepository.GetByEventDetailId(eventDetail.Id); zoomValidateUserCommandResult.EventHostMappings = _eventHostMappingRepository.GetAllByEventId(eventDetail.EventId).OrderBy(s => s.StartDateTime).ToList(); foreach (var currentEHM in zoomValidateUserCommandResult.EventHostMappings) { currentEHM.StartDateTime = currentEHM.StartDateTime != null?_localTimeZoneConvertProvider.ConvertToLocal((DateTime)currentEHM.StartDateTime, zoomValidateUserCommandResult.EventAttribute.TimeZone) : currentEHM.StartDateTime; currentEHM.EndDateTime = currentEHM.EndDateTime != null?_localTimeZoneConvertProvider.ConvertToLocal((DateTime)currentEHM.EndDateTime, zoomValidateUserCommandResult.EventAttribute.TimeZone) : currentEHM.EndDateTime; } zoomValidateUserCommandResult.EventDetail = _eventDetailRepository.Get(eventDetail.Id); zoomValidateUserCommandResult.LiveEventDetail = _liveEventDetailRepository.GetByEventId(eventDetail.EventId); if (isHost && eventHostModel.StartDateTime != null && zoomValidateUserCommandResult.LiveEventDetail != null) { zoomValidateUserCommandResult.LiveEventDetail.EventStartDateTime = eventHostModel.StartDateTime; } zoomValidateUserCommandResult.Event = _eventRepository.Get(eventDetail.EventId); var eventTicketDetails = _eventTicketDetailRepository.GetByEventDetailId(eventDetail.Id).Where(s => s.IsEnabled).ToList(); var eventTicketAttributes = _eventTicketAttributeRepository.GetByEventTicketDetailIds(eventTicketDetails.Select(s => s.Id)).Where(s => s.IsEnabled).ToList(); if (eventTicketDetails.Select(s => s.TicketCategoryId).Contains(19452) || eventTicketDetails.Select(s => s.TicketCategoryId).Contains(12259)) // if donate { zoomValidateUserCommandResult.IsDonate = true; } if ((access == Access.GA || access == Access.VIP) && eventTicketDetails.Select(s => s.TicketCategoryId).Contains(19350) || eventTicketDetails.Select(s => s.TicketCategoryId).Contains(12079)) // if BSP Exists { var price = getBSPPrice(eventTicketDetails, eventTicketAttributes) - (access == Access.GA ? getGAPrice(eventTicketDetails, eventTicketAttributes) : getVIP(eventTicketDetails, eventTicketAttributes)); var transacions = _transactionRepository.GetAllSuccessfulTransactionByReferralId(zoomUserModel.TransactionId.ToString()); if (price >= 0 && !transacions.Any()) { zoomValidateUserCommandResult.IsUpgradeToBSP = true; zoomValidateUserCommandResult.Price = price; } } if (zoomUserModel.RoleId != 21 && zoomUserModel.RoleId != 26) // If the user is attendee { var transactionDetail = _transactionDetailRepository.GetByTransactionId(zoomUserModel.TransactionId); var eta = _eventTicketAttributeRepository.Get(transactionDetail.Count() > 1 ? transactionDetail.Where(s => s.TransactionType == Contracts.Enums.TransactionType.LiveOnline).FirstOrDefault().EventTicketAttributeId : transactionDetail.FirstOrDefault().EventTicketAttributeId); zoomValidateUserCommandResult.ImportantInformation = eta.TicketCategoryNotes; /* If Recurring then update Event Start & Interactivity start time */ if (eventDetail.EventFrequencyType == Contracts.Enums.EventFrequencyType.Recurring) { UpdateEventSchedule(zoomValidateUserCommandResult, transactionDetail.ToList()); } } else { zoomValidateUserCommandResult.ImportantInformation = zoomValidateUserCommandResult.EventHostMappings.Where(s => s.Id == zoomUserModel.EventHostUserId).FirstOrDefault().ImportantInformation; } } } zoomValidateUserCommandResult.success = true; zoomValidateUserCommandResult.TransactionId = zoomUserModel.TransactionId; return(zoomValidateUserCommandResult); } catch (Exception e) { _logger.Log(LogCategory.Error, new Exception("Failed to validate zoom details " + e.Message, e)); return(zoomValidateUserCommandResult); } }