public async Task <ResultChampionshipCommand> Create(AddChampionshipCommand command) { await Validation(command); var result = StartChampionship(command.Movies); return(result); }
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")); } }