コード例 #1
0
 public ActionResult Edit(int id, Customers1 customer)
 {
     try
     {
         using (DatabaseDataTableEntities2 dbModel = new DatabaseDataTableEntities2())
         {
             dbModel.Entry(customer).State = EntityState.Modified;
             dbModel.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
コード例 #2
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         using (DatabaseDataTableEntities2 dbModel = new DatabaseDataTableEntities2())
         {
             Customers1 customers = dbModel.Customers1.Where(x => x.CustomerID == id).FirstOrDefault();
             dbModel.Customers1.Remove(customers);
             dbModel.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
コード例 #3
0
        public ActionResult Create(Customers1 customer)
        {
            try
            {
                using (DatabaseDataTableEntities2 dbModel = new DatabaseDataTableEntities2())
                {
                    dbModel.Customers1.Add(customer);
                    dbModel.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }