Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "id,knowledge1")] Knowledge knowledge)
        {
            if (ModelState.IsValid)
            {
                db.Knowledges.Add(knowledge);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(knowledge));
        }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Include = "ISBN,author,name,publication_type,tome,compiler,language,translator,place_publication,publishing,year,number,price")] Book book)
        {
            if (ModelState.IsValid)
            {
                db.Books.Add(book);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(book));
        }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "id,FullName,age")] Authors authors)
        {
            if (ModelState.IsValid)
            {
                db.Authors.Add(authors);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(authors));
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "id,last_name,name,middle_name,age,address,phone")] Reader reader)
        {
            if (ModelState.IsValid)
            {
                db.Readers.Add(reader);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(reader));
        }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Include = "ISBN,title,idAuthor,photo")] Books books)
        {
            if (ModelState.IsValid)
            {
                db.Books.Add(books);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.idAuthor = new SelectList(db.Authors, "id", "FullName", books.idAuthor);
            return(View(books));
        }
Ejemplo n.º 6
0
 public void Save(Member member)
 {
     if (member.MemberId <= 0)
     {
         db.Members.Add(member);
     }
     else
     {
         db.Entry(member).State = EntityState.Modified;
     }
     db.SaveChanges();
 }
Ejemplo n.º 7
0
 public void Save(Author author)
 {
     if (author.AuthorId <= 0)
     {
         db.Authors.Add(author);
     }
     else
     {
         db.Entry(author).State = EntityState.Modified;
     }
     db.SaveChanges();
 }
Ejemplo n.º 8
0
        public ActionResult Create([Bind(Include = "id,room,rack,shelf,existence,ISBN")] Instance instance)
        {
            if (ModelState.IsValid)
            {
                db.Instances.Add(instance);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ISBN = new SelectList(db.Books, "ISBN", "name", instance.ISBN);
            return(View(instance));
        }
        public ActionResult Create([Bind(Include = "id,instance_id,reader_id,date_extradition,return_date")] Extradition extradition)
        {
            if (ModelState.IsValid)
            {
                db.Extraditions.Add(extradition);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.instance_id = new SelectList(db.Instances, "id", "ISBN", extradition.instance_id);
            ViewBag.reader_id   = new SelectList(db.Readers, "id", "last_name", extradition.reader_id);
            return(View(extradition));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Add a new book to the database.
        /// </summary>
        /// <param name="sender">The details of the new book </param>
        private void AddNewBook(Book sender)
        {
            if (sender.Year == 0 || string.IsNullOrWhiteSpace(sender.BookName) || string.IsNullOrWhiteSpace(sender.Authors) || string.IsNullOrWhiteSpace(sender.Category))
            {
                dialogBox = new DialogBox("FIGYELEM!", "Minden mező kitöltése kötelező!");
                dialogBox.Show();
                return;
            }

            dialogBox = new DialogBox(DialogBoxType.WARNING, "VÉGLEGESÍTÉS!", "Könyv hozzáadása?");
            dialogBox.ShowDialog();
            if (dialogBox.Answer == DialogAnswer.NO)
            {
                return;
            }

            using (var context = new LibraryDatabaseEntities())
            {
                try
                {
                    context.Books.Add(sender);
                    context.SaveChanges();
                    BooksDataContext.StoredBooksList.Add(sender);
                    dialogBox = new DialogBox("Hozzáadás sikeres!");
                    dialogBox.Show();
                }
                catch
                {
                    dialogBox = new DialogBox("HIBA!", "Hozzáadás nem sikerült!");
                    dialogBox.Show();
                }
            }
            ControlDataContext.SelectedBookDetails = sender;
        }
Ejemplo n.º 11
0
 public ActionResult CheckOut(CheckoutViewModel cvm)
 {
     if (ModelState.IsValid)
     {
         var checkoutEvent = new CheckoutEvent
         {
             DateTimeCheckedOut = cvm.TimeCheckedOut,
             BookId             = cvm.BookId,
             PatronId           = cvm.PatronId
         };
         var book = db.Books.Single(x => x.BookId == cvm.BookId);
         book.PatronId = cvm.PatronId;
         db.CheckoutEvents.Add(checkoutEvent);
         db.Entry(book).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cvm));
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Borrow the books and add the selected books to the borrowed table.
        /// </summary>
        private void BorrowBooks()
        {
            //Check empty fields
            if (BorrowDataContext.BorrowedBooksList == null)
            {
                dialogBox = new DialogBox("HIBA!", "Nem adott hozzá könyvet!");
                dialogBox.Show();
                return;
            }

            if (BorrowDataContext.IsExpired || BorrowDataContext.IsExist == false)
            {
                dialogBox = new DialogBox("HIBA!", "Hibás vagy lejárt azonosító!");
                dialogBox.Show();
                return;
            }

            if (BorrowDataContext.ExpDate < DateTime.Today)
            {
                dialogBox = new DialogBox("HIBA!", "Érvénytelen kölcsönzési idő");
                dialogBox.Show();
                return;
            }

            dialogBox = new DialogBox(DialogBoxType.WARNING, "FIGYELEM!", "Művelet megerősítése?");
            dialogBox.ShowDialog();
            if (dialogBox.Answer == DialogAnswer.NO)
            {
                return;
            }

            using (var context = new LibraryDatabaseEntities())
            {
                foreach (var item in BorrowDataContext.BorrowedBooksList)
                {
                    context.BorrowedBooks.Add(new BorrowedBook {
                        LibID = BorrowDataContext.LibID, ExpDate = BorrowDataContext.ExpDate, CopyID = item.CopyID
                    });
                    var bookCopies = context.BookCopies.FirstOrDefault(r => r.ID == item.CopyID);
                    bookCopies.IsBorrowed = true;
                }

                context.SaveChanges();
                dialogBox = new DialogBox("Kölcsönzés sikeres!");
                dialogBox.Show();

                // Reset the properties and list.
                BorrowDataContext.BorrowedBooksList = new ObservableCollection <BorrowModel>();
                BorrowDataContext.BookID            = "";
                BorrowDataContext.MemberID          = "";
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Return the borrowed books to the library and remove them from the borrowed table.
        /// </summary>
        private void ReturnBooks()
        {
            if (ReturnDataContext.ReturnedBooksList.Count == 0)
            {
                return;
            }

            dialogBox = new DialogBox(DialogBoxType.WARNING, "FIGYELEM!", "Biztos visszaadja a könyveket?");
            dialogBox.ShowDialog();
            if (dialogBox.Answer == DialogAnswer.NO)
            {
                return;
            }

            using (var context = new LibraryDatabaseEntities())
            {
                try
                {
                    foreach (var item in ReturnDataContext.ReturnedBooksList)
                    {
                        var returnBook = (from borrowed in context.BorrowedBooks
                                          join copies in context.BookCopies
                                          on borrowed.CopyID equals copies.ID
                                          where copies.BookCode == item.CopyID
                                          select new { BorrowedBook = borrowed }).Single().BorrowedBook;

                        context.BorrowedBooks.Remove(returnBook);
                    }

                    context.SaveChanges();
                    dialogBox = new DialogBox("Könyvek visszaadása sikeres!");
                    dialogBox.Show();
                    ReturnDataContext.ReturnedBooksList = new ObservableCollection <ReturnModel>();
                    ReturnDataContext.MemberBooksList   = new ObservableCollection <ReturnModel>();
                }
                catch
                {
                    dialogBox = new DialogBox("HIBA!", "Hiba a művelet közben!");
                    dialogBox.Show();
                }
            }
        }
Ejemplo n.º 14
0
 public void Save(Publisher publisher)
 {
     db.Publishers.Add(publisher);
     db.SaveChanges();
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Register a new member or expand the membership.
        /// </summary>
        private void RegisterMember()
        {
            if (IsRegisterClicked && !IsValidFields())
            {
                dialogBox = new DialogBox("HIBA!", "Helytelenül kitöltött Mezők!");
                dialogBox.Show();
                return;
            }


            if (IsEnabled == Visibility.Visible)
            {
                dialogBox = new DialogBox(DialogBoxType.WARNING, "FIGYELEM!", "Regisztrálja az új tagot?");
                dialogBox.ShowDialog();
                if (dialogBox.Answer == DialogAnswer.NO)
                {
                    return;
                }

                // Register a new member.
                using (var context = new LibraryDatabaseEntities())
                {
                    try
                    {
                        var item = DateTime.Today;
                        item = item.AddMonths(int.Parse(MembershipLength));
                        MemberInfo.ExpData = item;
                        MemberInfo.LibID   = MemberInfo.LibID.ToUpper();

                        context.Members.Add(MemberInfo);
                        context.SaveChanges();
                        dialogBox = new DialogBox("Sikeres regisztráció!");
                        dialogBox.Show();
                    }
                    catch
                    {
                        dialogBox = new DialogBox("HIBA!", "Művelet sikertelen!");
                        dialogBox.Show();
                        return;
                    }
                }
            }
            else
            {
                dialogBox = new DialogBox(DialogBoxType.WARNING, "FIGYELEM!", "Tagság meghosszabítása?");
                dialogBox.ShowDialog();
                if (dialogBox.Answer == DialogAnswer.NO)
                {
                    return;
                }

                // Expand the membership of an existing member.
                using (var context = new LibraryDatabaseEntities())
                {
                    var item = context.Members.FirstOrDefault(r => r.LibID.Equals(MemberInfo.LibID));

                    if (item == null)
                    {
                        dialogBox = new DialogBox("HIBA!", "Nem található ilyen felhasználó!");
                        dialogBox.Show();
                        return;
                    }

                    //Expand membership.
                    try
                    {
                        var dateCurrent = item.ExpData;
                        item.ExpData = dateCurrent.AddMonths(int.Parse(MembershipLength));

                        context.SaveChanges();

                        dialogBox = new DialogBox("SIKER!", "Tagság sikeresen meghosszabbítva!");
                        dialogBox.Show();
                    }
                    catch
                    {
                        dialogBox = new DialogBox("HIBA!", "Művelet sikertelen!");
                        dialogBox.Show();
                    }
                }
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Add the copies to the database.
        /// </summary>
        private void AddNewCopies()
        {
            if (ControlDataContext.SelectedBookDetails == null)
            {
                return;
            }

            foreach (var item in ControlDataContext.CopiesList)
            {
                if (item.BookCode.Length != 6)
                {
                    dialogBox = new DialogBox("HIBA!", "Hibásan kitöltött mező!");
                    dialogBox.Show();
                    return;
                }
            }

            dialogBox = new DialogBox(DialogBoxType.WARNING, "FIGYELEM!", "Hozzáadja a másolatokat?");
            dialogBox.ShowDialog();
            if (dialogBox.Answer == DialogAnswer.NO)
            {
                return;
            }

            using (var context = new LibraryDatabaseEntities())
            {
                foreach (var item in ControlDataContext.CopiesList)
                {
                    var bookCopy = new BookCopy
                    {
                        BookCode = item.BookCode.ToUpper(),
                        BookID   = ControlDataContext.SelectedBookDetails.ID
                    };

                    context.BookCopies.Add(bookCopy);
                }

                try
                {
                    context.SaveChanges();
                }
                catch
                {
                    dialogBox = new DialogBox("HIBA!", "Már létezik ilyen azonosító!\nHozzáadás nem lehetséges!");
                    dialogBox.Show();
                    return;
                }

                // Calculate the new value of the available copies.

                short count = (short)context.BookCopies.Count(t => t.BookID == ControlDataContext.SelectedBookDetails.ID);
                var   books = context.Books.FirstOrDefault(r => r.ID == ControlDataContext.SelectedBookDetails.ID);
                books.BookCopies = count;
                context.SaveChanges();

                //Update thhe copies column acording to the new value.
                BooksDataContext.StoredBooksList
                .Where(r => r.ID == ControlDataContext.SelectedBookDetails.ID)
                .Select(n => { n.BookCopies = count; return(n); }).ToList();
            }
        }
Ejemplo n.º 17
0
 public void Delete(Book book)
 {
     db.Books.Remove(book);
     db.SaveChanges();
 }