public async Task <ICommandResult> Handle(GiftCodeCampaignChangeCommand mesage)
        {
            try
            {
                var shard = await _shardingService.Get(mesage.ShardId);

                if (shard == null)
                {
                    throw new MessageException(ResourceKey.ShardingConfig_NotFound);
                }
                GiftCodeCampaign campaign = new GiftCodeCampaign();
                campaign.Change(mesage);
                int rowCount = await _giftcodeService.Change(shard.ConnectionString, campaign);

                if (rowCount <= 0)
                {
                    throw new MessageException(ResourceKey.GiftCodeCampaignCart_NotFound);
                }
                await _eventSender.Notify();

                ICommandResult result = new CommandResult()
                {
                    Message  = "",
                    ObjectId = string.Empty,
                    Status   = CommandResult.StatusEnum.Sucess
                };
                return(result);
            }
            catch (MessageException e)
            {
                e.Data["Param"] = mesage;
                ICommandResult result = new CommandResult()
                {
                    Message      = e.Message,
                    Status       = CommandResult.StatusEnum.Fail,
                    ResourceName = e.ResourceName
                };
                return(result);
            }
            catch (Exception e)
            {
                e.Data["Param"] = mesage;
                ICommandResult result = new CommandResult()
                {
                    Message = e.Message,
                    Status  = CommandResult.StatusEnum.Fail
                };
                return(result);
            }
        }
 public void Change(GiftCodeCampaignChangeCommand command)
 {
     Id                     = command.Id;
     Name                   = command.Name;
     Notes                  = command.Notes;
     BeginDate              = command.BeginDate;
     EndDate                = command.EndDate;
     GiftCodeCalendars      = command.Calendars.Select(p => new GiftCodeCalendar(p.Date, p.Times)).ToArray();
     Message                = string.Empty;
     AllowPaymentOnCheckout = command.AllowPaymentOnCheckout;
     GiftCodeConditions     = command.Conditions.Select(p => new GiftCodeCondition(p.ConditionType, p.Condition))
                              .ToArray();
     Status         = EnumDefine.GiftCodeCampaignStatus.New;
     UpdatedDateUtc = command.CreatedDateUtc;
     UpdatedUid     = command.CreatedUid;
     Version        = command.Version;
 }
        public async Task <CommandResult> SendCommand(GiftCodeCampaignChangeCommand command)
        {
            CommandResult commandResult = await _commandService.SendAndReceiveResult <CommandResult>(command);

            return(commandResult);
        }