public ActionResult Edit([Bind(Include = "CustomerId,CustomerName")] Customer customer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(customer));
 }
Example #2
0
 public ActionResult Edit([Bind(Include = "FilePathId,FileName,FileType,ProductId")] FilePath filePath)
 {
     if (ModelState.IsValid)
     {
         db.Entry(filePath).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProductId = new SelectList(db.Products, "ProductId", "ProductName", filePath.ProductId);
     return(View(filePath));
 }
Example #3
0
 public ActionResult Edit([Bind(Include = "ProductId,ProductName,ProductsDescryption,ProductHeight,ProductWidth,ProductPrice")] Product product, HttpPostedFileBase upload)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         UploadImage(product, upload);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }
Example #4
0
 public ActionResult Edit([Bind(Include = "OrderId,CustomerId,OrderName,OrderDate,OrderDeliveryDeadlineDate,OrderDeliveryDate,QuantityOrdered,QuantityDeliverded,OrderValue,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);
     return(View(order));
 }
Example #5
0
 public ActionResult Edit([Bind(Include = "ProductOrderId,ProductId,OrderId")] ProductOrder productOrder)
 {
     if (ModelState.IsValid)
     {
         db.Entry(productOrder).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.OrderId   = new SelectList(db.Orders, "OrderId", "OrderName", productOrder.OrderId);
     ViewBag.ProductId = new SelectList(db.Products, "ProductId", "ProductName", productOrder.ProductId);
     return(View(productOrder));
 }
Example #6
0
        /*This method will modify the data inside a specified id, must fulfill the specified conditions obviously.
         * Data has to be inserted according to the model and be sure that there is no duplication of key values inside the database
         */
        public IHttpActionResult PutProducts(int id, ProductsModel products)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != products.Id)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateException)
            {
                return(StatusCode(HttpStatusCode.Forbidden));
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }