Esempio n. 1
0
        /// <summary>
        /// 書籍情報を登録する。
        /// </summary>
        /// <param name="?"></param>
        public void regist(BookInfo bookInfo)
        {
            if (bookInfo == null) {
                throw new NullReferenceException("BookInfo is null");
            }

            // TODO 宣言的トランザクションに対応する。
            DataBaseAccessor accessor = new DataBaseAccessor();
            accessor.open();

            BookEval eval = null;
            // Evalのマスタ存在チェック
            if (bookInfo.EvalType != null) {
                BookEvalDao evalDao = new BookEvalDao(accessor);
                eval = evalDao.findById(bookInfo.EvalType);
                if (eval == null)
                {
                    // TODO Exceptionを確認
                    throw new ApplicationRuntimeException("評価マスタ上に存在しない評価です。");
                }
            }

            // Bookの存在有無チェック
            BookDao bookDao = new BookDao(accessor);
            Book existsBook = bookDao.findByIsbn(bookInfo.Isbn);
            if (existsBook != null)
            {
                throw new ApplicationRuntimeException("この本は既に登録済みです。入力内容をご確認ください");
            }

            // BookEntityの作成
            Book registBook = new Book();
            registBook.BookType = bookInfo.BookType;
            registBook.Title = bookInfo.Title;
            registBook.Isbn = bookInfo.Isbn;
            registBook.Publisher = bookInfo.Publisher;
            registBook.Price = bookInfo.Price;
            registBook.BuyDate = bookInfo.BuyDate;
            registBook.Status = bookInfo.Status;
            registBook.BookEval = eval;
            registBook.Eval = bookInfo.Eval;

            bookDao.insert(registBook);
        }
Esempio n. 2
0
        /// <summary>
        /// ログイン処理。
        /// </summary>
        /// <param name="userId">ログインユーザのユーザID</param>
        /// <param name="password">ログインユーザのパスワード</param>
        /// <returns>ログイン成功:ログインユーザ情報を保持するUserInfo。ログイン失敗:null</returns>
        public static UserInfo login(String userId, String password)
        {
            DataBaseAccessor accessor = new DataBaseAccessor();
            accessor.open();

            UserDao userDao = new UserDao(accessor);
            User user = userDao.findByUserIdAndPassword(userId, password);

            if (user == null)
            {
                return null;
            }

            EmployeeDao employeeDao = new EmployeeDao(accessor);
            Employee employee = employeeDao.findByUserId(userId);
            accessor.close();

            UserInfo userInfo = new UserInfo();
            userInfo.User = user;
            userInfo.Employee = employee;
            return userInfo;
        }
Esempio n. 3
0
 public UserDao(DataBaseAccessor accessor)
     : base(accessor)
 {
 }
Esempio n. 4
0
 public EmployeeDao(DataBaseAccessor accessor)
     : base(accessor)
 {
 }
Esempio n. 5
0
 public BookEvalDao(DataBaseAccessor accessor)
     : base(accessor)
 {
 }
Esempio n. 6
0
 protected AbstractDao(DataBaseAccessor accessor)
 {
     this.accessor = accessor;
 }