コード例 #1
0
        public IActionResult CreateMovie(MovieDTO movieDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            Movie movie = _mapper.Map <MovieDTO, Movie>(movieDTO);

            _context.Add(movie);
            _context.SaveChanges();

            movieDTO.Id = movie.Id;

            return(CreatedAtAction(nameof(GetMovie), new { Id = movie.Id }, movieDTO));
        }
コード例 #2
0
        public IActionResult CreateCustomer(CustomerDTO customerDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            Customer customer = _mapper.Map <CustomerDTO, Customer>(customerDTO);

            _context.Add(customer);
            _context.SaveChanges();

            customerDTO.Id = customer.Id;

            return(CreatedAtAction(nameof(GetCustomer), new { Id = customer.Id }, customerDTO));

            //return Ok(customerDTO);
        }