public ProgramsResponse LoadPrimetime(string epoch) { ProgramsResponse programs = new ProgramsResponse(); programs.CodeStatus = StatusHelper.GenerateStatus(CodeStatus.Unknown); try { string uri = System.Configuration.ConfigurationManager.ConnectionStrings["primetime"].ToString(); uri += "?" + epoch; using (WebClient wc = new WebClient()) { string jsonResponse = wc.DownloadString(uri); JsonDataResponse jsonObject = JsonConvert.DeserializeObject <JsonDataResponse>(jsonResponse); programs = JsonMapper.MapJsonDataResponseToProgramResponse(jsonObject); } programs.CodeStatus = StatusHelper.GenerateStatus(CodeStatus.Successful); LoggerHelper.LogOuterParams(LoggerLevel.Trace, "LoadPrimetime", ReflectionHelper.GetPropertiesToBeLogged(programs)); } catch (Exception ex) { programs.CodeStatus = StatusHelper.GenerateStatus(CodeStatus.Timeout); LoggerHelper.LogExceptionParams(LoggerLevel.Exception, "LoadPrimetime", ex); } return(programs); }
public static ProgramsResponse MapJsonDataResponseToProgramResponse(JsonDataResponse apiResponse) { ProgramsResponse programs = new ProgramsResponse(); programs.response = new List <ProgramResponse>(); foreach (List <string> programValues in apiResponse.Data) { ProgramResponse programResponse = new ProgramResponse() { GenericType = programValues[0], Id = programValues[1], IdChannel = programValues[2], Type = programValues[3], Title = programValues[4], Category = programValues[5], Description = programValues[6], Score = programValues[7], Image = programValues[8], EpochStart = programValues[9], EpochEnd = programValues[10] }; programs.response.Add(programResponse); } return(programs); }
public async Task <JsonDataResponse <List <RoomParticipant> > > GetConnectedClients([FromBody] GetConnectedClientsRequest request) { var participants = await _roomParticipantService.GetConnectedClients(request.RoomId); var ownId = _connectionMappingService.GetIdForClient(UserId.ToString()) !; return(JsonDataResponse <List <RoomParticipant> > .Success(participants.Where(x => x.ConnectionId != ownId).ToList())); }
public async Task <JsonDataResponse <List <RoomUiModel> > > GetRooms() { var rooms = await _roomManagementService.GetRooms(); var roomUiModels = rooms.Select(x => new RoomUiModel() { Participants = x.Participants, Id = x.Id, Description = x.Description, Name = x.Name, CreationDate = x.CreationDate, MaxParticipants = x.MaxParticipants }).ToList(); await roomUiModels.ParallelAsync(async x => { x.ParticipantCount = (await _roomParticipantService.GetConnectedClients(x.Id)).Count; }); return(JsonDataResponse <List <RoomUiModel> > .Success(roomUiModels)); }
public IActionResult GetAll() { var newsList = _newsRepository.FindAll().ToList(); JsonDataResponse response; if (newsList.Any()) { response = new JsonDataResponse() { Data = newsList, Error = "", Ok = true }; } else { response = new JsonDataResponse <string, List <News> >() { Data = newsList, Error = "No news!", Ok = false }; } return(Ok(response)); }
public ProgramsResponse LoadNowGuideTV(string[] sortBy, string channel) { ProgramsResponse programs = new ProgramsResponse(); programs.CodeStatus = StatusHelper.GenerateStatus(CodeStatus.Unknown); try { string uri = System.Configuration.ConfigurationManager.ConnectionStrings["programsNow"].ToString(); using (WebClient wc = new WebClient()) { string jsonResponse = wc.DownloadString(uri); JsonDataResponse jsonObject = JsonConvert.DeserializeObject <JsonDataResponse>(jsonResponse); programs = JsonMapper.MapJsonDataResponseToProgramResponse(jsonObject); } if (!String.IsNullOrEmpty(channel)) { programs.response = programs.response.OrderBy(p => p.IdChannel == channel).ToList(); } if (StringHelper.IsNotNullOrEmpty(sortBy)) { } programs.CodeStatus = StatusHelper.GenerateStatus(CodeStatus.Successful); LoggerHelper.LogOuterParams(LoggerLevel.Trace, "LoadNowGuideTV", ReflectionHelper.GetPropertiesToBeLogged(programs)); } catch (Exception ex) { programs.CodeStatus = StatusHelper.GenerateStatus(CodeStatus.Timeout); LoggerHelper.LogExceptionParams(LoggerLevel.Exception, "LoadNowGuideTV", ex); } return(programs); }
public async Task <JsonDataResponse <Guid> > CreateRoom([FromBody] Room roomDetails) { var roomId = await _roomManagementService.CreateRoom(roomDetails); return(JsonDataResponse <Guid> .Success(roomId)); }