public IActionResult Post([FromBody] TeamModelIn teamIn) { try { if (ModelState.IsValid) { Team team = teamIn.TransformToEntity(); team = teamService.CreateTeam(team); TeamModelOut modelOut = new TeamModelOut(team); return(CreatedAtRoute("Get", new { id = team.TeamId }, modelOut)); } else { return(BadRequest(ModelState)); } } catch (NotUniqueException ex) { return(BadRequest(ex.Message)); } catch (Exception ex) { return(BadRequest("Ha ocurrido un error" + ex.Message)); } }
public IActionResult Put(int id, [FromBody] TeamModelIn modelIn) { try { if (ModelState.IsValid) { Team team = modelIn.TransformToEntity(); teamService.UpdateTeam(id, team); return(Ok("El equipo ha sido modificado")); } else { return(BadRequest(ModelState)); } } catch (ArgumentException ex) { return(BadRequest(ex.Message)); }catch (NotExistsException ex) { return(BadRequest(ex.Message)); }catch (NotUniqueException ex) { return(BadRequest(ex.Message)); } }