Esempio n. 1
0
        public bool SaveStudentDetails(StudentDetail Stu) // calling SaveStudentMethod for insert a new record
        {
            bool result = false;

            using (StudentInformationEntities _entity = new StudentInformationEntities())
            {
                _entity.StudentDetails.Add(Stu);
                _entity.SaveChanges();
                result = true;
            }
            return(result);
        }
Esempio n. 2
0
        public bool DeleteStudentDetails(StudentDetail Stu) // DeleteStudentDetails method to delete record from table
        {
            bool result = false;

            using (StudentInformationEntities _entity = new StudentInformationEntities())
            {
                StudentDetail _student = _entity.StudentDetails.Where(x => x.Id == Stu.Id).Select(x => x).FirstOrDefault();
                _entity.StudentDetails.Remove(_student);
                _entity.SaveChanges();
                result = true;
            }
            return(result);
        }
Esempio n. 3
0
        public bool UpdateStudentDetails(StudentDetail Stu) // UpdateStudentDetails method for update a existing Record
        {
            bool result = false;

            using (StudentInformationEntities _entity = new StudentInformationEntities())
            {
                StudentDetail _student = _entity.StudentDetails.Where(x => x.Id == Stu.Id).Select(x => x).FirstOrDefault();
                _student.Name   = Stu.Name;
                _student.Age    = Stu.Age;
                _student.City   = Stu.City;
                _student.Gender = Stu.Gender;
                _entity.SaveChanges();
                result = true;
            }
            return(result);
        }