public void contactDetails(BookModel bookModel)
        {
            if (!bookRepo.GetBookByName(bookModel.bookName, bookModel.bookType))
            {
                bookRepo.AddBook(bookModel);
            }

            ContactModel contactModel = new ContactModel();

            Console.WriteLine("Enter First Name:");
            contactModel.firstName = Console.ReadLine();
            Console.WriteLine("Enter Last Name");
            contactModel.lastName = Console.ReadLine();
            Console.WriteLine("Enter Address");
            contactModel.address = Console.ReadLine();
            Console.WriteLine("Enter City");
            contactModel.city = Console.ReadLine();
            Console.WriteLine("Enter State");
            contactModel.state = Console.ReadLine();
            Console.WriteLine("Enter zip");
            contactModel.zip = Console.ReadLine();
            Console.WriteLine("Enter Phone Number");
            contactModel.phoneNumber = Console.ReadLine();
            Console.WriteLine("Enter Email");
            contactModel.email = Console.ReadLine();

            if (contactRepo.AddContact(contactModel, bookModel))
            {
                Console.WriteLine("Records added successfully");
            }
        }
示例#2
0
        public async void AddBook(BookInputModel book)
        {
            var bookEntity = new Book
            {
                Title          = book.Title,
                Isbn           = book.Isbn,
                PublishingYear = book.PublishingYear ?? default(int),
                Type           = book.Type,
                Price          = book.Price ?? default(double),
                PublisherId    = book.PublisherId ?? default(int)
            };

            var bookId = _bookRepo.AddBook(bookEntity);

            var details = new BookDetails
            {
                BookId      = bookId,
                Description = book.Description,
                Font        = book.Font,
                PageCount   = book.PageCount ?? default(int),
                Length      = book.Length ?? default(int)
            };

            _bookRepo.AddBookDetails(details);

            foreach (var id in book.Author)
            {
                var AuthorConnection = new BookAuthorConnection
                {
                    BookId   = bookId,
                    AuthorId = id
                };

                _bookRepo.AddBookAuthorConnection(AuthorConnection);
            }

            foreach (var id in book.Genre)
            {
                var GenreConnection = new BookGenreConnection
                {
                    BookId  = bookId,
                    GenreId = id
                };
                _bookRepo.AddBookGenreConnection(GenreConnection);
            }

            using (var memoryStream = new MemoryStream())
            {
                await book.CoverImage.CopyToAsync(memoryStream);

                var img = new CoverImage
                {
                    BookId = bookId,
                    Img    = memoryStream.ToArray()
                };
                _bookRepo.AddImage(img);
            }
        }
示例#3
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            Book book = new Book();

            book.Title       = txtTitle.Text;
            book.Author      = txtAuthor.Text;
            book.Price       = decimal.Parse(txtPrice.Text);
            book.Description = txtDescription.Text;
            book.CountryId   = (int)CmbxCountry.SelectedValue;

            BookRepo repo = new BookRepo();

            repo.AddBook(book);
        }
示例#4
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            Book book = new Book
            {
                Title       = txtTitle.Text,
                Author      = txtAuthor.Text,
                Price       = decimal.Parse(txtPrice.Text),
                Description = txtDescription.Text,
                CountryId   = 1
            };

            repo.AddBook(book);
            LoadBooks();
        }
示例#5
0
        public IActionResult Create(string title, int year, double rating, int author, string isbn, int category, string coverImage)
        {
            var NewBook = new Book {
                Title       = title,
                ReleaseYear = year,
                Rating      = rating,
                AuthorId    = author,
                Isbn        = isbn,
                CategoryId  = category,
                CoverImg    = coverImage
            };

            _bookRepo.AddBook(NewBook);
            return(RedirectToAction("Index", "Create"));
        }
示例#6
0
文件: Form1.cs 项目: YannickB23/Books
        private void btnInsert_Click(object sender, EventArgs e)
        {
            var book = new Book
            {
                Title       = txtTitle.Text,
                Author      = txtAuthor.Text,
                Price       = decimal.Parse(txtPrice.Text),
                Description = txtDescription.Text,
                CountryId   = (int)cmbCountry.SelectedValue
            };

            BookRepo repo = new BookRepo();

            repo.AddBook(book);
        }
示例#7
0
        public void AddBook(BookInputModel model)
        {
            var book = new Book
            {
                Title       = model.Title,
                Author      = model.Author,
                ReleaseYear = model.ReleaseYear,
                Genre       = model.Genre,
                ISBN        = model.ISBN,
                Price       = model.Price,
                Stock       = model.Stock,
                TopSeller   = model.TopSeller,
                OnSale      = model.OnSale,
                Discount    = model.Discount,
                Image       = model.Image,
            };

            _bookRepo.AddBook(book);
        }
        public IActionResult Add(BookVM book)
        {
            if (ModelState.IsValid && book.image != null)
            {
                // this class contains the function that handles the files
                FileHandling fileHandling = new FileHandling(_webHostEnvironment);
                String       imagePath    = fileHandling.fileUpload(book.image, "books");

                book.books.image_path = imagePath;
                _bookrepo.AddBook(book.books);
                return(RedirectToAction("Table", book));
            }
            else
            {
                book.fileError  = "Please Upload a Image";
                book.genreList  = _genreRepo.GetAllGenres();
                book.authorList = _authorRepo.GetAllAuthors();

                return(View("AddForm", book));
            }
        }
示例#9
0
        public void AddBook(BookInputModel bookInputModel)
        {
            //returns new book
            var book = new Book
            {
                ISBN        = bookInputModel.ISBN,
                Language    = bookInputModel.Language,
                Image       = bookInputModel.Image,
                Title       = bookInputModel.Title,
                Genre       = bookInputModel.Genre,
                Info        = bookInputModel.Info,
                AuthorId    = (int)bookInputModel.AuthorId,
                Publisher   = bookInputModel.Publisher,
                PageCount   = bookInputModel.PageCount,
                ReleaseYear = (int)bookInputModel.ReleaseYear,
                Price       = (double)bookInputModel.Price,
                Discount    = 0,
                Rating      = 0,
                RatingCount = 0,
                Stock       = 10
            };

            _bookRepo.AddBook(book);
        }
示例#10
0
 public void AddBook(InputBookModel book)
 {
     _bookRepo.AddBook(book);
 }
示例#11
0
 public void AddBook(BookInputModel model)
 {
     _bookRepo.AddBook(model);
 }
示例#12
0
 public void AddBook(BookInputModel newBook)
 {
     _bookRepo.AddBook(newBook);
 }