public CameraStatistics getCameraStatisticsForNowById(int cameraId) { DatabaseCamera camera = _dbQueryService.GetCameraById(cameraId); DatabaseRoom room = null; if (camera != null && camera.RoomId != null) { room = _dbQueryService.GetRoomById(camera.RoomId.Value); } DatabasePerSecondStat mostRecentStat = _dbQueryService.GetLatestPerSecondStatForCamera(cameraId); GraphStatistics graphStatistics = _graphStatisticsService.GetLast30MinutesStatistics(cameraId); if (camera != null) { CameraStatistics cameraStatistics = new CameraStatistics { CameraInformation = new CameraInformation(camera), CameraDetails = new CameraDetails(camera), DayTimeOfTheWeekAverageCount = 0, DayTimeOfTheWeekAverageCountAvailable = false, DayTimeOfTheWeekAverageCountDisplayString = null, LastUpdatedTime = null, MostRecentPeopleCount = null, PeriodOfTheDayAverageCount = 0, PeriodOfTheDayAverageCountAvailable = false, PeriodOfTheDayAverageCountDisplayString = null, GraphStatistics = graphStatistics, TempImagePath = null }; if (room != null) { cameraStatistics.CameraDetails.MonitoredArea = room.RoomName; cameraStatistics.CameraInformation.CameraRoomName = room.RoomName; cameraStatistics.CameraInformation.RoomId = room.RoomId; } if (mostRecentStat != null) { cameraStatistics.LastUpdatedTime = mostRecentStat.DateTime; cameraStatistics.MostRecentPeopleCount = mostRecentStat.NumDetectedObjects; } if (camera.LocationId != null) { cameraStatistics.CameraDetails.Location = new LocationDetails(_dbQueryService.GetLocationById(camera.LocationId.Value)); } cameraStatistics.CameraInformation.TempImagePath = GetTempPathFromFullPath(camera.ImagePath); return(cameraStatistics); } return(null); }