Ejemplo n.º 1
0
        public void Handle(UserRegisterCommand command)
        {
            var user = new User(new UserId(command.Id), new UserName(command.Name), new MailAddress(command.MailAddress));

            if (userDuplicatedChecker.Check(user))
            {
                throw new Exception("ユーザは既に存在しています。");
            }

            userRepository.Save(user);
        }
Ejemplo n.º 2
0
        private static void TestApplicationService()
        {
            var defaultId          = "0";
            var defaultName        = "Kaleidot725";
            var defaultMailAddress = "*****@*****.**";
            var nextName           = "Kaleidot888";
            var nextMailAddress    = "*****@*****.**";

            var repository         = new ApplicationService.UserRepository();
            var applicationService = new ApplicationService.UserApplicationService(
                new ApplicationService.UserGetInfoService(repository),
                new ApplicationService.UserRegisterService(repository),
                new ApplicationService.UserDeleteService(repository),
                new ApplicationService.UserUpdateService(repository)
                );

            var registerCommand = new ApplicationService.UserRegisterCommand(defaultId, defaultName, defaultMailAddress);

            applicationService.Register(registerCommand);
            var newUserData = applicationService.Get(defaultId);

            Console.WriteLine(newUserData.Id + " " + newUserData.Name + " " + newUserData.MailAddress);

            var updateCommand = new ApplicationService.UserUpdateCommand(defaultId, nextName, nextMailAddress);

            applicationService.Update(updateCommand);
            var updateUserData = applicationService.Get(defaultId);

            Console.WriteLine(updateUserData.Id + " " + updateUserData.Name + " " + updateUserData.MailAddress);

            var deleteCommand = new ApplicationService.UserDeleteCommand(defaultId);

            applicationService.Delete(deleteCommand);
            var deleteUserData = applicationService.Get(defaultId);

            Console.WriteLine(deleteUserData == null ? "Null" : "Not Null");
        }
Ejemplo n.º 3
0
 public void Register(UserRegisterCommand command)
 {
     this.userRegisterService.Handle(command);
 }