Exemplo n.º 1
0
 // GET: Customer/Delete/5
 public ActionResult Delete(int id)
 {
     using (Customer1Entities ce = new Customer1Entities())
     {
         return(View(ce.Customers.Where(x => x.Id == id).FirstOrDefault()));
     }
 }
Exemplo n.º 2
0
 // GET: Customer/Index
 public ActionResult Index()
 {
     using (Customer1Entities ce = new Customer1Entities())
     {
         return(View(ce.Customers.ToList()));
     }
 }
Exemplo n.º 3
0
 public ActionResult Edit(int id, Customer c)
 {
     try
     {
         // TODO: Add update logic here
         using (Customer1Entities ce = new Customer1Entities())
         {
             ce.Entry(c).State = EntityState.Modified;
             ce.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 4
0
        public ActionResult Create(Customer c)
        {
            try
            {
                // TODO: Add insert logic here
                using (Customer1Entities ce = new Customer1Entities())
                {
                    ce.Customers.Add(c);
                    ce.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 5
0
        public ActionResult Delete(int id, Customer customer)
        {
            try
            {
                // TODO: Add delete logic here
                using (Customer1Entities ce = new Customer1Entities())
                {
                    customer = ce.Customers.Where(x => x.Id == id).FirstOrDefault();
                    ce.Customers.Remove(customer);
                    ce.SaveChanges();
                }

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