public async Task <ProductAttributeValueCrudResponse> AddOrUpdate(ProductAttributeValueCrudRequest request) { var response = new ProductAttributeValueCrudResponse(); try { var user = await _context.GetCurrentCustomer(); var command = request.ToCommand(user.Id); var result = await _productAttributeValue.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); }
public async Task <IActionResult> DeleteProductAttributeValue([FromBody] ProductAttributeValueCrudRequest request) { try { var response = new ProductAttributeValueCrudResponse(); var validate = ProductAttributeValueRequestValidator.ValidateModel(request); if (validate.IsValid) { // Đổi trạng thái về Lock để ẩn thuộc tính request.Status = EnumDefine.StatusEnum.Lock; response = await _productAttributeValueAppService.AddOrUpdate(request); } else { response.SetFail(validate.Errors.Select(p => p.ToString())); } return(Json(response)); } catch (Exception e) { _logger.LogError(e, Common.Common.GetMethodName(), request); throw; } }