Beispiel #1
0
 // GET: Customer/Delete/5
 public ActionResult Delete(int id)
 {
     using (dbModels dbModel = new dbModels())
     {
         return(View(dbModel.Customers.Where(x => x.Id == id).FirstOrDefault()));
     }
 }
Beispiel #2
0
 // GET: Customer
 public ActionResult Index()
 {
     using (dbModels dbModel = new dbModels())
     {
         return(View(dbModel.Customers.ToList()));
     }
 }
Beispiel #3
0
 // GET: Customer/Edit/5
 public ActionResult Edit(int id)
 {
     using (dbModels obj = new dbModels())
     {
         return(View(obj.Customers.Where(x => x.ID == id).FirstOrDefault()));
     }
 }
Beispiel #4
0
        public ActionResult Edit(int id, Customer customer)
        {
            try
            {
                using (dbModels dbModel = new dbModels())
                {
                    dbModel.Entry(customer).State = EntityState.Modified;
                    dbModel.SaveChanges();
                }
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #5
0
        public ActionResult Create(Customer customer)
        {
            try
            {
                using (dbModels dbModel = new dbModels())
                {
                    dbModel.Customers.Add(customer);
                    dbModel.SaveChanges();
                }
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #6
0
        public ActionResult Create(Customer custobj)
        {
            try
            {
                // TODO: Add insert logic here
                using (dbModels obj = new dbModels())
                {
                    obj.Customers.Add(custobj);
                    obj.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #7
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                using (dbModels dbModel = new dbModels())
                {
                    Customer customer = dbModel.Customers.Where(x => x.Id == id).FirstOrDefault();
                    dbModel.Customers.Remove(customer);
                    dbModel.SaveChanges();
                }
                // TODO: Add delete logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
 public LandingPageRepositroy(dbModels context)
 {
     this.context = context;
 }