Example #1
0
 public void Change(ProductGroupChangeCommand command)
 {
     Add(command);
     Id             = command.Id;
     UpdatedDateUtc = command.UpdatedDateUtc;
     UpdatedUid     = command.UpdatedUid ?? string.Empty;
 }
        public async Task <ICommandResult> Handle(ProductGroupChangeCommand message)
        {
            try
            {
                ICommandResult result;
                RProductGroup  rproductGroup = await _productGroupService.Get(message.Id);

                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.Change(message);
                await _productGroupService.Change(productGroup);

                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);
            }
        }
 public async Task <CommandResult> SendCommand(ProductGroupChangeCommand command)
 {
     return(await _commandService.SendAndReceiveResult <CommandResult>(command));
 }