public bool EditStudent(int studentId, Student student) { using (_entity = new StudentModal()) { return(_entity.EditStudent(studentId, student)); } }
} //List Method public int Update(StudentModal student) { int rowsAffected = 0; using (SqlConnection connection = new SqlConnection(_connectionString)) { connection.Open(); SqlCommand command = new SqlCommand("spUpdateStudent", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@Id", student.Id); command.Parameters.AddWithValue("@SessionId", student.SessionId); command.Parameters.AddWithValue("@SemesterId", student.SemesterId); command.Parameters.AddWithValue("@SectionId", student.SectionId); command.Parameters.AddWithValue("@RollNumber", student.RollNumber); command.Parameters.AddWithValue("@Name", student.Name); command.Parameters.AddWithValue("@FatherName", student.FatherName); command.Parameters.AddWithValue("@Password", student.Password); try { rowsAffected = command.ExecuteNonQuery(); } catch (Exception e) { return(0); } return(rowsAffected); } }
public bool AddStudent(Student student) { using (_entity = new StudentModal()) { return(_entity.AddStudent(student)); } }
public List <Student> GetStudentByClass(string selectedClass) { using (_entity = new StudentModal()) { return(_entity.GetStudentByClass(selectedClass)); } }
public Student GetStudentByEnrollmentNumber(int enrollmentNumber) { using (_entity = new StudentModal()) { return(_entity.GetStudentByEnrollmentNumber(enrollmentNumber)); } }
public List <Student> GetAllStudent() { using (_entity = new StudentModal()) { return(_entity.GetAllStudent()); } }
public int Insert(StudentModal student) { student.RollNumber = student.RollNumber.Trim(); student.Name = student.Name.Trim(); student.FatherName = student.FatherName.Trim(); student.Password = student.Password.Trim(); bool isDuplicate = CheckPrimaryKeyViolation(student.SemesterId, student.SessionId, student.SectionId, student.RollNumber); if (isDuplicate) { return(0); } int noOfRowsAffected = 0; using (SqlConnection connection = new SqlConnection(_connectionString)) { connection.Open(); SqlCommand command = new SqlCommand("spInsertStudent", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@SessionId", student.SessionId); command.Parameters.AddWithValue("@SemesterId", student.SemesterId); command.Parameters.AddWithValue("@SectionId", student.SectionId); command.Parameters.AddWithValue("@RollNumber", student.RollNumber); command.Parameters.AddWithValue("@Name", student.Name); command.Parameters.AddWithValue("@FatherName", student.FatherName); command.Parameters.AddWithValue("@Password", student.Password); try { noOfRowsAffected = command.ExecuteNonQuery(); } catch (SqlException ex) { if (ex.Number == 2627) { return(0); } } } return(noOfRowsAffected); } // Insert Method
public JsonResult Insert(StudentModal student) { return(Json(_databaseConnection.Insert(student), JsonRequestBehavior.AllowGet)); }
public JsonResult Update(StudentModal studentOject) { return(Json(_databaseConnection.Update(studentOject), JsonRequestBehavior.AllowGet)); }