public async Task <List <MovieDTO> > List() { var movies = await _movieRepository.FindAllAsync(); return(movies.Select(x => MovieDTO.Create( title: x.Title, releaseDate: x.ReleaseDate, genre: x.Genre, price: x.Price)).ToList()); }
public ObjectResponse <List <MovieDTO> > GetAll() { try { var response = _unitOfWork.MoviesRepository.GetAll().Include(t => t.copies).Include(z => z.actors).ToList(); if (!response.Any()) { return(new ObjectResponse <List <MovieDTO> > { Success = false, Error = "No Movies In Database", Info = DB_GET_ERROR }); } return(new ObjectResponse <List <MovieDTO> > { Success = true, Data = response.Select(x => MovieDTO.Create(x))?.ToList() }); } catch (Exception ex) { return(new ObjectResponse <List <MovieDTO> > { Success = false, Error = ex.GetBaseException().Message, Info = DB_GET_ERROR }); } }
public ObjectResponse <MovieDTO> GetById(int id) { try { var response = _unitOfWork.MoviesRepository.GetAllWhere(x => x.movie_id == id).Include(t => t.copies).Include(z => z.actors)?.FirstOrDefault(); if (response != null) { return(new ObjectResponse <MovieDTO> { Success = true, Data = MovieDTO.Create(response) }); } return(new ObjectResponse <MovieDTO> { Success = false, Error = "No Movie Found", Info = DB_GET_ERROR }); } catch (Exception ex) { return(new ObjectResponse <MovieDTO> { Success = false, Error = ex.GetBaseException().Message, Info = DB_GET_ERROR }); } }