public async Task <IActionResult> Put(long id, [FromBody] AcademiaInputDTO inputDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var academia = new AcademiaEntity(inputDTO.Nome, inputDTO.Endereco, inputDTO.Email); academia.Id = id; var result = await _service.Put(academia); if (result != null) { return(Ok(result)); } else { return(BadRequest()); } } catch (ArgumentException e) { return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message)); } }
public async Task <IActionResult> Post([FromBody] AcademiaInputDTO inputDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var academia = new AcademiaEntity(inputDTO.Nome, inputDTO.Endereco, inputDTO.Email); var result = await _service.Post(academia); if (result != null) { return(Created(new Uri(Url.Link("GetWithId", new { id = result.Id })), result)); } else { return(BadRequest()); } } catch (ArgumentException e) { return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message)); } }
public async Task <AcademiaEntity> Put(AcademiaEntity academia) { return(await _repository.UpdateAsync(academia)); }
public async Task <AcademiaEntity> Post(AcademiaEntity academia) { return(await _repository.InsertAsync(academia)); }