Example #1
0
        public ActionResult NewStudent(HostelData stu)
        {
            var context = new MiniEntities();

            context.HostelDatas.Add(stu);
            context.SaveChanges();
            return(RedirectToAction("AllStudents"));
        }
Example #2
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"));
        }
Example #3
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"));
        }