Exemplo n.º 1
0
        public ActionResult <IEnumerable <ErrorDTO> > GetAll(string description, string level, string origin, int environmentId)
        {
            if (description != null)
            {
                return(Ok(_service.FindByEnvironmentIdAndDescription(environmentId, description)
                          .Select(x => _mapper.Map <ErrorDTO>(x))
                          .ToList()));
            }

            if (level != null)
            {
                return(Ok(_service.FindByEnvironmentIdAndLevelName(environmentId, level)
                          .Select(x => _mapper.Map <ErrorDTO>(x))
                          .ToList()));
            }

            if (origin != null)
            {
                return(Ok(_service.FindByEnvironmentIdAndOrigin(environmentId, origin)
                          .Select(x => _mapper.Map <ErrorDTO>(x))
                          .ToList()));
            }

            return(Ok(_service.FindByEnvironmentId(environmentId)
                      .Select(x => _mapper.Map <ErrorDTO>(x))
                      .ToList()));
        }