示例#1
0
 protected override IEnumerable <CommandDefinition> GetCommand(object evt)
 {
     return(evt switch
     {
         ArticlePublished e => ArrayOf(new ArticleInsertCommand(e).Command, new TagBatchInsert(e).Command),
         ArticleDeleted e => ArrayOf(
             new CommandDefinition("delete from Tags where ArticleId=@ArticleId", e),
             new CommandDefinition("delete from Favorites where ArticleId=@ArticleId", e),
             new CommandDefinition("delete from Articles where ArticleId=@ArticleId", e)),
         ArticleFavorited e => ArrayOf(
             new CommandDefinition("insert into Favorites (ArticleId, UserId) values (@ArticleId, @UserId)", e),
             new CommandDefinition("update Articles set FavoriteCount=FavoriteCount+1 where ArticleId=@ArticleId", e)),
         ArticleUnfavorited e => ArrayOf(
             new CommandDefinition("delete from Favorites where ArticleId=@ArticleId and UserId=@UserId", e),
             new CommandDefinition("update Articles set FavoriteCount=FavoriteCount-1 where ArticleId=@ArticleId", e)),
         BodyUpdated e => ArrayOf(new CommandDefinition("update Articles set Body=@Body, UpdatedDate=@UpdatedAt where ArticleId=@ArticleId", e)),
         DescriptionUpdated e => ArrayOf(new CommandDefinition("update Articles set Description=@Description, UpdatedDate=@UpdatedAt where ArticleId=@ArticleId", e)),
         TitleUpdated e => ArrayOf(new CommandDefinition("update Articles set Title=@Title, TitleSlug=@TitleSlug, UpdatedDate=@UpdatedAt where ArticleId=@ArticleId", e)),
         _ => Array.Empty <CommandDefinition>()
     });
示例#2
0
 private void OnDescriptionUpdated(DescriptionUpdated e) => Description = e.Description;