Exemplo n.º 1
0
        public IActionResult RentalList()
        {
            Dictionary <RentalActiveRecord, List <BookActiveRecord> > rentalDictionary = new Dictionary <RentalActiveRecord, List <BookActiveRecord> >();
            List <RentalActiveRecord>       rentals         = RentalActiveRecord.Find();
            List <RentalActiveRecord>       customerRentals = new List <RentalActiveRecord>();
            List <BookInRentalActiveRecord> booksInRental   = BookInRentalActiveRecord.Find();

            foreach (RentalActiveRecord rental in rentals)
            {
                if (rental.Customer.ID == Var.zakaznik.ID)
                {
                    customerRentals.Add(rental);
                }
            }
            foreach (RentalActiveRecord rental in customerRentals)
            {
                List <BookActiveRecord> tmpBooks = new List <BookActiveRecord>();
                foreach (BookInRentalActiveRecord book in booksInRental)
                {
                    if (book.Rental.ID == rental.ID)
                    {
                        tmpBooks.Add(BookActiveRecord.Find((int)book.Book.ID));
                    }
                }
                rentalDictionary.Add(rental, tmpBooks);
            }
            ViewBag.Rentals = rentalDictionary;
            return(View());
        }
Exemplo n.º 2
0
        public IActionResult BookList()
        {
            List <BookActiveRecord> books = BookActiveRecord.Find();

            ViewBag.Books = books;
            return(View());
        }
Exemplo n.º 3
0
        public IActionResult Book(ExtendForm form)
        {
            BookActiveRecord book = BookActiveRecord.Find(form.id);

            book.Available -= 1;
            book.Save();
            return(RedirectToAction("BookList", "Home"));
        }
Exemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            List <BookActiveRecord>         knihy          = BookActiveRecord.Find();
            List <LibrarianActiveRecord>    knihovnici     = LibrarianActiveRecord.Find();
            List <CustomerActiveRecord>     zakaznici      = CustomerActiveRecord.Find();
            List <RentalActiveRecord>       vypujcky       = RentalActiveRecord.Find();
            List <BookInRentalActiveRecord> knihyVeVypujce = BookInRentalActiveRecord.Find();
            List <AuthorActiveRecord>       autori         = AuthorActiveRecord.Find();

            AddBook addBookForm = new AddBook(this);

            addBookForm.Show();
            this.Hide();
        }
Exemplo n.º 5
0
        public FileContentResult DownloadCSV()
        {
            List <BookActiveRecord> books   = BookActiveRecord.Find();
            StringBuilder           builder = new StringBuilder();

            builder.AppendLine("Nazev;Autor;Zanr;Skladem");
            foreach (BookActiveRecord book in books)
            {
                builder.AppendLine();
                builder.Append(book.Title + ";");
                builder.Append(book.Author.Name + " " + book.Author.Surname + ";");
                builder.Append(book.Genre + ";");
                builder.Append(book.Available + ";");
            }
            string csv = builder.ToString();

            return(File(new System.Text.UTF32Encoding().GetBytes(csv), "text/csv", "Books.csv"));
        }
Exemplo n.º 6
0
        public AddRental(Form1 _f1)
        {
            InitializeComponent();

            f1 = _f1;

            booksToRent = new List <BookActiveRecord>();
            books       = BookActiveRecord.Find();
            customers   = CustomerActiveRecord.Find();

            for (int i = 0; i < books.Count; i++)
            {
                if (books[i].Available == 0)
                {
                    books.RemoveAt(i);
                }
            }

            cb_kniha.DataSource    = books;
            cb_zakaznik.DataSource = customers;
        }