Exemplo n.º 1
0
        public async Task <IActionResult> CreateFilmAsync(Models.FilmSave film)
        {
            var filmSave = await _filmsService.CreateAsync(_mapper.Map <Data.Models.Film>(film));

            film.FilmId = filmSave.FilmId;

            return(CreatedAtAction(
                       nameof(GetByIdAsync),
                       new { id = film.FilmId, languageId = film.IsoLanguage639Id },
                       film));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PostAsync([FromBody] Film postViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.ErrorsToList()));
            }

            var result = await _dataService.CreateAsync(postViewModel);

            if (result.Succeeded)
            {
                return(new CreatedResult(Request.GetDisplayUrl() + $"/{postViewModel.Id}", postViewModel));
            }

            return(result.ToActionResult());
        }