コード例 #1
0
        public Message Save(Student newStudent)
        {
            Message message = new Message();
            bool isStudentExists = IsStudentExists(newStudent);

            if (isStudentExists)
            {
                message.Status = "warning";
                message.Details = "Registration Number is already exists.";
                return message;
            }

            StudentGateway aStudentGateway = new StudentGateway();
            int totalRowsAffected = aStudentGateway.AddStudent(newStudent);
            if (totalRowsAffected > 0)
            {
                message.Status = "success";
                message.Details = "Data Saved Successfully";
            }
            else
            {
                message.Status = "error";
                message.Details = "Operation Failed.";
            }

            return message;
        }
コード例 #2
0
        private bool IsStudentExists(Student newStudent)
        {
            StudentGateway aStudentGateway = new StudentGateway();

            Student aStudent = aStudentGateway.GetStudentByRegNo(newStudent.RegNo);

            if (aStudent != null)
            {
                return true;
            }
            return false;
        }
コード例 #3
0
 public Student GetStudentByRegNo(string regNo)
 {
     StudentGateway aStudentGateway = new StudentGateway();
     Student student = aStudentGateway.GetStudentByRegNo(regNo);
     return student;
 }
コード例 #4
0
 public List<Student> GetAll()
 {
     StudentGateway aStudentGateway = new StudentGateway();
     List<Student> students = aStudentGateway.GetAll();
     return students;
 }