public IActionResult GetByCpf([FromServices] IClienteApplicationService service, string cpf) { if (!ModelState.IsValid) { return(BadRequest(ModelStateValidaton.GetErrors(ModelState))); } try { return(Ok(service.SelectByCpf(cpf))); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public IActionResult Get([FromServices] IEnderecoApplicationService service, Guid id) { if (!ModelState.IsValid) { return(BadRequest(ModelStateValidaton.GetErrors(ModelState))); } try { return(Ok(service.SelectById(id))); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public IActionResult Put([FromServices] IClienteApplicationService service, ClienteModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelStateValidaton.GetErrors(ModelState))); } try { return(Ok(service.Update(model))); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public IActionResult Delete([FromServices] IEnderecoApplicationService service, EnderecoModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelStateValidaton.GetErrors(ModelState))); } try { service.Remove(model); return(Ok()); } catch (Exception e) { return(StatusCode(500, e.Message)); } }