Exemple #1
0
 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());
     }
 }
        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);
        }