示例#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 <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"
            }));
        }
示例#3
0
 private User(Guid Id, UserCreateCommand command)
 {
     this.Name = command.Name;
     this.Age  = command.Age;
     this.Id   = Id;
 }