private StatusViewModel GetStatusViewModel() { var viewModel = StatusViewModel.Default; try { var redisKey = "Jabbot:LastSeen"; if (RedisConnection.Keys.Exists(0, redisKey).Result) { var dateTimeOffsetString = RedisConnection.Strings.GetString(0, redisKey).Result; dateTimeOffsetString = dateTimeOffsetString.Trim('\"'); var lastSeen = DateTimeOffset.Parse(dateTimeOffsetString); viewModel = new StatusViewModel(lastSeen); } } catch(Exception ex) { Logger.ErrorException("An error occured while populating the StatusViewModel.", ex); } return viewModel; }
public HomeViewModel(JabbotStatisticsViewModel jabbotStatistics, IEnumerable<SprocketStatisticsViewModel> sprocketStatistics, StatusViewModel status) { JabbotStatistics = jabbotStatistics ?? JabbotStatisticsViewModel.Default; SprocketStatistics = sprocketStatistics ?? new List<SprocketStatisticsViewModel>(); Status = status ?? StatusViewModel.Default; }