예제 #1
0
 public ActionResult Edit([Bind(Include = "ProductImageID,ImageDescription,ImageURL,ProductID,ImageActive,ImageUpdateDateTime")] ProductImage productImage)
 {
     productImage.ImageUpdateDateTime = DateTime.Now;
     if (ModelState.IsValid)
     {
         db.Entry(productImage).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProductID = new SelectList(db.Products, "ProductID", "ProductName", productImage.ProductID);
     return(View(productImage));
 }
예제 #2
0
 public ActionResult Edit([Bind(Include = "ProductID,ProductName,ProductDescription,ProductModel,ProductPrice,ProductKeywords,CategoryID,ProductActive,ProductCreateDateTime")] Product product)
 {
     product.ProductUpdateDateTime = DateTime.Now;
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", product.CategoryID);
     return(View(product));
 }
예제 #3
0
 public ActionResult Edit([Bind(Include = "id,member_id,book_id,date")] bookDetail bookDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bookDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.id = new SelectList(db.book, "id", "name", bookDetail.id);
     ViewBag.id = new SelectList(db.member, "id", "name", bookDetail.id);
     return(View(bookDetail));
 }
예제 #4
0
 public ActionResult OrderUpdate([Bind(Include = "OrderId,CustomerId,OrderDate,PlaceOfDelivery,Distance,PaymentId,DeliveryDate,OrderStatus")] Order order)
 {
     if (ModelState.IsValid)
     {
         db.Entry(order).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CustomerId = new SelectList(db.Customers, "CustomerId", "CustomerName", order.CustomerId);
     ViewBag.PaymentId  = new SelectList(db.Payments, "PaymentId", "PaymentName", order.PaymentId);
     return(View(order));
 }
예제 #5
0
 public ActionResult Edit(Book book)
 {
     if (ModelState.IsValid)
     {
         db.Entry(book).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.GenreId  = new SelectList(db.Genres, "GenreId", "Name", book.GenreId);
     ViewBag.AuthorId = new SelectList(db.Authors, "AuthorId", "Name", book.AuthorId);
     return(View(book));
 }
예제 #6
0
        public ActionResult Edit([Bind(Include = "BookID,ISBN,BookTitle,Description,GenreID,Price,UnitsSold,PublishDate,PublisherID,BookImage,IsSiteFeature,IsGenreFeature,BookStatusID")] Book book, HttpPostedFileBase imageUpload)
        {
            if (ModelState.IsValid)
            {
                //Only process the file IF all other validation has passed (Model.State.IsValid)

                #region FileUpload

                //Check the input and process if its value is NOT null
                if (imageUpload != null)
                {
                    //Get the file name and save it to a variable (resuse the string declared for default)
                    string imageName = imageUpload.FileName;
                    //Use the fileName and extract the Extension and save it to a variable (important for images)

                    //Create a List of valid extensions
                    string ext = imageName.Substring(imageName.LastIndexOf(".")); // return .extension
                    //Compare our extension to the List
                    string[] goodExts = new string[] { ".jpeg", ".jpg", ".png", ".gif" };
                    //If we have a VALID extension:
                    if (goodExts.Contains(ext.ToLower()))
                    {
                        //rename the file (conventially we do a guid) - if you need something more descriptive you can dynamically create a unique value
                        //You could take part of the book title and concatenate with DateTime.Now OR you could use part of the userID to define
                        //  --(if you go to these routes, make sure your datatype in SQL is big enough to accept it)
                        //EX: imageName = book.BookTitle.Substring(0,20) +DateTime.Now + ext; //20 chars of the Title plus the DateTime stamp

                        //Here use the GUID (Global Unique Identifier)
                        imageName = Guid.NewGuid() + ext;

                        //Save the image file to the webserver
                        imageUpload.SaveAs(Server.MapPath("~/Content/images/Books/" + imageName));

                        //Only if the file type is correct  will we save the file and update the record with the correct imageName ofr the record
                        book.BookImage = imageName;
                    }
                }//If there is no NEW image information, the existing image is kept (HiddenFor() in the view)

                #endregion

                //Pass the modified (updated version of the record to EF) - set the state to Modified
                db.Entry(book).State = EntityState.Modified;
                //UPDATE/SAVE changes to the DB
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.BookID       = new SelectList(db.BookRoyalities, "BookID", "BookID", book.BookID);
            ViewBag.BookStatusID = new SelectList(db.BookStatuses, "BookStatusID", "BookStatusName", book.BookStatusID);
            ViewBag.GenreID      = new SelectList(db.Genres, "GenreID", "GenreName", book.GenreID);
            ViewBag.PublisherID  = new SelectList(db.Publishers, "PublisherID", "PublisherName", book.PublisherID);
            return(View(book));
        }
예제 #7
0
 public ActionResult Edit([Bind(Include = "BillID,CustomerID,Street,City,State,Zip")] Billing billing)
 {
     if (ModelState.IsValid)
     {
         Customer customer = db.Customers.Where(x => x.Username == User.Identity.Name).First();
         billing.CustomerID      = customer.CustomerID;
         db.Entry(billing).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("YourAccount", "Account", null));
     }
     ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "FirstName", billing.CustomerID);
     return(View(billing));
 }
예제 #8
0
 public ActionResult Edit([Bind(Include = "InvoiceID,CardID,CartID,ShipID,BillID,Status,TotalPrice")] Invoice invoice)
 {
     if (ModelState.IsValid)
     {
         db.Entry(invoice).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.BillID = new SelectList(db.Billings, "BillID", "Street", invoice.BillID);
     ViewBag.CardID = new SelectList(db.Credit_Card, "CardID", "Number", invoice.CardID);
     ViewBag.CartID = new SelectList(db.Shoppings, "CartID", "CartID", invoice.CartID);
     ViewBag.ShipID = new SelectList(db.Shippings, "ShipID", "Street", invoice.ShipID);
     return(View(invoice));
 }
예제 #9
0
        public ActionResult ShopCarts_Update([DataSourceRequest] DataSourceRequest request, ShopCart shopCart)
        {
            if (ModelState.IsValid)
            {
                var entity = new ShopCart
                {
                    BookID      = shopCart.BookID,
                    UserID      = shopCart.UserID,
                    ShopCartId  = shopCart.ShopCartId,
                    Quantity    = shopCart.Quantity,
                    CreatedTime = shopCart.CreatedTime,
                };

                db.ShopCarts.Attach(entity);
                db.Entry(entity).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(Json(new[] { shopCart }.ToDataSourceResult(request, ModelState)));
        }
예제 #10
0
        public ActionResult Purchaseds_Update([DataSourceRequest] DataSourceRequest request, Purchased purchased)
        {
            if (ModelState.IsValid)
            {
                var entity = new Purchased
                {
                    BookID         = purchased.BookID,
                    UserID         = purchased.UserID,
                    PurchasedID    = purchased.PurchasedID,
                    Title          = purchased.Title,
                    Quantity       = purchased.Quantity,
                    PurchasedPrice = purchased.PurchasedPrice,
                    PurchasedTime  = purchased.PurchasedTime,
                };

                db.Purchaseds.Attach(entity);
                db.Entry(entity).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(Json(new[] { purchased }.ToDataSourceResult(request, ModelState)));
        }
예제 #11
0
        public ActionResult Users_Update([DataSourceRequest] DataSourceRequest request, User user)
        {
            if (ModelState.IsValid)
            {
                var entity = new User
                {
                    UserID       = user.UserID,
                    UserName     = user.UserName,
                    Password     = user.Password,
                    EmailAddress = user.EmailAddress,
                    BirthDate    = user.BirthDate,
                    FirstName    = user.FirstName,
                    LastName     = user.LastName,
                    Address      = user.Address,
                    IsValid      = user.IsValid,
                };

                db.Users.Attach(entity);
                db.Entry(entity).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(Json(new[] { user }.ToDataSourceResult(request, ModelState)));
        }
예제 #12
0
 public void Update(Author author)
 {
     db.Entry(author).State = EntityState.Modified;
     db.SaveChanges();
 }
예제 #13
0
 public ActionResult ChinhSua(ChuDe cd)
 {
     db.Entry(cd).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
예제 #14
0
 public void Update(Book book)
 {
     db.Entry(book).State = EntityState.Modified;
     db.SaveChanges();
 }
예제 #15
0
 public ActionResult ChinhSua(NhaXuatBan nxb)
 {
     db.Entry(nxb).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
예제 #16
0
 public virtual void Update(T entity)
 {
     dbset.Attach(entity);
     dataContext.Entry(entity).State = EntityState.Modified;
 }
예제 #17
0
 public void Update(Book Model, int Id)
 {
     _context.Entry(Model).State = EntityState.Modified;
 }