Example #1
0
        public IHttpActionResult Get(ODataQueryOptions <Movie> queryOptions)
        {
            var query = default(IQueryable <Movie>);

            query = MovieAppService.GetAll();

            return(HandleQueryable <Movie, MovieViewModel>(query, queryOptions));
        }
        async Task Validation(AddChampionshipCommand command)
        {
            if (command is null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            var validator = new AddChampionshipCommandValidator().Validate(command);

            if (!validator.IsValid)
            {
                throw new ApplicationException(string.Join(" | ", validator.Errors.Select(x => x.ErrorMessage)));
            }

            var movies = await movieAppService.GetAll();

            if (!command.Movies.TrueForAll(x => movies.Select(e => e.Id).Contains(x.Id)))
            {
                throw new ApplicationException(string.Format(ResourceMessage.NotExist, "Movies"));
            }
        }