public void Refresh() { Repertoires.Clear(); var location = _appSettings.Location; if (location != null) { var cinemas = Task.Run(() => _dataStorage.GetCinemaRepertoires(location)).Result; foreach (var cinema in cinemas) { var color = CinemaHelper.TextColor((CinemaType)cinema.CinemaType); var displayName = String.Format("{0} {1}", cinema.CinemaName, cinema.CinemaCity); var shortName = String.Format("{0}{1}", cinema.CinemaName.Substring(0, 2), cinema.CinemaCity.Substring(0, 1)); var group = new Group <MovieShows>(color, displayName, shortName); foreach (var movie in cinema.Movies) { if (_filter.Check(movie)) { var movieShow = new MovieShows(cinema.Id, movie.Id, group.DisplayName, movie.Title, movie.Genres, movie.Shows, movie.Rating); group.Add(movieShow); } } Repertoires.Add(group); } } }
public static IState <T, TError> Decorate <T, TK, TError>(this Func <IState <T, TError> > step, Func <T, TK> transform, IFilter <TK, TError> filter, Action <Exception, ILogger> exceptionHandler) { var state = step(); try { state.LogDebug($"Validating {typeof(T)} object."); TK target = transform(state.StepResult); if (!state.Broken && !filter.Check(target, out TError error)) { state.LogError($"{typeof(T)} is invalid. {typeof(TError)} error registered."); return(state.Invalidate(error)); } state.LogDebug("Validated"); return(state.Next(state.StepResult)); } catch (Exception ex) { exceptionHandler(ex, state); return(state.Fail <T>(ex)); } }