コード例 #1
0
 public ActionResult Edit(int id, customerdetail customer)
 {
     try
     {
         // TODO: Add update logic here
         using (CustomerModels cst = new CustomerModels())
         {
             cst.Entry(customer).State = EntityState.Modified;
             cst.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
コード例 #2
0
        public ActionResult Create(customerdetail customer)
        {
            try
            {
                using (CustomerModels cst = new CustomerModels())
                {
                    cst.customerdetails.Add(customer);
                    cst.SaveChanges();
                }
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #3
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                using (CustomerModels cd = new CustomerModels())
                //modelname
                {
                    customerdetail customer = cd.customerdetails.Where(x => x.id == id).FirstOrDefault();
                    //tablenmame               searching id from table name
                    cd.customerdetails.Remove(customer);
                    //table name
                    cd.SaveChanges();
                }

                // TODO: Add delete logic here

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