Beispiel #1
0
        public async Task <IActionResult> Post(FilmModel filmModel)
        {
            var film        = _mapper.Map <Film>(filmModel);
            var createdFilm = await _filmService.AddAsync(film);

            return(Ok(createdFilm));
        }
        public async Task <IActionResult> InsertAsync([FromBody] Film film, CancellationToken cancellationToken)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (film == null)
            {
                return(BadRequest());
            }

            film = await _filmsService.AddAsync(film, cancellationToken);

            return(CreatedAtRoute("GetFilm", new { id = film.Id }, film));
        }
Beispiel #3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var s = await _service.AddAsync(FilmToAdd);

            if (s != OperationStatus.OK)
            {
                return(HandleError(s, _action));
            }

            return(RedirectToPage("./Index"));
        }
Beispiel #4
0
 public async Task <OperationResult <IKeyedDto> > PostAsync([FromBody] BaseFilmDto model)
 {
     return(await _service.AddAsync(model));
 }