Exemple #1
0
        public void Handle(UserDeleteCommand command)
        {
            var user = userRepository.Find(new UserId(command.Id));

            if (user == null)
            {
                throw new Exception("ユーザーは存在しません。");
            }

            userRepository.Delete(user);
        }
Exemple #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");
        }
 public void Delete(UserDeleteCommand command)
 {
     this.userDeleteService.Handle(command);
 }