public bool BookIsAlreadyUnreserved(Book book)
 {
     if (string.IsNullOrEmpty(book.ReservedBy)) {
         return true;
     }
     return false;
 }
 private void Unreserve(Book book)
 {
     book.ReservedBy = null;
     _bookService.Update(book);
 }
 private void Reserve(Book book)
 {
     book.ReservedBy = GetUserName();
     _bookService.Update(book);
 }
 public void Update(Book book)
 {
     _dbContext.Entry(book).State = EntityState.Modified;
     Save();
 }
 public void Remove(Book book)
 {
     _dbContext.Books.Remove(book);
     Save();
 }
 public void Add(Book book)
 {
     _dbContext.Books.Add(book);
     Save();
 }
 private void SaveCoverImageOnServer(Book book)
 {
     foreach (var file in from string item in Request.Files select Request.Files[item])
     {
         SaveOnServer(file.FileName, Keys.CoverImageBase);
         book.CoverImageUrl = String.Concat(Keys.PathUploads + "/", file.FileName);
         break;
     }
 }
 private void SaveCoverImageOnServer(BookViewModel bookViewModel, Book book)
 {
     var fileName = bookViewModel.CoverImageBase.FileName;
     if (_fileFormatValidation.IsImageType(fileName))
     {
         SaveOnServer(bookViewModel.CoverImageBase.FileName, Keys.CoverImageBase);
         book.CoverImageUrl = String.Concat(Keys.PathUploads + "/", bookViewModel.CoverImageBase.FileName);
     }
     else
     {
         ModelState.AddModelError(string.Empty, "Please upload a valid image file.");
     }
 }
        private static Book ExtractValuesFromWorksheetAndCreateBook(ExcelWorksheet workSheet, int rowIndex)
        {
            var propertyDictionary = new Dictionary<string, string>();

            try
            {
                propertyDictionary["title"] = workSheet.Cells[rowIndex, 1].Value.ToString();
                propertyDictionary["author"] = workSheet.Cells[rowIndex, 2].Value.ToString();
                propertyDictionary["description"] = workSheet.Cells[rowIndex, 3].Value.ToString();
                propertyDictionary["language"] = workSheet.Cells[rowIndex, 4].Value.ToString();
                propertyDictionary["pages"] = workSheet.Cells[rowIndex, 5].Value.ToString();
                propertyDictionary["isbn10"] = workSheet.Cells[rowIndex, 6].Value.ToString();
                propertyDictionary["isbn13"] = workSheet.Cells[rowIndex, 7].Value.ToString();
            }
            catch (Exception)
            {
                return null;
            }

            var book = new Book()
            {
                Title = propertyDictionary["title"],
                Author = propertyDictionary["author"],
                Description = propertyDictionary["description"],
                Language = propertyDictionary["language"],
                Pages = propertyDictionary["pages"].ToInt32(),
                ISBN10 = propertyDictionary["isbn10"],
                ISBN13 = propertyDictionary["isbn13"],
                CoverImageUrl = Keys.PathNAImage
            };
            return book;
        }
 public void Update(Book book)
 {
     _bookRepository.Update(book);
 }
 public void Remove(Book book)
 {
     _bookRepository.Remove(book);
 }
 public void Add(Book book)
 {
     _bookRepository.Add(book);
 }