Exemplo n.º 1
0
        public void Remove(BannerRemoveCommand command)
        {
            Status         = EnumDefine.CommonStatusEnum.Deleted;
            UpdatedDateUtc = command.CreatedDateUtc;
            UpdatedUid     = command.UpdatedUid;

            AddEvent(this.ToRemoveEvent());
        }
        public async Task <ICommandResult> Handle(BannerRemoveCommand mesage)
        {
            try
            {
                ICommandResult result;
                var            rBanner = await _bannerService.GetBannerById(mesage.Id);

                if (rBanner == null)
                {
                    result = new CommandResult()
                    {
                        Message      = "Banner not found",
                        ObjectId     = "",
                        Status       = CommandResult.StatusEnum.Fail,
                        ResourceName = ResourceKey.Banner_NotFound
                    };
                    return(result);
                }
                SystemDomains.Banner.Banner banner = new SystemDomains.Banner.Banner(rBanner);
                banner.Remove(mesage);
                await _bannerService.ChangeBannerStatus(banner.Id, banner.Status, banner.UpdatedUid, banner.UpdatedDateUtc);

                await _eventSender.Notify(banner.Events);

                result = new CommandResult()
                {
                    Message  = "",
                    ObjectId = banner.Id,
                    Status   = CommandResult.StatusEnum.Sucess
                };
                return(result);
            }
            catch (Exception e)
            {
                e.Data["Param"] = mesage;
                ICommandResult result = new CommandResult()
                {
                    Message = e.Message,
                    Status  = CommandResult.StatusEnum.Fail
                };
                return(result);
            }
        }
Exemplo n.º 3
0
        public async Task <CommandResult> SendCommand(BannerRemoveCommand command)
        {
            CommandResult commandResult = await _commandService.SendAndReceiveResult <CommandResult>(command);

            return(commandResult);
        }