Exemplo n.º 1
0
        public ActionResult Edit(ServiceIssuedBookViewModel issuedBookViewModel)
        {
            if (ModelState.IsValid)
            {
                ServiceIssuedBooks issuedBooks = context.issuedBook.Find(issuedBookViewModel.serviceIssuedId);
                var fromDate = issuedBookViewModel.serviceDisplayFromDate;
                var toDate   = issuedBookViewModel.serviceDisplayToDate;
                issuedBooks.serviceFromDate = Convert.ToDateTime(fromDate);
                issuedBooks.serviceToDate   = Convert.ToDateTime(toDate);

                context.Entry(issuedBooks).State = EntityState.Modified;
                context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(issuedBooks));
        }
Exemplo n.º 2
0
        public JsonResult BookIssue(ServiceIssuedBooks issuedBooks)
        {
            var Book = context.book.FirstOrDefault(b => b.serviceBookId == issuedBooks.bookId);

            if (issuedBooks != null && Book != null)
            {
                context.issuedBook.Add(issuedBooks);
                context.SaveChanges();
                Book.serviceIsAvailable = false;

                context.Entry(Book).State = EntityState.Modified;
                context.SaveChanges();
                return(Json(new { result = "success" }));
            }
            else
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
        public IHttpActionResult DeleteServiceIssuedBooks(int id)
        {
            ServiceIssuedBooks serviceIssuedBooks = db.issuedBook.Find(id);
            var Book = db.book.FirstOrDefault(b => b.serviceBookId == serviceIssuedBooks.bookId);

            if (serviceIssuedBooks == null)
            {
                return(NotFound());
            }
            db.issuedBook.Remove(serviceIssuedBooks);
            db.SaveChanges();

            if (Book != null)
            {
                Book.serviceIsAvailable = true;
                db.Entry(Book).State    = EntityState.Modified;
                db.SaveChanges();
            }
            return(Ok(serviceIssuedBooks));
        }
        public IHttpActionResult PostServiceIssuedBooks(ServiceIssuedBooks serviceIssuedBooks)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var Book = db.book.FirstOrDefault(b => b.serviceBookId == serviceIssuedBooks.bookId);

            if (Book != null)
            {
                Book.serviceIsAvailable = false;
                db.Entry(Book).State    = EntityState.Modified;
                db.SaveChanges();
            }
            db.issuedBook.Add(serviceIssuedBooks);
            db.SaveChanges();


            return(CreatedAtRoute("DefaultApi", new { id = serviceIssuedBooks.serviceIssuedId }, serviceIssuedBooks));
        }