예제 #1
0
        public async Task <IActionResult> GetUnreadMessagesForVideoOfficerAsync(Guid conferenceId)
        {
            _logger.LogDebug($"GetMessages for {conferenceId}");
            try
            {
                var messages = await _videoApiClient.GetInstantMessageHistoryAsync(conferenceId);

                if (messages.IsNullOrEmpty())
                {
                    return(Ok(new UnreadInstantMessageConferenceCountResponse()));
                }

                var conference = await _conferenceCache.GetOrAddConferenceAsync
                                 (
                    conferenceId,
                    () => _videoApiClient.GetConferenceDetailsByIdAsync(conferenceId)
                                 );

                var unreadInstantMessageConferenceCountResponseMapper = _mapperFactory.Get <Conference, IList <InstantMessageResponse>, UnreadInstantMessageConferenceCountResponse>();
                var response = unreadInstantMessageConferenceCountResponseMapper.Map(conference, messages.ToList());

                return(Ok(response));
            }
            catch (VideoApiException e)
            {
                _logger.LogError(e, $"Unable to get messages for conference {conferenceId}");
                return(StatusCode(e.StatusCode, e.Response));
            }
        }
예제 #2
0
        public async Task <IActionResult> LeaveConsultationAsync(LeavePrivateConsultationRequest request)
        {
            var participant = new Participant();

            try
            {
                var conference = await GetConference(request.ConferenceId);

                participant = conference.Participants?.SingleOrDefault(x => x.Id == request.ParticipantId);
                if (participant == null)
                {
                    return(NotFound());
                }

                var leaveConsultationRequestMapper = _mapperFactory.Get <LeavePrivateConsultationRequest, LeaveConsultationRequest>();
                var mappedRequest = leaveConsultationRequestMapper.Map(request);
                await _videoApiClient.LeaveConsultationAsync(mappedRequest);

                return(NoContent());
            }
            catch (VideoApiException e)
            {
                if (participant != null)
                {
                    _logger.LogError(e, "Participant: {Username} was not able to leave the private consultation. An error occured", participant.Username);
                }
                else
                {
                    _logger.LogError(e, "Invalid participant");
                }

                return(StatusCode(e.StatusCode, e.Response));
            }
        }
 public IActionResult GetUserProfile()
 {
     try
     {
         var claimsPrincipalToUserProfileResponseMapper = _mapperFactory.Get <ClaimsPrincipal, UserProfileResponse>();
         var response = claimsPrincipalToUserProfileResponseMapper.Map(User);
         return(Ok(response));
     }
     catch (Exception e)
     {
         const string message = "User does not have permission";
         _logger.LogError(e, message);
         return(Unauthorized(message));
     }
 }
        public async Task <IActionResult> GetParticipantRoomForParticipant(Guid conferenceId, Guid participantId,
                                                                           [FromQuery] string participantType = "Civilian")
        {
            try
            {
                var room = participantType switch
                {
                    "Witness" => await _videoApiClient.GetWitnessRoomForParticipantAsync(conferenceId,
                                                                                         participantId),
                    "Judicial" => await _videoApiClient.GetJudicialRoomForParticipantAsync(conferenceId,
                                                                                           participantId),
                    _ => await _videoApiClient.GetInterpreterRoomForParticipantAsync(conferenceId, participantId)
                };
                var conference = await GetConference(conferenceId);

                var participant = conference.Participants.First(x => x.Id == participantId);
                var mapper      =
                    _mapperFactory.Get <SharedParticipantRoomResponse, Participant, bool, SharedParticipantRoom>();
                var response = mapper.Map(room, participant, participantType == "Witness");
                return(Ok(response));
            }
            catch (VideoApiException e)
            {
                _logger.LogError(e,
                                 "Unable to retrieve interpreter room for participant {ParticipantId} for conference: {ConferenceId}",
                                 participantId, conferenceId);
                return(StatusCode(e.StatusCode, e.Response));
            }
        }
예제 #5
0
        public void MapFrom(string source)
        {
            dynamic mapper = _factory.Get(source);

            var instance = mapper.Map(source);

            // do something with instance...
        }
        public async Task <IActionResult> GetVideoEndpointsForConferenceAsync(Guid conferenceId)
        {
            try
            {
                var endpoints = await _videoApiClient.GetEndpointsForConferenceAsync(conferenceId);

                var videoEndpointResponseMapper = _mapperFactory.Get <EndpointResponse, int, VideoEndpointResponse>();
                var response = endpoints.Select(videoEndpointResponseMapper.Map).ToList();

                return(Ok(response));
            }
            catch (VideoApiException e)
            {
                _logger.LogError(e, "Endpoints could not be fetched for ConferenceId: {ConferenceId}", conferenceId);
                return(StatusCode(e.StatusCode, e.Response));
            }
        }
예제 #7
0
        /// <summary>
        /// Purpose : Get Application Text by id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <ApplicationTextEntity> GetApplicationTextById(int id)
        {
            var ApplicationText = await _repository.GetAsync(id);

            if (ApplicationText == null)
            {
                return(null);
            }
            return(_mapperFactory.Get <ApplicationText, ApplicationTextEntity>(ApplicationText));
        }
예제 #8
0
        public async Task <ActionResult <List <ConferenceForJudgeResponse> > > GetConferencesForJudgeAsync()
        {
            _logger.LogDebug("GetConferencesForJudge");

            try
            {
                var conferenceForJudgeResponseMapper = _mapperFactory.Get <JudgeConference, ConferenceForJudgeResponse>();
                var username            = User.Identity.Name;
                var conferencesForJudge = await _videoApiClient.GetConferencesTodayForJudgeByUsernameAsync(username);

                var response = conferencesForJudge
                               .Select(conferenceForJudgeResponseMapper.Map)
                               .ToList();
                return(Ok(response));
            }
            catch (VideoApiException e)
            {
                _logger.LogError(e, "Unable to get conferences for user");
                return(StatusCode(e.StatusCode, e.Response));
            }
        }
        public ActionResult <ClientSettingsResponse> GetClientConfigurationSettings()
        {
            var response = new ClientSettingsResponse();

            try
            {
                var clientSettingsResponseMapper = _mapperFactory.Get <AzureAdConfiguration, HearingServicesConfiguration, KinlyConfiguration, ClientSettingsResponse>();
                response = clientSettingsResponseMapper.Map(_azureAdConfiguration, _servicesConfiguration, _kinlyConfiguration);
                return(Ok(response));
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message, $"Unable to retrieve client configuration settings for ClientId: {response.ClientId}");
                return(BadRequest(e.Message));
            }
        }
예제 #10
0
        private CallbackEvent TransformAndMapRequest(ConferenceEventRequest request, Conference conference)
        {
            var isPhoneEvent = string.IsNullOrEmpty(request.Phone);

            if (!isPhoneEvent)
            {
                return(null);
            }

            var callbackEventMapper = _mapperFactory.Get <ConferenceEventRequest, Conference, CallbackEvent>();
            var callbackEvent       = callbackEventMapper.Map(request, conference);

            request.EventType = Enum.Parse <EventType>(callbackEvent.EventType.ToString());

            return(callbackEvent);
        }
예제 #11
0
        public async Task <ActionResult <IList <CourtRoomsAccountResponse> > > GetCourtRoomsAccounts([FromQuery] VhoConferenceFilterQuery query)
        {
            try
            {
                var response = await _userApiClient.GetJudgesAsync();

                var courtRoomsAccountResponsesMapper = _mapperFactory.Get <IEnumerable <UserResponse>, IEnumerable <string>, List <CourtRoomsAccountResponse> >();
                var accountList = courtRoomsAccountResponsesMapper.Map(response, query.UserNames);

                return(Ok(accountList));
            }
            catch (UserApiException e)
            {
                _logger.LogError(e, "Unable to get list of court rooms accounts");
                return(StatusCode(e.StatusCode, e.Response));
            }
        }
예제 #12
0
        public async Task <ActionResult <SelfTestPexipResponse> > GetPexipConfig()
        {
            try
            {
                var config = await _videoApiClient.GetPexipServicesConfigurationAsync();

                var selfTestPexipResponseMapper = _mapperFactory.Get <PexipConfigResponse, SelfTestPexipResponse>();
                var response = selfTestPexipResponseMapper.Map(config);

                return(Ok(response));
            }
            catch (VideoApiException e)
            {
                _logger.LogError(e, $"Unable to get Pexip configuration");
                return(StatusCode(e.StatusCode, e.Response));
            }
        }
예제 #13
0
        /// <summary>
        /// Purpose : Create new Fuel Capacity
        /// </summary>
        /// <param name="entityFuel"></param>
        /// <returns></returns>
        public async Task <FuelMasterEntity> AddFuel(FuelMasterEntity entityFuel)
        {
            entityFuel.Ipaddress = Helper.GetIPAddress(Helper.httpRequest);
            //var isExist = _repository.Exists(x => x.FuelCapacity.ToLowerInvariant() == entityFuel.FuelCapacity.ToLowerInvariant() && !x.IsDeleted);
            //if (isExist)
            //    throw new Exception(_messageService.GetString("Exist"));

            FuelMaster oFuel = _mapperFactory.Get <FuelMasterEntity, FuelMaster>(entityFuel);

            _repository.AddAsync(oFuel);
            var oResult = await _unitOfWork.SaveChangesAsync();

            if (oFuel.FuelId == 0)
            {
                throw new Exception(_messageService.GetString("AddFailed"));
            }
            return(_mapperFactory.Get <FuelMaster, FuelMasterEntity>(oFuel));
        }
예제 #14
0
        public async Task <IActionResult> UpdateParticipantStatusAsync(Guid conferenceId,
                                                                       UpdateParticipantStatusEventRequest updateParticipantStatusEventRequest)
        {
            var conference = await _conferenceCache.GetOrAddConferenceAsync(conferenceId,
                                                                            () => _videoApiClient.GetConferenceDetailsByIdAsync(conferenceId));

            var participantId          = GetIdForParticipantByUsernameInConference(conference);
            var eventTypeMapper        = _mapperFactory.Get <EventType, string>();
            var conferenceEventRequest = new ConferenceEventRequest
            {
                ConferenceId  = conferenceId.ToString(),
                ParticipantId = participantId.ToString(),
                EventId       = Guid.NewGuid().ToString(),
                EventType     = updateParticipantStatusEventRequest.EventType,
                TimeStampUtc  = DateTime.UtcNow,
                Reason        = eventTypeMapper.Map(updateParticipantStatusEventRequest.EventType)
            };

            var callbackEventMapper = _mapperFactory.Get <ConferenceEventRequest, Conference, CallbackEvent>();
            var callbackEvent       = callbackEventMapper.Map(conferenceEventRequest, conference);
            var handler             = _eventHandlerFactory.Get(callbackEvent.EventType);

            try
            {
                await handler.HandleAsync(callbackEvent);
            }
            catch (ConferenceNotFoundException e)
            {
                _logger.LogError(e, $"Unable to retrieve conference details");
                return(BadRequest(e));
            }

            try
            {
                await _videoApiClient.RaiseVideoEventAsync(conferenceEventRequest);

                return(NoContent());
            }
            catch (VideoApiException e)
            {
                _logger.LogError(e, $"Unable to update participant status for " +
                                 $"participant: {participantId} in conference: {conferenceId}");
                return(StatusCode(e.StatusCode, e.Response));
            }
        }
예제 #15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="entityUser"></param>
        /// <returns></returns>
        public async Task <UserEntity> AddUser(UserEntity entityUser)
        {
            var _roleIdExist = _repositoryRole.Exists(x => x.RoleId == entityUser.RoleId);

            if (!_roleIdExist)
            {
                return(null);
            }

            //Set Password
            entityUser.Password = Helper.GenerateSHA256String(entityUser.Password);

            var isExist = _repository.Exists(x => (x.EmailAddress.ToLowerInvariant() == entityUser.EmailAddress.ToLowerInvariant() && x.RoleId == entityUser.RoleId));

            if (isExist)
            {
                return(null);
            }

            User oUser = _mapperFactory.Get <UserEntity, User>(entityUser);

            _repository.AddAsync(oUser);
            var oResult = await _unitOfWork.SaveChangesAsync();

            if (oUser.UserId == 0)
            {
                return(null);                   //throw new Exception(_messageService.GetString("AddFailed"));
            }
            return(_mapperFactory.Get <User, UserEntity>(oUser));
        }