Exemple #1
0
        public void PostMessage(User user, string message)
        {
            CreateAccount(user);
            Post post = new Post(user, message);

            MyPosts.Add(post);
        }
Exemple #2
0
        public override ValidationResult AddPost(UserAddPostCommand command)
        {
            if (command.NewPost != command.PostToDelete)
            {
                MyPosts.Add(command.NewPost);
                return(ValidationResult.OkResult(new List <DomainEventBase>
                {
                    new UserAddPostEvent(command.NewPost.Id, command.PostToDelete.Id, Id)
                }));
            }

            return(ValidationResult.ErrorResult(new List <string> {
                "Can not delete post that should be added"
            }));
        }
Exemple #3
0
        public override ValidationResult UpdateName(UserUpdateNameCommand command)
        {
            var creationResult = Post.Create(new PostCreateCommand("luly"));

            if (command.Name.Length > 4)
            {
                MyPosts.Add(creationResult.CreatedEntity);
                return(ValidationResult.OkResult(new List <DomainEventBase> {
                    new UserUpdateNameEvent(command.Name, Id)
                }));
            }

            return(ValidationResult.ErrorResult(new List <string> {
                "Name too short to update"
            }));
        }