예제 #1
0
        public static CreationResult <User> Create(UserCreateCommand command)
        {
            // TODO: Implement this method;
            var newGuid = Guid.NewGuid();
            var entity  = new User(newGuid, command);

            return(CreationResult <User> .OkResult(new List <DomainEventBase> {
                new UserCreateEvent(entity, newGuid)
            }, entity));
        }
예제 #2
0
        public static CreationResult <Post> Create(PostCreateCommand command)
        {
            var newGuid          = Guid.NewGuid();
            var post             = new Post(newGuid, command);
            var createEvent      = new PostCreateEvent(post, newGuid);
            var domainEventBases = new List <DomainEventBase>();

            domainEventBases.Add(createEvent);
            return(CreationResult <Post> .OkResult(domainEventBases, post));
        }
예제 #3
0
        public static CreationResult <User> Create(UserCreateCommand command)
        {
            if (command.Name.Length > 4)
            {
                var newGuid = Guid.NewGuid();
                var user    = new User(newGuid, command);
                return(CreationResult <User> .OkResult(new List <DomainEventBase> {
                    new UserCreateEvent(user, newGuid)
                },
                                                       user));
            }

            return(CreationResult <User> .ErrorResult(new List <string> {
                "Name too short"
            }));
        }