Exemplo n.º 1
0
        public bool ReturnOrder(int orderId)
        {
            bool isSuccess = false;
            var  order     = db.OrderTbls.Find(orderId);

            if (order != null)
            {
                order.status          = 2;
                db.Entry(order).State = EntityState.Modified;

                var detailsOrder = FindDetailOrderByOid(orderId);
                if (detailsOrder.Count > 0)
                {
                    foreach (var i in detailsOrder)
                    {
                        Book b = db.Books.Find(i.bookID);
                        b.quantity       += i.quantityBorrowed;
                        db.Entry(b).State = EntityState.Modified;
                        isSuccess         = true;
                    }
                }
            }
            db.SaveChanges();
            return(isSuccess);
        }
Exemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "Id,User_Name,Password,Type,Date_Created,Created_by")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
 public ActionResult Edit([Bind(Include = "Id,StudentID,L_Name,F_Name,Class")] Student student)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(student));
 }
Exemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "IDManager,IDCooperative,FirstName,LastName,Email,ManagerPassword")] Manager manager)
 {
     if (ModelState.IsValid)
     {
         db.Entry(manager).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IDCooperative = new SelectList(db.Cooperative, "IDCooperative", "Name", manager.IDCooperative);
     return(View(manager));
 }
        public IHttpActionResult PutCategories(int id, Categories categories)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != categories.category_id)
            {
                return(BadRequest());
            }

            db.Entry(categories).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CategoriesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 6
0
        public bool InsertDetailOrder(List <DetailOrdersDTO> dto, int orderId)
        {
            var temp = db.OrderTbls.Find(orderId);

            if (temp != null)
            {
                if (dto != null)
                {
                    foreach (var i in dto)
                    {
                        DetailOrder dtop = new DetailOrder();
                        dtop.orderID          = orderId;
                        dtop.bookID           = i.BookId;
                        dtop.quantityBorrowed = i.QuantityBorrowed;
                        db.DetailOrders.Add(dtop);

                        Book b = db.Books.Find(i.BookId);
                        b.quantity       -= i.QuantityBorrowed;
                        db.Entry(b).State = EntityState.Modified;
                    }
                    db.SaveChanges();
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 7
0
        public IHttpActionResult PutBorrowedBooks(int id, BorrowedBooks borrowedBooks)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != borrowedBooks.borrowed_book_id)
            {
                return(BadRequest());
            }

            db.Entry(borrowedBooks).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BorrowedBooksExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutStock(int id, Stock stock)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != stock.stock_id)
            {
                return(BadRequest());
            }

            db.Entry(stock).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StockExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public ActionResult Edit([Bind(Include = "Id,ISBN,Title,Author,Publisher,Category,Year_Released,Pages,Num_of_Copies,Shelf_Number")] Book book)
 {
     if (ModelState.IsValid)
     {
         db.Entry(book).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(book));
 }
 public ActionResult Edit([Bind(Include = "IDStudent,FirstName,LastName,Email,PhoneNumber,StudentPassword")] Student student)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(student));
 }
Exemplo n.º 11
0
 public ActionResult Edit([Bind(Include = "Id,P_Category,Name,ISBN,Volume_Number,Year,Page_Number,Shelf_Num")] Period period)
 {
     if (ModelState.IsValid)
     {
         db.Entry(period).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(period));
 }
        public async Task <ActionResult> Edit([Bind(Include = "Book_ID,Book_Name,Author_Name,Publication,Purchase_Date,Book_Price,Books_Quantity")] BooksInfoEntry booksInfoEntry)
        {
            if (ModelState.IsValid)
            {
                db.Entry(booksInfoEntry).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(booksInfoEntry));
        }
Exemplo n.º 13
0
        public async Task <ActionResult> Edit([Bind(Include = "Student_ID,Student_Name,Enrollment_No,Department,Student_Semester,Student_Contact,Student_Email")] StudentInfoEntry studentInfoEntry)
        {
            if (ModelState.IsValid)
            {
                db.Entry(studentInfoEntry).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(studentInfoEntry));
        }
Exemplo n.º 14
0
        public static void ChangeLanguageTwo()
        {
            LibraryManagementEntities db = new LibraryManagementEntities();
            Settings config = db.Settings.Single();

            if (config.IDLanguage == 1)
            {
                IDLanguage = 2;
            }
            else
            {
                IDLanguage = 1;
            }
            config.IDLanguage      = IDLanguage;
            db.Entry(config).State = EntityState.Modified;
            db.SaveChanges();
        }
Exemplo n.º 15
0
        public static void ChangeLanguage(string language)
        {
            LibraryManagementEntities db = new LibraryManagementEntities();

            switch (language)
            {
            case "Fr":
                IDLanguage = 1;
                break;

            case "En":
                IDLanguage = 2;
                break;

            default:
                IDLanguage = 1;
                break;
            }
            Settings config = db.Settings.Single();

            config.IDLanguage      = IDLanguage;
            db.Entry(config).State = EntityState.Modified;
            db.SaveChanges();
        }
Exemplo n.º 16
0
 public void Update(Student obj)
 {
     ctx.Students.Attach(obj);
     ctx.Entry(obj).State = System.Data.Entity.EntityState.Modified;
     ctx.SaveChanges();
 }