Beispiel #1
0
 private Filme ToDomainModel(FilmeInputModel inputModel)
 {
     return(new Filme
     {
         Id = inputModel.Id,
         Titulo = inputModel.Titulo,
         AnoLancamento = inputModel.AnoLancamento,
         Resumo = inputModel.Resumo
     });
 }
Beispiel #2
0
        public IActionResult Create([FromBody] FilmeInputModel inputModel)
        {
            if (inputModel == null)
            {
                return(BadRequest());
            }

            var model = ToDomainModel(inputModel);

            service.AddFilme(model);

            var outputModel = ToOutputModel(model);

            return(CreatedAtRoute("GetFilme", new { id = outputModel.Id }, outputModel));
        }
Beispiel #3
0
        public IActionResult Update(int id, [FromBody] FilmeInputModel inputModel)
        {
            if (inputModel == null || id != inputModel.Id)
            {
                return(BadRequest());
            }

            if (!service.FilmeExists(id))
            {
                return(NotFound());
            }

            var model = ToDomainModel(inputModel);

            service.UpdateFilme(model);

            return(NoContent());
        }