Exemple #1
0
        public void Update(BorrowDTO recDTO)
        {
            Borrow borrow = _borrowRepository.Find(recDTO.BookID, recDTO.StudentID);

            if (borrow == null)
            {
                throw new DataException(string.Format(ValidationConstants.SDataNotFoundWithValue, "Borrow", string.Format("book: {0} student: {1}", recDTO.BookID, recDTO.StudentID)));
            }

            borrow = BorrowMapper.Map(recDTO);
            _borrowRepository.Update(borrow);
        }
Exemple #2
0
 public void Add(BorrowDTO recDTO)
 {
     if (_borrowRepository.isBookAvaliable(recDTO.BookID))
     {
         Borrow Borrow = BorrowMapper.Map(recDTO);
         _borrowRepository.Add(Borrow);
     }
     else
     {
         throw new DataException("This Book is already borrowed");
     }
 }
Exemple #3
0
        public BorrowDTO Find(int bookID, int studentID)
        {
            Borrow borrow = _borrowRepository.Find(bookID, studentID);

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

            BorrowDTO recDTO = BorrowMapper.Map(borrow);

            return(recDTO);
        }
Exemple #4
0
        public List <BorrowDTO> FindBorrows(BorrowFindCriteria criteria)
        {
            if (criteria == null)
            {
                throw new ArgumentNullException("criteria");
            }

            var Borrows             = _borrowRepository.FindByCriteria(criteria);
            List <BorrowDTO> result = new List <BorrowDTO>();

            foreach (var Borrow in Borrows)
            {
                result.Add(BorrowMapper.Map(Borrow));
            }

            return(result);
        }