public IHttpActionResult GetAllReaders()
        {
            var itemList = readerBL.GetAllReaders();

            var itemViewModelList = Mapper.Map <List <ReaderViewModel> >(itemList);

            return(Ok(itemViewModelList));
        }
Beispiel #2
0
        public int CreateBook(Book entity, Guid authorID, Guid isbnID, List <Guid> readerIDs)
        {
            if (validationService.EntityIsValid(entity))
            {
                entity.id = Guid.NewGuid();

                entity.author = authorBL.FindAuthorByKey(authorID);
                entity.isbn   = isbnBL.FindISBNById(isbnID);

                var readerList = readerBL.GetAllReaders();
                entity.readers = readerList.Where(r => readerIDs.Any(i => i.Equals(r.id))).ToList();

                bookDal.SaveBook(entity);

                return(0);
            }

            return(-1);
        }