Exemplo n.º 1
0
        public static object button1(int[] listOfIds)
        {
            List <NabaT12> NAB = new List <NabaT12>();

            using (NabayubakDBEntities db = new NabayubakDBEntities())
            {
                if (listOfIds.Length > 0)
                {
                    foreach (var id in listOfIds)
                    {
                        var     list             = db.Table_2.Where(x => x.Id == id).ToList();
                        Table_2 dataOfTable1     = list.FirstOrDefault();
                        Table_1 insertIntoTable1 = new Table_1();
                        insertIntoTable1.Name1   = dataOfTable1.Name2;
                        insertIntoTable1.Name1Id = id;
                        db.Table_1.Add(insertIntoTable1);
                        db.SaveChanges();

                        db.Table_2.Remove(dataOfTable1);
                        db.SaveChanges();
                    }
                }

                return(db.Table_1.ToList());
            }
        }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Table_2 table_2 = db.Table_2.Find(id);

            db.Table_2.Remove(table_2);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "Id,Name,City,Address")] Table_2 table_2)
 {
     if (ModelState.IsValid)
     {
         db.Entry(table_2).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(table_2));
 }
Exemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "NumberPlate,carnumber,Cars,RentalPrice")] Table_2 table_2)
 {
     if (ModelState.IsValid)
     {
         db.Entry(table_2).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(table_2));
 }
Exemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "cost,carss,bikee")] Table_2 table_2)
 {
     if (ModelState.IsValid)
     {
         db.Entry(table_2).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.cost = new SelectList(db.Table_1, "cost", "cars", table_2.cost);
     return(View(table_2));
 }
Exemplo n.º 6
0
        public ActionResult Create([Bind(Include = "Name,City,Address")] Table_2 table_2)
        {
            if (ModelState.IsValid)
            {
                db.Table_2.Add(table_2);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(table_2));
        }
Exemplo n.º 7
0
        public ActionResult Create([Bind(Include = "NumberPlate,carnumber,Cars,RentalPrice")] Table_2 table_2)
        {
            if (ModelState.IsValid)
            {
                db.Table_2.Add(table_2);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(table_2));
        }
Exemplo n.º 8
0
        public ActionResult Create([Bind(Include = "cost,carss,bikee")] Table_2 table_2)
        {
            if (ModelState.IsValid)
            {
                db.Table_2.Add(table_2);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.cost = new SelectList(db.Table_1, "cost", "cars", table_2.cost);
            return(View(table_2));
        }
Exemplo n.º 9
0
        // GET: Table_2/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Table_2 table_2 = db.Table_2.Find(id);

            if (table_2 == null)
            {
                return(HttpNotFound());
            }
            return(View(table_2));
        }
Exemplo n.º 10
0
        // GET: Table_2/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Table_2 table_2 = db.Table_2.Find(id);

            if (table_2 == null)
            {
                return(HttpNotFound());
            }
            ViewBag.cost = new SelectList(db.Table_1, "cost", "cars", table_2.cost);
            return(View(table_2));
        }