public void ChangeAttribute(ProductGroupAttributeAddCommand command) { InitConditions(); if (!Conditions.ContainsKey(EnumDefine.ProductGroupConfigTypeEnum.Attribute)) { Conditions.Add(EnumDefine.ProductGroupConfigTypeEnum.Attribute, new ProductGroupCondition( EnumDefine.ProductGroupConfigTypeEnum.Attribute, new ProductGroupAttributeCondition() )); } ProductGroupAttributeCondition condition = (ProductGroupAttributeCondition)Conditions[EnumDefine.ProductGroupConfigTypeEnum.Attribute].Config; condition.Change(command.AttributeId, command.AttributeValueIds); Conditions[EnumDefine.ProductGroupConfigTypeEnum.Attribute].ChangeConfig(condition); UpdatedUid = command.UpdatedUid; UpdatedDateUtc = command.CreatedDateUtc; }
public async Task <ICommandResult> Handle(ProductGroupAttributeAddCommand message) { try { ICommandResult result; RProductGroup rproductGroup = await _productGroupService.Get(message.ProductGroupId); if (rproductGroup == null) { result = new CommandResult() { Message = "ProductGroup not found", ObjectId = "", Status = CommandResult.StatusEnum.Fail, ResourceName = ResourceKey.ProductGroup_NotFound }; return(result); } ProductGroup productGroup = new ProductGroup(rproductGroup); productGroup.AddAttribute(message); await _productGroupService.ChangeConditions(productGroup.Id, productGroup.Conditions, productGroup.UpdatedUid, productGroup.UpdatedDateUtc); result = new CommandResult() { Message = "", ObjectId = productGroup.Id, Status = CommandResult.StatusEnum.Sucess }; return(result); } catch (Exception e) { e.Data["Param"] = message; ICommandResult result = new CommandResult() { Message = e.Message, Status = CommandResult.StatusEnum.Fail }; return(result); } }