Exemplo n.º 1
0
        static private void AddBook()
        {
            Console.Clear();
            Console.WriteLine("Enter book title");
            var booktitle = Console.ReadLine();

            Console.WriteLine("Enter book author");
            var authorName = Console.ReadLine();

            Console.WriteLine("Enter book genre");
            var genre = Console.ReadLine();

            Console.WriteLine("Enter year");
            var year = Console.ReadLine();

            BookServiceClient client = new BookServiceClient();
            Book book = new Book();

            book.title      = booktitle;
            book.year       = year;
            book.genre      = genre;
            book.authorName = authorName;

            client.addBook(book);
            client.Close();
        }
Exemplo n.º 2
0
        static private void ShowBooksList()
        {
            BookServiceClient client = new BookServiceClient();

            var list = client.getBooksList();

            foreach (Book book in list)
            {
                Console.WriteLine(book.title + " " + book.authorName);
            }
        }
Exemplo n.º 3
0
        private void LoanBookPage_Load(object sender, EventArgs e)
        {
            BookServiceClient bookService = new BookServiceClient();

            foreach (CarteDTO carte in bookService.GetAvailableBooks())
            {
                ListViewItem item = new ListViewItem(carte.carteId.ToString());
                item.SubItems.Add(carte.titlu);
                item.SubItems.Add(carte.AutorDto.nume + " " + carte.AutorDto.prenume);
                item.SubItems.Add(carte.GenDto.descriere);
                availableBooksList.Items.Add(item);
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var client = new BookServiceClient();
            var book   = new Book(1, "Leo Tolstoy", "War and Peace", 25, 1867);

            client.AddBook(book);
            book = new Book(2, "Albert Camus", "The stranger", 20, 1942);
            client.AddBook(book);
            book = new Book(3, "George Orwell", "1984", 23, 1949);
            client.AddBook(book);
            book = new Book(4, "Fyodor Dostoyevsky", "The Brothers Karamazov", 30, 1880);
            client.AddBook(book);
            client.UpdatePrice(3, 25);
            client.GetBookInfo(4);
        }
Exemplo n.º 5
0
        public void AddBook(string isbn, string code, string title, string author, string subject)
        {
            Book newBook;

            using (var cli = new BookServiceClient())
            {
                cli.Open();
                newBook = cli.CreateBook(isbn, code, title, author, subject);
                cli.Close();
            }

            if (newBook != null)
            {
                books.TryAdd(newBook.Id, newBook);
            }
        }
Exemplo n.º 6
0
        private void filterButton_Click(object sender, EventArgs e)
        {
            bookIsNotAvailable.Hide();
            BookServiceClient bookService  = new BookServiceClient();
            string            filterGender = genInput.Text;

            availableBooksList.Items.Clear();
            foreach (CarteDTO carte in bookService.GetAvailableBooks())
            {
                if (filterGender.Equals("") || filterGender.Equals(' ') || filterGender.Equals(carte.GenDto.descriere))
                {
                    ListViewItem item = new ListViewItem(carte.carteId.ToString());
                    item.SubItems.Add(carte.titlu);
                    item.SubItems.Add(carte.AutorDto.nume + " " + carte.AutorDto.prenume);
                    item.SubItems.Add(carte.GenDto.descriere);
                    availableBooksList.Items.Add(item);
                }
            }
        }
Exemplo n.º 7
0
        private void loanBookButton_Click(object sender, EventArgs e)
        {
            ReaderServiceClient readerService = new ReaderServiceClient();
            BookServiceClient   bookService   = new BookServiceClient();
            LoanServiceClient   loanService   = new LoanServiceClient();

            CititorDTO citior = readerService.GetReaderByEmail(emailInput.Text);
            CarteDTO   carte  = bookService.GetBookById(Int32.Parse(bookIdInput.Text));

            ImprumutDTO existingLoan = loanService.GetLoanForBookId(carte.carteId);

            if (existingLoan == null)
            {
                loanService.LoanBook(carte, citior, DateTime.Now, DateTime.Now.AddDays(30));
                this.Close();
            }
            else
            {
                bookIsNotAvailable.Text = "Cartea va fi disponibila in data de: " + existingLoan.dataScadenta;
                bookIsNotAvailable.Show();
            }
        }
Exemplo n.º 8
0
 BookServiceClient bookService;//Declare service object
 public Form1()
 {
     InitializeComponent();
     bookService = new BookServiceClient();//Initialize
 }