コード例 #1
0
        protected override Task <object> ExecuteAsync(IAggregateCommand command)
        {
            switch (command)
            {
            case CreateComment createComment:
                return(UpsertAsync(createComment, c =>
                {
                    GuardComments.CanCreate(c);

                    Create(c);

                    return EntityCreatedResult.Create(createComment.CommentId, Version);
                }));

            case UpdateComment updateComment:
                return(UpsertAsync(updateComment, c =>
                {
                    GuardComments.CanUpdate(events, c);

                    Update(c);
                }));

            case DeleteComment deleteComment:
                return(UpsertAsync(deleteComment, c =>
                {
                    GuardComments.CanDelete(events, c);

                    Delete(c);
                }));

            default:
                throw new NotSupportedException();
            }
        }
コード例 #2
0
        private Task <object> ExecuteAsync(CommentsCommand command)
        {
            switch (command)
            {
            case CreateComment createComment:
                return(Upsert(createComment, c =>
                {
                    GuardComments.CanCreate(c);

                    Create(c);

                    return EntityCreatedResult.Create(createComment.CommentId, Version);
                }));

            case UpdateComment updateComment:
                return(Upsert(updateComment, c =>
                {
                    GuardComments.CanUpdate(Key, events, c);

                    Update(c);

                    return new EntitySavedResult(Version);
                }));

            case DeleteComment deleteComment:
                return(Upsert(deleteComment, c =>
                {
                    GuardComments.CanDelete(Key, events, c);

                    Delete(c);

                    return new EntitySavedResult(Version);
                }));

            default:
                throw new NotSupportedException();
            }
        }