// GET: Student public ActionResult Index(string search, string option) { StudentDBHandle dbhandle = new StudentDBHandle(); ModelState.Clear(); List <StudentModel> ll = new List <StudentModel>(); ll = dbhandle.GetStudent(); if (option == "Name") { List <StudentModel> ss = ll.Where(x => x.Name == search).ToList(); return(View(ss)); } else if (option == "City") { return(View(ll.Where(x => x.City == search).ToList())); } else if (option == "Address") { return(View(ll.Where(x => x.Address == search).ToList())); } else { return(View(ll)); } }
public IHttpActionResult Index() { StudentDBHandle dbhandle = new StudentDBHandle(); var students = dbhandle.GetStudent(); return(Ok(students)); }
//Retrieves all student details // GET: Student public ActionResult Index() { StudentDBHandle dbHandle = new StudentDBHandle(); ModelState.Clear(); return(View(dbHandle.GetStudent())); }
// 3. ************* EDIT STUDENT DETAILS ****************** // GET: Student/Edit/5 public ActionResult Edit(int id) { StudentDBHandle sdb = new StudentDBHandle(); var dd = sdb.GetStudent().Find(smodel => smodel.Id == id); return(View()); // return View(sdb.GetStudent().Find(smodel => smodel.Id == id)); }
public JsonResult GetStudents() { // simulate delay Thread.Sleep(1500); StudentDBHandle dbhandle = new StudentDBHandle(); ModelState.Clear(); return(Json(dbhandle.GetStudent(), JsonRequestBehavior.AllowGet)); }
// 2. *************ADD NEW STUDENT ****************** // GET: Student/Create public ActionResult Create(int?id) { StudentDBHandle sdb = new StudentDBHandle(); var dd = sdb.GetStudent().Find(smodel => smodel.Id == id); //dd.IsMovie = (dd.IsMovie == false) ? false : dd.IsMovie; //dd.IsCricket = (dd.IsCricket == false) ? false : dd.IsCricket; var genList = sdb.GenList().ToList(); ViewBag.GenList = new SelectList(genList, "Id", "Name"); return(View(dd)); // return View(sdb.GetStudent().Find(smodel => smodel.Id == id)); }
// 1. *************RETRIEVE ALL STUDENT DETAILS ****************** // GET: Student public ActionResult Index(string SortOrder, string SortBy) { ViewBag.SortOrder = SortOrder; StudentDBHandle dbhandle = new StudentDBHandle(); var dd = dbhandle.GetStudent().ToList(); switch (SortBy) { case "Name": { switch (SortOrder) { case "Asc": { dd = dd.OrderBy(x => x.Name).ToList(); break; } case "Desc": { dd = dd.OrderByDescending(x => x.Name).ToList(); break; } default: { dd = dd.OrderBy(x => x.Name).ToList(); break; } } break; } case "City": { switch (SortOrder) { case "Asc": { dd = dd.OrderBy(x => x.City).ToList(); break; } case "Desc": { dd = dd.OrderByDescending(x => x.City).ToList(); break; } default: { dd = dd.OrderBy(x => x.City).ToList(); break; } } break; } case "DOB": { switch (SortOrder) { case "Asc": { dd = dd.OrderBy(x => x.DOB).ToList(); break; } case "Desc": { dd = dd.OrderByDescending(x => x.DOB).ToList(); break; } default: { dd = dd.OrderBy(x => x.DOB).ToList(); break; } } break; } default: { dd = dd.OrderBy(x => x.Name).ToList(); break; } } ModelState.Clear(); return(View(dd)); }