コード例 #1
0
        public async Task <ICommandResult> Handle(GiftCodeCampaignChangeStatusCommand mesage)
        {
            try
            {
                var shard = await _shardingService.Get(mesage.ShardId);

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

                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);
            }
        }
コード例 #2
0
        public bool ChangeStatus(GiftCodeCampaignChangeStatusCommand command)
        {
            Id             = command.Id;
            Status         = command.Status;
            UpdatedDateUtc = command.CreatedDateUtc;
            UpdatedUid     = command.CreatedUid;
            Version        = command.Version;
            switch (command.Status)
            {
            case EnumDefine.GiftCodeCampaignStatus.Active:
            case EnumDefine.GiftCodeCampaignStatus.ReActive:
                ApprovedDate = command.CreatedDateUtc;
                ApprovedUid  = command.CreatedUid;
                return(true);

                break;
            }
            return(false);
        }
コード例 #3
0
        public async Task <CommandResult> SendCommand(GiftCodeCampaignChangeStatusCommand command)
        {
            CommandResult commandResult = await _commandService.SendAndReceiveResult <CommandResult>(command);

            return(commandResult);
        }