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 IActionResult GetByName(string name, [FromServices] IConfiguration config) { if (!string.IsNullOrEmpty(name)) { try { using (IQueryApplication queryApplication = new CrossCutting.IoCManager.Voluntario.Application.Query.QueryApplicationIoCManager(config).GetCurrentIQueryApplicationImplementation()) { string requestId = Guid.NewGuid().ToString(); queryApplication.RequestId = requestId; queryApplication.VoluntarioName = name; var obj = queryApplication.GetByName(); if (obj != null) { return(StatusCode(200, JArray.FromObject(obj))); } else { return(StatusCode(404)); } } } catch (Exception ex) { //TODO: log de exception return(StatusCode(500)); } } else { return(BadRequest()); } }
private IList <IVoluntario> ListaAll() { IList <IVoluntario> obj = null; if (Voluntario == null) { Setup(); } //Add //AddListVolunt(); using (IQueryApplication qry = new CrossCutting.IoCManager.Voluntario.Application.Query.QueryApplicationIoCManager(base.Config).GetCurrentIQueryApplicationImplementation()) { try { qry.RequestId = RequestId; int current = 1; obj = qry.GetAllPaged(current); } catch (Exception ex) { throw ex; } } return(obj); }
public void TestLogIn_Negative() { bool result = false; ICryptography _crypto = new CrossCutting.IoCManager.Cryptography.CryptographyIoCManager(base.Config).GetICryptographyCurrentImplementation(); using (IQueryApplication qry = new CrossCutting.IoCManager.Voluntario.Application.Query.QueryApplicationIoCManager(base.Config).GetCurrentIQueryApplicationImplementation()) { qry.RequestId = RequestId; qry.Email = base.Voluntario.Email; qry.Pass = _crypto.Encrypt("qqqqqqqqqqqqqqqq"); result = qry.EmailLogIn(); } Assert.IsFalse(result); }
public void GetById() { IVoluntario obj = null; string id = ListaAll()[0].Id; using (IQueryApplication qry = new CrossCutting.IoCManager.Voluntario.Application.Query.QueryApplicationIoCManager(base.Config).GetCurrentIQueryApplicationImplementation()) { qry.RequestId = RequestId; qry.VoluntarioId = id; try { obj = qry.GetById(); } catch (Exception ex) { throw ex; } } Assert.IsNotNull(obj); Assert.IsNotEmpty(obj.Id); }
public void GetByName() { IList <IVoluntario> obj = null; string nome = ListaAll()[0].Nome.Split(':')[0]; using (IQueryApplication qry = new CrossCutting.IoCManager.Voluntario.Application.Query.QueryApplicationIoCManager(base.Config).GetCurrentIQueryApplicationImplementation()) { qry.RequestId = RequestId; qry.VoluntarioName = nome; try { obj = qry.GetByName(); } catch (Exception ex) { throw ex; } } Assert.IsNotNull(obj); Assert.GreaterOrEqual(obj.Count, 1); Assert.IsNotEmpty(obj[0].Id); }