Esempio n. 1
0
        public IHttpActionResult Put(string id, string user, Rent_Details rent_Details)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != rent_Details.callNumber && user != rent_Details.stu_userName)
            {
                return(BadRequest());
            }
            db.Entry(rent_Details).State = EntityState.Modified;
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Rent_DetailsExists(user))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
 public static void Update(IssueBooks ib)
 {
     using (var db = new LibraryDBEntities())
     {
         db.Entry(ib).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Esempio n. 3
0
 public static void Update(UserPrivileges up)
 {
     using (var db = new LibraryDBEntities())
     {
         db.Entry(up).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Esempio n. 4
0
 public static void Update(Sessions s)
 {
     using (var db = new LibraryDBEntities())
     {
         db.Entry(s).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Esempio n. 5
0
 public static void Update(Departments d)
 {
     using (var db = new LibraryDBEntities())
     {
         db.Entry(d).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Esempio n. 6
0
 internal static void DecreaseBookAvlaible(Book book)
 {
     using (LibraryDBEntities context = new LibraryDBEntities())
     {
         context.Entry(book).State = EntityState.Modified;
         book.AvailableNumber      = book.AvailableNumber - 1;
         context.SaveChanges();
     }
 }
 public ActionResult Edit([Bind(Include = "ID,Name,City")] Departmen departmen)
 {
     if (ModelState.IsValid)
     {
         db.Entry(departmen).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(departmen));
 }
Esempio n. 8
0
 public ActionResult Edit([Bind(Include = "ISBN,Title,Author,Year")] Book book)
 {
     if (ModelState.IsValid)
     {
         db.Entry(book).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(book));
 }
 public ActionResult Edit([Bind(Include = "Id,BookName,Price,Category,AuthorName,Edition,BookCondition,Available")] BookDetails bookDetails)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bookDetails).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(bookDetails));
 }
Esempio n. 10
0
 public ActionResult Edit([Bind(Include = "ID,Name,Author,Year,Department")] Book book)
 {
     if (ModelState.IsValid)
     {
         db.Entry(book).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Department = new SelectList(db.Departmens, "ID", "Name", book.Department);
     return(View(book));
 }
Esempio n. 11
0
        public static void UpdateStudent(int id, StudentViewModel oldStudent)
        {
            using (LibraryDBEntities contex = new LibraryDBEntities())
            {
                Student stu = contex.Students.Find(id);
                contex.Entry(stu).State = EntityState.Modified;
                stu.FirstName           = oldStudent.FirstName;
                stu.LastName            = oldStudent.LastName;

                contex.SaveChanges();
            }
        }
Esempio n. 12
0
 public ActionResult Edit([Bind(Include = "Id,BookId,StudentId,BorrowDate,ReturnDate")] BorrowHistory borrowHistory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(borrowHistory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.BookId    = new SelectList(db.Books, "Id", "Code", borrowHistory.BookId);
     ViewBag.StudentId = new SelectList(db.Students, "Id", "FirstName", borrowHistory.StudentId);
     return(View(borrowHistory));
 }
Esempio n. 13
0
 // PUT: api/Departmen/id
 public void Put(Departmen sub)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sub).State = EntityState.Modified;
         try
         {
             db.SaveChanges();
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
        public ActionResult Edit([Bind(Include = "FirstName,LastName,OIB")] LibraryUsers libraryUsers)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Entry(libraryUsers).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException de)
            {
                ModelState.AddModelError("", "Unable to save changes." + de.Message);
            }

            return(View(libraryUsers));
        }
        public ActionResult Edit([Bind(Include = "Name,Mark")] Publishers publishers)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Entry(publishers).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException)
            {
                ModelState.AddModelError("", "Unable to save changes.");
            }

            return(View(publishers));
        }
Esempio n. 16
0
        public ActionResult Edit([Bind(Include = "Name,Description")] Categories categories)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Entry(categories).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException de)
            {
                ModelState.AddModelError("", "Unable to save changes." + de.Message);
            }

            return(View(categories));
        }
Esempio n. 17
0
        public ActionResult Edit([Bind(Include = "AuthorID,FirstName,LastName")] Authors authors)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Entry(authors).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException)
            {
                ModelState.AddModelError("", "Unable to save changes.");
            }

            return(View(authors));
        }
Esempio n. 18
0
        public static void UpdateBook(int id, BookViewModel oldbbook)
        {
            if (IsNegativeValue(oldbbook))
            {
                throw new Exception(" Please check number of book");
            }

            using (LibraryDBEntities contex = new LibraryDBEntities())
            {
                Book book = contex.Books.Find(id);
                contex.Entry(book).State = EntityState.Modified;
                book.Id              = oldbbook.Id;
                book.Code            = oldbbook.Code;
                book.Name            = oldbbook.Name;
                book.Author_Name     = oldbbook.Author_Name;
                book.Publisher       = oldbbook.Publisher;
                book.OriginalCopies  = oldbbook.OriginalCopies;
                book.AvailableNumber = oldbbook.AvailableNumber;
                contex.SaveChanges();
            }
        }
Esempio n. 19
0
 public ActionResult Edit([Bind(Include = "BookID,Title,ISBN,Availability,AuthorID,PublisherID,CategoryID")] Books books)
 {
     try
     {
         var authorsBooks = db.AuthorsBooks.SingleOrDefault(ab => ab.BookID == books.BookID);
         authorsBooks.AuthorID = books.AuthorID;
         var booksPublishers = db.BooksPublishers.SingleOrDefault(bp => bp.BookID == books.BookID);
         booksPublishers.PublisherID = books.PublisherID;
         var booksCategories = db.BooksCategories.SingleOrDefault(bc => bc.BookID == books.BookID);
         booksCategories.CategoryID = books.CategoryID;
         db.Entry(books).State      = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch (DataException)
     {
         ModelState.AddModelError("", "Unable to save changes.");
     }
     PopulateAuthorsDropDownList(books.AuthorID);
     PopulatePublishersDropDownList(books.PublisherID);
     PopulateCategoriesDropDownList(books.CategoryID);
     return(View(books));
 }
Esempio n. 20
0
 public void Update(T obj)
 {
     _db.Entry(obj).State = System.Data.Entity.EntityState.Modified;
 }