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

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

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

            var returnModelView = new BaseViewModel <ProductsModelView>
            {
                Sucesso         = true,
                Mensagem        = dataReturn.Product_id != 0 ?  messages.PRODUCT_UPDATE_SUCCESS() : messages.PRODUCT_UPDATE_FAIL(),
                ObjetoDeRetorno = dataReturn
            };

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

            return(Ok(returnModelView));
        }