public async Task <IList <ResponsibleResponseTO> > ListAsync(ResponsibleFilterTO filterTO)
        {
            var responsibleSpecification = new BaseSpecification <ResponsibleEntity>();

            responsibleSpecification.AddCriteria(filterTO.UnifiedProcessNumber, responsible => responsible.ProcessResponsible.Any(processResponsible => processResponsible.Process != null && !string.IsNullOrEmpty(processResponsible.Process.UnifiedProcessNumber) && processResponsible.Process.UnifiedProcessNumber.Replace("-", string.Empty).Replace(".", string.Empty).Contains(filterTO.UnifiedProcessNumber.Replace("-", string.Empty).Replace(".", string.Empty))));
            responsibleSpecification.AddCriteria(filterTO.Cpf, responsible => responsible.Cpf == Convert.ToInt64(filterTO.Cpf.Replace(".", string.Empty).Replace("-", string.Empty)));
            responsibleSpecification.AddCriteria(filterTO.Name, responsible => responsible.Name.Trim().ToUpper().Contains(filterTO.Name.Trim().ToUpper()));

            responsibleSpecification.ApplyOrderByDescending(responsible => responsible.Name);
            responsibleSpecification.ApplyPaging(filterTO.Page.GetValueOrDefault(), filterTO.PerPage.GetValueOrDefault());

            var listResponsible = await _responsibleRepository.ListAsync(responsibleSpecification);

            return(listResponsible.ToList().ToListResponsibleResponseTO());
        }
        public void ValidateListAsync(ResponsibleFilterTO filterTO)
        {
            var errors = new List <ErrorsTO>();

            if (filterTO.PerPage > 50)
            {
                errors.Add(new ErrorsTO
                {
                    Field      = "PerPage",
                    Validation = Messaging.ExceededMaximumValue
                });
            }

            if (errors.Count > 0)
            {
                throw new ErrorsException(errors);
            }
        }
Пример #3
0
        public async Task <IActionResult> ListAsync([FromQuery] ResponsibleFilterTO filterTO)
        {
            IList <ResponsibleResponseTO> listResponseTO = null;

            try
            {
                listResponseTO = await _responsibleFacade.ListAsync(filterTO);
            }
            catch (ErrorsException ex)
            {
                return(BadRequest(ex.ErrorResponse));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "AddAsync", new object[] { filterTO });
                return(StatusCode((int)HttpStatusCode.InternalServerError, ErrorHelper.GenericError(ex)));
            }

            return(Ok(listResponseTO));
        }
 public async Task <IList <ResponsibleResponseTO> > ListAsync(ResponsibleFilterTO filterTO)
 {
     _responsibleService.ValidateListAsync(filterTO);
     return(await _responsibleService.ListAsync(filterTO));
 }