public async Task <ActionResult> DeleteFilm(int id) { FilmDetailsModel film = await _filmService.DeleteFilmAsync(id); if (film != null) { return(Ok(film.Name)); } return(BadRequest()); }
public async Task EditFilmAsync(FilmDetailsModel model) { Film film = _mapper.Map <FilmDetailsModel, Film>(model); if (film == null) { throw new FilmNotExistException($"Film with Id{film.FilmId} does not exist"); } await _filmRepository.EditFilmAsync(film); }
public async Task <ActionResult> AddFilm([FromBody] FilmDetailsViewModel model) { if (ModelState.IsValid) { FilmDetailsModel film = _mapper.Map <FilmDetailsViewModel, FilmDetailsModel>(model); if (model.FilmId == 0) { await _filmService.AddFilmAsync(film); } else { await _filmService.EditFilmAsync(film); } return(Ok()); } return(BadRequest(ModelState)); }
public async Task AddFilmAsync(FilmDetailsModel model) { Film film = _mapper.Map <FilmDetailsModel, Film>(model); await _filmRepository.AddFilmAsync(film); }
public async Task <ActionResult <FilmDetailsViewModel> > GetFilmDetails(int id) { FilmDetailsModel film = await _filmService.GetFilmByIdAsync(id); return(Ok(_mapper.Map <FilmDetailsModel, FilmDetailsViewModel>(film))); }