public IActionResult PostPronostic([FromBody] PronosticDTO pronosticDto) { // map dto to entity var pronostic = mapper.Map <Pronostic>(pronosticDto); try { // save pronosticService.Create(pronostic); return(Ok()); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(ex.Message)); } }
public IActionResult UpdatePronostic([FromRoute] int id, [FromBody] PronosticDTO pronosticDto) { // map dto to entity and set id var pronostic = mapper.Map <Pronostic>(pronosticDto); pronostic.Id = id; try { // save pronosticService.Update(pronostic); return(Ok()); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(ex.Message)); } }