Beispiel #1
0
        public async Task <IActionResult> UpdateFilmAsync(int id, Models.FilmSave film)
        {
            if (id != film.FilmId)
            {
                return(BadRequest(new ProblemDetails
                {
                    Title = "ID Mismatch",
                    Detail = "The ID in the URL does not match the ID in the body of the request.",
                    Instance = HttpContext.TraceIdentifier
                }));
            }

            var filmDb = await _filmsService.GetByIdAsync(id, film.IsoLanguage639Id);

            if (filmDb == null)
            {
                return(NotFound());
            }

            var filmSave = await _filmsService.UpdateAsync(_mapper.Map <Data.Models.Film>(film));

            filmSave.FilmTranslation.FilmI18nId = filmDb.FilmTranslation.FilmI18nId;

            return(Ok(film));
        }
Beispiel #2
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));
        }