public void Register_New_User() { var container = Container.Init_Container(); var service = container.Resolve<RegistrationService>(); var cmd = new Register_New_User { DisplayName ="Valerio", Identity="123", Provider="Google" }; service.Register_New_User(cmd); }
public void Register_New_User(Register_New_User cmd) { var identity_already_exists = DocumentSession.Query<User>().Any(u=> u.Identities.Any(i=> i.Provider == cmd.Provider && i.Id == cmd.Identity)); if(identity_already_exists) throw new Exception(""); var user = new User { Name = cmd.DisplayName }; user.Identify(cmd.Provider, cmd.Identity, cmd.DisplayName); DocumentSession.Store(user); }