Ejemplo n.º 1
0
        // 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));
        }
Ejemplo n.º 3
0
        //Retrieves all student details
        // GET: Student
        public ActionResult Index()
        {
            StudentDBHandle dbHandle = new StudentDBHandle();

            ModelState.Clear();
            return(View(dbHandle.GetStudent()));
        }
Ejemplo n.º 4
0
        // 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));
        }
Ejemplo n.º 5
0
        public JsonResult GetStudents()
        {
            // simulate delay
            Thread.Sleep(1500);
            StudentDBHandle dbhandle = new StudentDBHandle();

            ModelState.Clear();
            return(Json(dbhandle.GetStudent(), JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 6
0
        // 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));
        }
Ejemplo n.º 7
0
        // 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));
        }