Example #1
0
        /// <summary>
        /// Submit the order - save to the database (still editable).
        /// </summary>
        /// <returns></returns>
        public bool Submit()
        {
            if (this.ItemsOrdered.Count == 0)
            {
                Statics.DebugOut("Error: cannot submit an order without an items");
                return(false);
            }


            using (InvContext ctx = new InvContext())
            {
                // ensure the context knows about this item in reference to the database
                ctx.Customers.Attach(this.Customer);

                ctx.Entry(this).State = this.OrderID == default(int) ? EntityState.Added : EntityState.Modified;


                // tell the database that this item already exists or needs to be added

                this.DateOrdered = DateTime.Now;
                this.OrderCode   = "ABC" + Statics.rand.Next(0, 999).ToString().PadLeft(3, '0');

                ctx.SaveChanges();
            }

            return(true);
        }
Example #2
0
 public ActionResult Edit([Bind(Include = "TransactionID,Status,DateCreated")] Transaction transaction)
 {
     if (ModelState.IsValid)
     {
         db.Entry(transaction).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(transaction));
 }
Example #3
0
 public ActionResult Edit([Bind(Include = "CategoryID,CategoryName")] Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
Example #4
0
 public ActionResult Edit([Bind(Include = "ProductID,CategoryID,ProductName,QuantityPerUnit,Stocks,Price,Available")] Product product)
 {
     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));
 }
Example #5
0
 public virtual void Actualizar(T entidad)
 {
     db.Entry(entidad).State = System.Data.Entity.EntityState.Modified;
 }