public ActionResult delete(int id)
 {
     using (var db = new xyzContext())
     {
         tbl_order order1 = db.tbl_order.Find(id);
         db.tbl_order.Remove(order1);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View());
 }
        public ActionResult add(tbl_order order)
        {
            Rule rules = new Rule(order.day, order.request, order.typeVehicle, order.quantity);

            if (!ModelState.IsValid)
            {
                return(View());
            }

            try
            {
                using (var db = new xyzContext())
                {
                    db.tbl_order.Add(order);
                    db.SaveChanges();
                }

                using (var db1 = new xyzContext())
                {
                    tbl_order order1 = new tbl_order();

                    rules.order();
                    order.day         = rules.AssignedDay;
                    order.quantity    = rules.QuantityAvalible;
                    order.request     = rules.Request;
                    order.typeVehicle = rules.TypeVehicle;

                    order1 = order;
                    db1.tbl_order.Add(order1);

                    db1.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Error al crear", ex.Message);
                return(View());
            }
        }
        public ActionResult edit(tbl_order order)
        {
            try
            {
                using (var db = new xyzContext())
                {
                    tbl_order order1 = db.tbl_order.Find(order.id);
                    order1.day         = order.day;
                    order1.request     = order.request;
                    order1.typeVehicle = order.typeVehicle;
                    order1.quantity    = order.quantity;

                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }