示例#1
0
 // GET: Customer
 public ActionResult Index()
 {
     using (tbl_studentModel db = new tbl_studentModel())
     {
         CustomersViewModel model = new CustomersViewModel();
         model.Customers = db.Customer.OrderBy(
             m => m.CustomerID).Take(5).ToList();
         model.SelectedCustomer = null;
         return(View(model));
     }
 }
示例#2
0
 public ActionResult Edit(string id)
 {
     using (tbl_studentModel db = new tbl_studentModel())
     {
         CustomersViewModel model = new CustomersViewModel();
         model.Customers = db.Customer.OrderBy(
             m => m.CustomerID).Take(5).ToList();
         model.SelectedCustomer = db.Customer.Find(id);
         model.DisplayMode      = "ReadWrite";
         return(View("Index", model));
     }
 }
示例#3
0
 public ActionResult New()
 {
     using (tbl_studentModel db = new tbl_studentModel())
     {
         CustomersViewModel model = new CustomersViewModel();
         model.Customers = db.Customer.OrderBy(
             m => m.CustomerID).Take(5).ToList();
         model.SelectedCustomer = null;
         model.DisplayMode      = "WriteOnly";
         return(View("Index", model));
     }
 }
示例#4
0
        public ActionResult Insert(Customer obj)
        {
            using (tbl_studentModel db = new tbl_studentModel())
            {
                db.Customer.Add(obj);
                db.SaveChanges();

                CustomersViewModel model = new CustomersViewModel();
                model.Customers = db.Customer.OrderBy(
                    m => m.CustomerID).Take(5).ToList();
                model.SelectedCustomer = db.Customer.Find(obj.CustomerID);
                model.DisplayMode      = "ReadOnly";
                return(View("Index", model));
            }
        }
示例#5
0
        public ActionResult Delete(string id)
        {
            using (tbl_studentModel db = new tbl_studentModel())
            {
                Customer existing = db.Customer.Find(id);
                db.Customer.Remove(existing);
                db.SaveChanges();

                CustomersViewModel model = new CustomersViewModel();
                model.Customers = db.Customer.OrderBy(
                    m => m.CustomerID).Take(5).ToList();

                model.SelectedCustomer = null;
                model.DisplayMode      = "";
                return(View("Index", model));
            }
        }
示例#6
0
        public ActionResult Update(Customer obj)
        {
            using (tbl_studentModel db = new tbl_studentModel())
            {
                Customer existing = db.Customer.Find(obj.CustomerID);
                existing.CompanyName = obj.CompanyName;
                existing.ContactName = obj.ContactName;
                existing.Country     = obj.Country;
                db.SaveChanges();

                CustomersViewModel model = new CustomersViewModel();
                model.Customers = db.Customer.OrderBy(
                    m => m.CustomerID).Take(5).ToList();

                model.SelectedCustomer = existing;
                model.DisplayMode      = "ReadOnly";
                return(View("Index", model));
            }
        }