Пример #1
0
        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());
        }
Пример #2
0
 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
         });
     }
 }
Пример #3
0
 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
         });
     }
 }