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

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

            var dataReturn = _mapper.Map <List <ProductsModelView> >(search);

            var returnModelView = new BaseViewModel <List <ProductsModelView> >
            {
                Sucesso         = true,
                Mensagem        = dataReturn.Count > 0 ?  messages.PRODUCT_CREATE_SUCCESS() : messages.PRODUCT_CREATE_FAIL(),
                ObjetoDeRetorno = dataReturn
            };

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

            return(Ok(returnModelView));
        }