public ActionResult Create([Bind(Include = "DepartmentID,DepName,Location,Telephone,Email,WebAddress,DepChair,DepChairEmail")] Department department)
        {
            if (ModelState.IsValid)
            {
                db.Departments.Add(department);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(department));
        }
示例#2
0
        public ActionResult Create([Bind(Include = "UserRolesId,UserRoleName")] UserRoles userRoles)
        {
            if (ModelState.IsValid)
            {
                db.UserRoles.Add(userRoles);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(userRoles));
        }
示例#3
0
        public ActionResult Create([Bind(Include = "CheckOutBookID,StudentsID,BooksID,DepartmentID,DueDate,ReturnedBook,ReturnedDate,CheckedOutDate")] CheckOutBook checkOutBook)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    db.CheckOutBooks.Add(checkOutBook);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                catch
                {
                    return(Content("check out request was invalid go back and try again"));
                }
            }

            ViewBag.BooksID      = new SelectList(db.Books, "BooksID", "Title", checkOutBook.BooksID);
            ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "DepName", checkOutBook.DepartmentID);
            ViewBag.StudentsID   = new SelectList(db.Students, "StudentsID", "StudentName", checkOutBook.StudentsID);
            return(View(checkOutBook));
        }
示例#4
0
        // GET: Supplies
        public ActionResult Index()
        {
            var SetAvailableSuppliesTrue =
                from chkb in db.CheckOutSupplies
                join bk in db.Supplies
                on chkb.SuppliesID equals bk.SuppliesID
                where chkb.SuppliesID == bk.SuppliesID && chkb.ReturnedSupply == true
                select bk;

            foreach (Supplies chkb in SetAvailableSuppliesTrue)
            {
                chkb.Available = true;
            }

            var SetAvailableSuppliesFalse =
                from chkb in db.CheckOutSupplies
                join bk in db.Supplies
                on chkb.SuppliesID equals bk.SuppliesID
                where chkb.SuppliesID == bk.SuppliesID && chkb.ReturnedSupply == false
                select bk;

            foreach (Supplies chkb in SetAvailableSuppliesFalse)
            {
                chkb.Available = false;
            }

            var ResetUpdateQuerySuppliesOnDelete =
                from st in db.Supplies
                where !(from ch in db.CheckOutSupplies select ch.SuppliesID).Contains(st.SuppliesID)
                select st;

            foreach (Supplies chkb in ResetUpdateQuerySuppliesOnDelete)
            {
                chkb.Available = true;
            }
            db.SaveChanges();
            return(View(db.Supplies.ToList()));
        }
        // GET: Books
        //TODO make delete unavailable if a book is featured in checked out

        public ActionResult Index()
        {
            var SetAvailableBooksTrue =
                from chkb in db.CheckOutBooks
                join bk in db.Books
                on chkb.BooksID equals bk.BooksID
                where chkb.BooksID == bk.BooksID && chkb.ReturnedBook == true
                select bk;

            foreach (Books chkb in SetAvailableBooksTrue)
            {
                chkb.Available = true;
            }

            var SetAvailableBooksFalse =
                from chkb in db.CheckOutBooks
                join bk in db.Books
                on chkb.BooksID equals bk.BooksID
                where chkb.BooksID == bk.BooksID && chkb.ReturnedBook == false
                select bk;

            foreach (Books chkb in SetAvailableBooksFalse)
            {
                chkb.Available = false;
            }

            var ResetUpdateQueryBooksOnDelete =
                from st in db.Books
                where !(from ch in db.CheckOutBooks select ch.BooksID).Contains(st.BooksID)
                select st;

            foreach (Books chkb in ResetUpdateQueryBooksOnDelete)
            {
                chkb.Available = true;
            }
            db.SaveChanges();
            return(View(db.Books.ToList()));
        }
示例#6
0
        // GET: Students
        public ActionResult Index(int?id)
        {
            Students students = db.Students.Find(id);
            //TODO Figure out if counting the amount of checkedout books by StudentID is possible.

            // Queries to check if Students have checkedout books and to switch a bool if true or false
            var UpdateQueryBooks =
                from chks in db.CheckOutBooks
                join st in db.Students
                on chks.StudentsID equals st.StudentsID
                where chks.StudentsID == st.StudentsID && chks.ReturnedBook == false
                select st;

            foreach (Students chks in UpdateQueryBooks)
            {
                chks.HasCheckedOutBooks = true;
            }

            var ResetUpdateQueryBooksOnReturn =
                from chks in db.CheckOutBooks
                join st in db.Students
                on chks.StudentsID equals st.StudentsID
                where chks.ReturnedBook == true
                select st;

            foreach (Students chkb in ResetUpdateQueryBooksOnReturn)
            {
                chkb.HasCheckedOutBooks = false;
            }

            var ResetUpdateQueryBooksOnDelete =
                from st in db.Students
                where !(from ch in db.CheckOutBooks select ch.StudentsID).Contains(st.StudentsID)
                select st;

            foreach (Students chkb in ResetUpdateQueryBooksOnDelete)
            {
                chkb.HasCheckedOutBooks = false;
            }


            // Queries to check if Students have checkedout supplies and to switch a bool if true or false
            var ResetUpdateQuerySuppliesOnReturn =
                from chks in db.CheckOutSupplies
                join st in db.Students
                on chks.StudentsID equals st.StudentsID
                where chks.ReturnedSupply == true
                select st;

            foreach (Students chkb in ResetUpdateQuerySuppliesOnReturn)
            {
                chkb.HasCheckedOutSupplies = false;
            }

            var ResetUpdateQuerySuppliesOnDelete =
                from st in db.Students
                where !(from ch in db.CheckOutSupplies select ch.StudentsID).Contains(st.StudentsID)
                select st;

            foreach (Students chkb in ResetUpdateQuerySuppliesOnDelete)
            {
                chkb.HasCheckedOutSupplies = false;
            }

            var UpdateQuerySupplies =
                from chks in db.CheckOutSupplies
                join st in db.Students
                on chks.StudentsID equals st.StudentsID
                where chks.StudentsID == st.StudentsID && chks.ReturnedSupply == false
                select st;

            foreach (Students chks in UpdateQuerySupplies)
            {
                chks.HasCheckedOutSupplies = true;
            }

            // Save each change to database
            db.SaveChanges();
            return(View(db.Students.ToList()));
        }