예제 #1
0
 public Boolean setBookRfidListOnShelfRfid(String shelfRfid, List <String> bookRfidList)
 {
     if (bookRfidList.Count == 0 || String.IsNullOrEmpty(shelfRfid))
     {
         return(false);
     }
     //delete the item in book on shelf
     foreach (String bookRfidCode in bookRfidList)
     {
         var findItemList = dbEntities.BookOnShelf.Where((item) => item.bookRfidCode == bookRfidCode);
         foreach (BookOnShelf item in findItemList)
         {
             dbEntities.BookOnShelf.Remove(item);
         }
     }
     //insert the item in book on shelf
     foreach (String bookRfidCode in bookRfidList)
     {
         BookOnShelf item = new BookOnShelf();
         item.shelfRfidCode = shelfRfid;
         item.bookRfidCode  = bookRfidCode;
         dbEntities.BookOnShelf.Add(item);
     }
     dbEntities.SaveChanges();
     return(true);
 }
예제 #2
0
        public BookOnShelfDocument Post(int bookshelfId, int bookId)
        {
            var bookShelf = bookShelfRepository.Get(bookshelfId);

            if (bookShelf == null)
            {
                throw new ResourceNotFoundException("Book shelf not Found");
            }

            var book = bookRepository.Get(bookId);

            if (book == null)
            {
                throw new ResourceNotFoundException("Book not Found");
            }


            var bookInShelf = new BookOnShelf
            {
                BookId      = bookId,
                BookShelfId = bookshelfId
            };

            repository.Save(bookInShelf);

            var document = Map(bookInShelf, book, bookShelf);

            return(document);
        }
예제 #3
0
        private static BookOnShelfDocument Map(BookOnShelf bookOnShelf, Book book, BookShelf bookShelf)
        {
            var document = Mapper.Map <BookOnShelfDocument>(bookOnShelf);

            document.Book      = Mapper.Map <BookDocument>(book);
            document.BookShelf = Mapper.Map <BookShelfDocument>(bookShelf);
            return(document);
        }
예제 #4
0
        public String getShelfRfidbyBookRfid(String rfidCode)
        {
            if (String.IsNullOrEmpty(rfidCode))
            {
                return("");
            }
            BookOnShelf obj = dbEntities.BookOnShelf.Where((item) => item.bookRfidCode == rfidCode).FirstOrDefault <BookOnShelf>();

            if (obj == null)
            {
                return("");
            }
            else
            {
                return(obj.shelfRfidCode);
            }
        }