public IActionResult GetById(string id, [FromServices] IConfiguration config) { if (!string.IsNullOrEmpty(id) && Guid.TryParse(id, out Guid idParsed)) { try { using (IQueryApplication queryApplication = new CrossCutting.IoCManager.Voluntario.Application.Query.QueryApplicationIoCManager(config).GetCurrentIQueryApplicationImplementation()) { string requestId = Guid.NewGuid().ToString(); queryApplication.RequestId = requestId; queryApplication.VoluntarioId = id; var obj = queryApplication.GetById(); 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 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); }