public ActionResult UpdateGame(int id, GameCreateUpdateDto gameCreateUpdateDto) { //var model = _mapper.Map<Game>(gameCreateUpdateDto); var model = _repo.GetGame(id); if (model == null) { return(NotFound(model)); } _mapper.Map(gameCreateUpdateDto, model); _repo.SaveChanges(); return(NoContent()); }
public ActionResult CreateGame(GameCreateUpdateDto gameCreateUpdateDto) { var model = _mapper.Map <Game>(gameCreateUpdateDto); if (model == null) { return(NotFound(model)); } _repo.CreateGame(model); _repo.SaveChanges(); var gameReadDto = _mapper.Map <GameReadDto>(model); return(CreatedAtRoute(nameof(GetGame), new { Id = model.ID }, gameReadDto)); }