コード例 #1
0
 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));
     }
 }
コード例 #2
0
 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));
     }
 }
コード例 #3
0
 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));
     }
 }
コード例 #4
0
 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));
     }
 }