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