public async Task <AttrCategoryRemoveResponse> AttrCategoryRemove(AttrCategoryRemoveRequest request)
        {
            AttrCategoryRemoveResponse response = new AttrCategoryRemoveResponse();

            try
            {
                var attrCategory = new AttrCategoryModel
                {
                    AttributeId = request.AttributeId,
                    CategoryId  = request.CategoryId
                };
                var command = attrCategory.ToRemoveCommand();

                var result = await _attrCategoryService.SendCommand(command);

                if (result.IsSucess)
                {
                    response.SetSucess();
                }
                else
                {
                    response.SetFail(result.Message);
                }
            }
            catch (Exception e)
            {
                response.SetFail(e);
                _logger.LogError(e, e.Message, request);
            }
            return(response);
        }
Example #2
0
        public async Task <IActionResult> Remove([FromBody] AttrCategoryRemoveRequest request)
        {
            try
            {
                AttrCategoryRemoveResponse response = new AttrCategoryRemoveResponse();
                var results = AttrCategoryRemoveRequestValidator.ValidateModel(request);
                if (results.IsValid)
                {
                    response = await _attrCategoryAppService.AttrCategoryRemove(request);
                }

                else
                {
                    response.SetFail(results.Errors.Select(p => p.ToString()));
                }

                return(Json(response));
            }
            catch (Exception e)
            {
                _logger.LogError(e, Common.Common.GetMethodName(), request);
                throw;
            }
        }