public BannerItem AddItem(BannerItemAddCommand command) { if (BannerItems == null) { BannerItems = new List <BannerItem>(); } BannerItem bannerItem = new BannerItem(); bannerItem.Init(command); BannerItems.Add(bannerItem); AddEvent(this.ToAddOrChangCacheEvent()); return(bannerItem); }
public void Init(BannerItemAddCommand command) { Id = Common.Common.GenerateGuid(); BannerItemName = command.BannerItemName ?? string.Empty; BannerId = command.BannerId ?? string.Empty; TargetUrl = command.TargetUrl ?? string.Empty; ImageUrl = command.ImageUrl ?? string.Empty; Status = command.Status; StartDateUtc = command.StartDateUtc; EndDateUtc = command.EndDateUtc; IsDefault = command.IsDefault; BackgroundRGB = command.BackgroundRGB; CreatedDateUtc = command.CreatedDateUtc; UpdatedDateUtc = command.CreatedDateUtc; CreatedUid = command.CreatedUid ?? string.Empty; UpdatedUid = command.CreatedUid ?? string.Empty; }
public async Task <ICommandResult> Handle(BannerItemAddCommand 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.AddItem(mesage); await _bannerService.AddBannerItem(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); } }
public async Task <CommandResult> SendCommand(BannerItemAddCommand command) { CommandResult commandResult = await _commandService.SendAndReceiveResult <CommandResult>(command); return(commandResult); }