Beispiel #1
0
        public async Task <IActionResult> GetProductsByIndustryAsync(
            string model,
            [FromServices] IProductsAppService productsAppService
            )
        {
            if (model is null || !ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            //var data = _mapper.Map<ProductsDomain>(model);
            var search = await productsAppService.GetProductsByIndustryAsync(model);

            var dataReturn      = _mapper.Map <List <ProductsModelView> >(search);
            var returnModelView = new BaseViewModel <List <ProductsModelView> >
            {
                Sucesso         = true,
                Mensagem        = dataReturn.Count <= 0 ? messages.INDUSTRY_NOT_FOUND() : messages.PRODUCTS_RESULT(),
                ObjetoDeRetorno = dataReturn
            };

            #region .::Log Requests
            loggerService.SaveLoggerSuccess(new LoggerDomain
            {
                objects = JsonConvert.SerializeObject(returnModelView),
                userId  = UsuarioId
            });
            #endregion

            return(Ok(returnModelView));
        }