public override async Task <GetAllMoviesResponse> GetAll(GetAllMoviesRequest request, ServerCallContext serverCallContext) { var response = new GetAllMoviesResponse(); try { await using (var db = new MovieDOContext()) { var movie = db.Movies.Select(x => x).ToList(); response.Movies.Add(_mapper.Map <List <Movie> >(movie)); } } catch (Exception ex) { string exception = ex.Message; } return(response); }
public GetAllMoviesResponse GetAllMovies() { GetAllMoviesResponse response = new GetAllMoviesResponse() { IsSuccess = true }; try { response.MoviesList = MoviesManager.GetAllMovies().OrderByDescending(x => x.Id).ToList(); } catch (Exception e) { response.IsSuccess = false; response.ErrorMessage = e.Message; } return(response); }