Exemple #1
0
        public void Update(BookDTO recDTO)
        {
            Book book = _bookRepository.Find(recDTO.BookID);

            if (book == null)
            {
                throw new DataException(string.Format(ValidationConstants.SDataNotFoundWithValue, "Book", recDTO.BookID));
            }

            book = BookMapper.Map(recDTO);
            _bookRepository.Update(book);
        }
Exemple #2
0
        public BookDTO Find(int bookID)
        {
            if (bookID == 0)
            {
                throw new ArgumentException("bookID");
            }

            Book book = _bookRepository.Find(bookID);

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

            BookDTO recDTO = BookMapper.Map(book);

            recDTO.IsAvaliable = _borrowRepository.isBookAvaliable(bookID);

            return(recDTO);
        }
Exemple #3
0
        public List <BookDTO> FindBooks(BookFindCriteria criteria)
        {
            if (criteria == null)
            {
                throw new ArgumentNullException("criteria");
            }

            var            books  = _bookRepository.FindByCriteria(criteria);
            List <BookDTO> result = new List <BookDTO>();
            BookDTO        recDTO;

            foreach (var book in books)
            {
                recDTO = BookMapper.Map(book);

                if (criteria.IncludeIsAvaliable)
                {
                    recDTO.IsAvaliable = _borrowRepository.isBookAvaliable(recDTO.BookID);
                }

                if (criteria.IsOverdue.HasValue)
                {
                    if (criteria.IsOverdue.Value == true && _borrowRepository.isBookOverdue(recDTO.BookID))
                    {
                        result.Add(recDTO);
                    }
                    else if (criteria.IsOverdue.Value == false && !_borrowRepository.isBookOverdue(recDTO.BookID))
                    {
                        result.Add(recDTO);
                    }
                }
                else
                {
                    result.Add(recDTO);
                }
            }

            return(result);
        }
Exemple #4
0
        public void Add(BookDTO recDTO)
        {
            Book book = BookMapper.Map(recDTO);

            _bookRepository.Add(book);
        }