Пример #1
0
        public ActionResult GetCity(int state)
        {
            Employee1Context context = new Employee1Context();

            var cities = context.CityList.Where(c => c.StateId == state);

            return(Json(cities, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        /*   #region--Create Method--
         *  public ActionResult Create()
         *  {
         *
         *      Employee1Context context = new Employee1Context();
         *      ViewBag.StateList = context.StateList;
         *      var model = new Employee();
         *      return View(model);
         *  }
         *
         *
         *  [HttpPost]
         *  public ActionResult Create(Employee model)
         *  {
         *     // Employee1Context context = new Employee1Context ();
         *
         *      if (ModelState.IsValid)
         *      {
         *          context.EmpList.Add(model);
         *          context.SaveChanges();
         *          return RedirectToAction("Index");
         *
         *      }
         *      ViewBag.StateList = context.StateList;
         *      return View(model);
         *  }
         #endregion */



        #region --GetData For DataTable--
        public ActionResult GetData()
        {
            using (Employee1Context context = new Employee1Context())
            {
                var EmployeeData = context.EmpList.OrderBy(a => a.EmployeeName).ToList();
                return(Json(new { data = EmployeeData }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #3
0
 public HomeController()
 {
     context = new Employee1Context();
 }