Пример #1
0
        public ViewResult AllStudents()
        {
            var context = new MiniEntities();
            var model   = context.HostelDatas.ToList();

            return(View(model));
        }
Пример #2
0
        public ActionResult NewStudent(HostelData stu)
        {
            var context = new MiniEntities();

            context.HostelDatas.Add(stu);
            context.SaveChanges();
            return(RedirectToAction("AllStudents"));
        }
Пример #3
0
        public ViewResult Find(string id)
        {
            int RollNo  = int.Parse(id);
            var context = new MiniEntities();
            var model   = context.HostelDatas.FirstOrDefault((e) => e.RollNo == RollNo);

            return(View(model));
        }
Пример #4
0
        public ActionResult Delete(string id)
        {
            int RollNo = int.Parse(id);

            var context = new MiniEntities();
            var model   = context.HostelDatas.FirstOrDefault((e) => e.RollNo == RollNo);

            context.HostelDatas.Remove(model);
            context.SaveChanges();
            return(RedirectToAction("AllStudents"));
        }
Пример #5
0
        public ActionResult Find(HostelData stu)
        {
            var context = new MiniEntities();
            var model   = context.HostelDatas.FirstOrDefault((e) => e.RollNo == stu.RollNo);

            model.Name       = stu.Name;
            model.RoomNo     = stu.RoomNo;
            model.HostelName = stu.HostelName;
            model.ContactNo  = stu.ContactNo;
            context.SaveChanges();
            return(RedirectToAction("AllStudents"));
        }