public HttpResponseMessage TotalRentalHistory(HttpRequestMessage request) { _requiredRepositories = new List<Type> { typeof (Customer), typeof (Stock), typeof (Rental), typeof (Customer), typeof (Movie) }; return CreateHttpResponse(request, _requiredRepositories, () => { HttpResponseMessage response = null; var _totalMoviesRentalHistory = new List<TotalRentalHistoryViewModel>(); var movies = _moviesRepository.GetAll(); foreach (var movie in movies) { var _totalRentalHistory = new TotalRentalHistoryViewModel { ID = movie.ID, Title = movie.Title, Image = movie.Image, Rentals = GetMovieRentalHistoryPerDates(movie.ID) }; if (_totalRentalHistory.TotalRentals > 0) _totalMoviesRentalHistory.Add(_totalRentalHistory); } response = request.CreateResponse(HttpStatusCode.OK, _totalMoviesRentalHistory); return response; }); }
public HttpResponseMessage TotalRentalHistory(HttpRequestMessage request) { return CreateHttpResponse(request, () => { HttpResponseMessage response = null; List<TotalRentalHistoryViewModel> _totalMoviesRentalHistory = new List<TotalRentalHistoryViewModel>(); var movies = _moviesRepository.GetAll(); foreach (var movie in movies) { TotalRentalHistoryViewModel _totalRentalHistory = new TotalRentalHistoryViewModel() { ID = movie.ID, Title = movie.Title, Image = movie.Image, Rentals = GetMovieRentalHistoryPerDates(movie.ID) }; if (_totalRentalHistory.TotalRentals > 0) _totalMoviesRentalHistory.Add(_totalRentalHistory); } response = request.CreateResponse<List<TotalRentalHistoryViewModel>>(HttpStatusCode.OK, _totalMoviesRentalHistory); return response; }); }