public GetFilmsResult GetAll() { try { using (var sqlConnection = new SqlConnection(_connectionString)) { sqlConnection.Open(); var films = sqlConnection.Query <FilmEntity>("SELECT [Title],[Year] FROM [dbo].[Films]"); return(GetFilmsResult.Success(films)); } } catch (Exception) { return(GetFilmsResult.Unsuccessful()); } }
private static IEnumerable <Film> Wishlist(GetFilmsResult result) => result.Result == RepositoryResult.Failed ? EmptyFilmsList() : FilmsFromEntities(result.Value);
private AddFilmResult AddFilmUnlessFilmsCannotBeRetrieved(string title, int year, GetFilmsResult getFilmsResult) => getFilmsResult.Result == RepositoryResult.Failed ? AddFilmResult.Failed : AddFilmUnlessDuplicate(title, year, getFilmsResult.Value);