Exemple #1
0
        public void Execute(CreateDirectorDto request)
        {
            _validator.ValidateAndThrow(request);
            var director = new Director
            {
                Id          = request.Id,
                FirstName   = request.FirstName,
                LastName    = request.LastName,
                Oscars      = request.Oscars,
                MovieNumber = request.MovieNumber,
                Fullname    = request.Fullname
            };

            foreach (var item in request.DirectorMovies)
            {
                director.DirectorMovies.Add(new DirectorMovie
                {
                    MovieId    = item.MovieId,
                    DirectorId = director.Id
                });
            }
            _context.Directors.Add(director);
            _context.SaveChanges();
        }
Exemple #2
0
 public IActionResult Post([FromBody] CreateDirectorDto dto, [FromServices] ICreateDirectorCommand command)
 {
     _executor.ExecuteCommand(command, dto);
     return(StatusCode(StatusCodes.Status201Created));
 }