public ActionResult Create(int memberID, FormCollection coll)
        {
            if (ModelState.IsValid)
            {
                var member = Utilities.Members.getMember(Session, memberID, Utilities.Members.MemberType.Staff);
                if (!member.IsLibrarian) throw new Exception("You do not have permissions to this page");
                var books = Utilities.Inventory.GetAllInventory(Session, Utilities.Inventory.InventoryTypes.Books);
                var book = new Book(Utilities.Inventory.getNextID(books)) { Author = coll["Author"], Title = coll["Title"], BookCopies = new List<LibrarySystem.Areas.Inventory.Models.Book.Copy>() };

                books.Add(book);
                Dictionary<String, List<InventoryItemBase>> inventory = Session["Inventory"] as Dictionary<String, List<InventoryItemBase>>;
                inventory[Utilities.Inventory.InventoryTypes.Books.ToString()] = books;
                Session["Inventory"] = inventory;
                return RedirectToAction(Utilities.Members.MemberType.Staff.ToString(), "Default", new { mid = memberID });
            }

            return View(memberID);
        }
예제 #2
0
 public Copy(int id, Book book, bool isAvailable)
 {
     this.isAvailable = isAvailable;
     this.isBorrowed = false;
     this.book = book;
     this.id = id;
 }
예제 #3
0
 public Copy(int id, Book book)
     : this(id, book, false)
 {
 }