Exemplo n.º 1
0
        //here assigning actions starts
        public async Task <ActionResult> Assign(int?id)
        {
            LibararyBooks libararyBooks = await db.LibararyBooks.FindAsync(id);

            if (libararyBooks.Quantity == 0)
            {
                TempData["msgnot"] = "Not Available! Cannot Issue Book" + " " + libararyBooks.Title + " " + "it Is Not Avialable in The Library!";
                return(RedirectToAction("Index"));
            }
            LibarayIssuedBooks = new LibarayIssuedBooks
            {
                BookId            = libararyBooks.Id,
                BookTitle         = libararyBooks.Title,
                AssignedBy        = User.Identity.Name,
                AssignedDate      = DateTime.Now,
                ReturnDate        = DateTime.Now.AddDays(14),
                StudedRegId       = 0,
                StudentName       = "",
                StudentClass      = "",
                StudentDepartment = "",
                Id             = 0,
                Comments       = "N/A",
                fineComment    = "",
                fineslipid     = "",
                finestatus     = "",
                Receiveddate   = DateTime.Today,
                ReceivedStatus = "Not Received",
            };



            return(View(LibarayIssuedBooks));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            LibarayIssuedBooks libarayIssuedBooks = await db.LibarayIssuedBooks.FindAsync(id);

            db.LibarayIssuedBooks.Remove(libarayIssuedBooks);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        // GET: LibarayIssuedBooks/Create
        //public ActionResult Create()
        //{
        //    return View();
        //}

        //// POST: LibarayIssuedBooks/Create
        //// To protect from overposting attacks, please enable the specific properties you want to bind to, for
        //// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public async Task<ActionResult> Create([Bind(Include = "Id,BookTitle,BookId,AssignedBy,AssignedDate,ReturnDate,StudedRegId,StudentName,StudentDepartment,StudentClass,Comments,fineComment,ReceivedStatus,Receiveddate,fineslipid,finestatus")] LibarayIssuedBooks libarayIssuedBooks)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        db.LibarayIssuedBooks.Add(libarayIssuedBooks);
        //        await db.SaveChangesAsync();
        //        return RedirectToAction("Index");
        //    }

        //    return View(libarayIssuedBooks);
        //}

        // GET: LibarayIssuedBooks/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LibarayIssuedBooks libarayIssuedBooks = await db.LibarayIssuedBooks.FindAsync(id);

            if (libarayIssuedBooks == null)
            {
                return(HttpNotFound());
            }
            return(View(libarayIssuedBooks));
        }
Exemplo n.º 4
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,BookTitle,BookId,AssignedBy,AssignedDate,ReturnDate,StudedRegId,StudentName,StudentDepartment,StudentClass,Comments,fineComment,ReceivedStatus,Receiveddate,fineslipid,finestatus")] LibarayIssuedBooks libarayIssuedBooks)
        {
            if (ModelState.IsValid)
            {
                //         public string fineComment { get; set; }
                //public string ReceivedStatus { get; set; }
                //public DateTime Receiveddate { get; set; }
                //public string fineslipid { get; set; }
                //public string finestatus { get; set; }
                libarayIssuedBooks.Receiveddate = DateTime.Now;
                if (libarayIssuedBooks.ReturnDate > libarayIssuedBooks.ReturnDate)
                {
                    if (libarayIssuedBooks.fineslipid == "")
                    {
                        ViewBag.finemsg = "Provide the Fine Challan ID to Proceed.";
                        return(View(libarayIssuedBooks));
                    }
                    int         convert     = Convert.ToInt32(libarayIssuedBooks.fineslipid);
                    Finerecords checkrecord = await db.Finerecords.FindAsync(convert);

                    if (checkrecord == null)
                    {
                        ViewBag.finemsg = "Provided  Fine Challan ID Not Matched.";
                    }
                    libarayIssuedBooks.finestatus = "Fined";
                }
                else
                {
                    libarayIssuedBooks.finestatus = "Not Fined";
                }
                libarayIssuedBooks.ReceivedStatus = "Received";

                db.Entry(libarayIssuedBooks).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(libarayIssuedBooks));
        }
Exemplo n.º 5
0
        public async Task <ActionResult> Assign(LibarayIssuedBooks libarayIssuedBook)
        {
            //check for book availability
            //check for student id
            if (libarayIssuedBook.StudedRegId == 0)
            {
                TempData["idnot"] = "Please Enter The Student Id To Issue The Library Book";
                return(View(libarayIssuedBook));
            }
            //now check that the student id exists or not [check]
            Students checkstudent = await db.students.FindAsync(libarayIssuedBook.StudedRegId);

            if (checkstudent == null)
            {
                TempData["idnot"] = "Student Not Found! Please Provide The Valid Student Id";
                return(View(libarayIssuedBook));
            }
            libarayIssuedBook.StudedRegId = checkstudent.Id;

            // LibarayIssuedBooks.StudentName = checkstudent.StudentName;

            //bind program and class of the student
            var getprogram = db.programs.Where(a => a.Id == checkstudent.ProgramId).FirstOrDefault();

            var getclass = db.classes.Where(a => a.Id == checkstudent.ClassId).FirstOrDefault();

            //now bind this infor with model
            libarayIssuedBook.StudentDepartment = getprogram.ProgramName;
            libarayIssuedBook.StudentClass      = getclass.ClassName;
            if (LibarayIssuedBooks.Comments == null)
            {
                libarayIssuedBook.Comments = "N/A";
            }

            LibarayIssuedBooks = libarayIssuedBook;

            return(RedirectToAction("ConfirmAssign"));
        }