コード例 #1
0
 public void Change(BannerItemChangeCommand command)
 {
     Id             = command.Id;
     BannerItemName = command.BannerItemName;
     TargetUrl      = command.TargetUrl;
     ImageUrl       = command.ImageUrl;
     StartDateUtc   = command.StartDateUtc;
     EndDateUtc     = command.EndDateUtc;
     Status         = command.Status;
     IsDefault      = command.IsDefault;
     BackgroundRGB  = command.BackgroundRGB;
     UpdatedDateUtc = command.CreatedDateUtc;
     UpdatedUid     = command.UpdatedUid;
 }
コード例 #2
0
ファイル: Banner.cs プロジェクト: MarkHollander/Gico_System
        public BannerItem ChangeItem(BannerItemChangeCommand command)
        {
            if (BannerItems == null)
            {
                BannerItems = new List <BannerItem>();
            }
            BannerItem bannerItem = BannerItems.FirstOrDefault(p => p.Id == command.Id);

            if (bannerItem == null)
            {
                throw new Exception("BannerItem not found.");
            }
            bannerItem.Change(command);

            AddEvent(this.ToAddOrChangCacheEvent());
            return(bannerItem);
        }
コード例 #3
0
        public async Task <ICommandResult> Handle(BannerItemChangeCommand mesage)
        {
            try
            {
                ICommandResult result;
                var            rBanner = await _bannerService.GetBannerById(mesage.BannerId);

                if (rBanner == null)
                {
                    result = new CommandResult()
                    {
                        Message      = "Banner not found",
                        ObjectId     = "",
                        Status       = CommandResult.StatusEnum.Fail,
                        ResourceName = ResourceKey.Banner_NotFound
                    };
                    return(result);
                }
                RBannerItem[] rBannerItems = await _bannerService.GetBannerItemByBannerId(rBanner.Id);

                SystemDomains.Banner.Banner banner = new SystemDomains.Banner.Banner(rBanner, rBannerItems);

                BannerItem bannerItem = banner.ChangeItem(mesage);
                await _bannerService.ChangeBannerItem(bannerItem);

                await _eventSender.Notify(banner.Events);

                result = new CommandResult()
                {
                    Message  = "",
                    ObjectId = bannerItem.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);
            }
        }
コード例 #4
0
        public async Task <CommandResult> SendCommand(BannerItemChangeCommand command)
        {
            CommandResult commandResult = await _commandService.SendAndReceiveResult <CommandResult>(command);

            return(commandResult);
        }