public IActionResult GetByCPF(string cpf, [FromServices] IConfiguration config) { if (long.TryParse(cpf, out long cpfParsed)) { try { using (IQueryApplication queryApplication = new CrossCutting.IoCManager.Voluntario.Application.Query.QueryApplicationIoCManager(config).GetCurrentIQueryApplicationImplementation()) { string requestId = Guid.NewGuid().ToString(); queryApplication.RequestId = requestId; queryApplication.Cpf = cpfParsed; var obj = queryApplication.GetByCpf(); if (obj != null) { return(StatusCode(200, JToken.FromObject(obj))); } else { return(StatusCode(404)); } } } catch (Exception ex) { //TODO: log de exception return(StatusCode(500)); } } else { return(BadRequest()); } }
public void GetByCpf() { IVoluntario obj = null; Int64 cpf = ListaAll()[0].Cpf; using (IQueryApplication qry = new CrossCutting.IoCManager.Voluntario.Application.Query.QueryApplicationIoCManager(base.Config).GetCurrentIQueryApplicationImplementation()) { qry.RequestId = RequestId; qry.Cpf = cpf; try { obj = qry.GetByCpf(); } catch (Exception ex) { throw ex; } } Assert.IsNotNull(obj); Assert.IsNotEmpty(obj.Id); }