Esempio n. 1
0
    protected void Submit_Click(object sender, EventArgs e)
    {
        Student AcceptedStudent = new Student();

        AcceptedStudent.StudentId = StudentIdTextBox.Text;
        AcceptedStudent.FirstName = FirstNameTextBox.Text;
        AcceptedStudent.LastName  = LastNameTextBox.Text;
        AcceptedStudent.Email     = EmailTextBox.Text;
        string ProgramCode = ProgramTextBox.Text;

        bool Confirmation;

        try
        {
            BCS RequestDirector = new BCS();
            Confirmation = RequestDirector.EnrollStudent(AcceptedStudent, ProgramCode);

            if (Confirmation)
            {
                MessagesLabel.Visible   = true;
                MessagesLabel.ForeColor = System.Drawing.Color.Green;
                MessagesLabel.Text      = ("Add student was successful");

                StudentIdTextBox.Text = "";
                FirstNameTextBox.Text = "";
                LastNameTextBox.Text  = "";
                EmailTextBox.Text     = "";
                ProgramTextBox.Text   = "";
            }
            else
            {
                MessagesLabel.ForeColor = System.Drawing.Color.Red;
                MessagesLabel.Visible   = true;
                MessagesLabel.Text      = ("Add student was not successful");
            }
        }
        catch (Exception ex)
        {
            MessagesLabel.Visible = true;
            //MessagesLabel.Text = ex.Message + "<br />"; this line looks ugly when the message is too long, look into this later
            MessagesLabel.Text      = ("Add student was not successful");
            MessagesLabel.ForeColor = System.Drawing.Color.DarkRed;
        }
    }
Esempio n. 2
0
        public void OnPost(string studentId, string firstName, string lastName, string email, string programList)
        {
            Student NewStudent = new Student()
            {
                StudentId   = studentId,
                FirstName   = firstName,
                LastName    = lastName,
                Email       = email,
                ProgramCode = programList
            };

            Success = _requestDirector.EnrollStudent(NewStudent);
            if (Success == true)
            {
                Message = "Student Created Successfully";
            }
            else
            {
                Message = "Student Create Failed";
            }
        }
Esempio n. 3
0
        public void OnPost()
        {
            if (ModelState.IsValid)
            {
                bool    Confirmation;
                Student AcceptedStudent = new Student
                {
                    StudentID = StudentIDField,
                    FirstName = FirstNameField,
                    LastName  = LastNameField,
                    Email     = EmailField
                };
                BCS RequestDirector = new BCS();
                Confirmation = RequestDirector.EnrollStudent(AcceptedStudent, ProgramCodeField);

                AcceptedStudent = RequestDirector.FindStudent(AcceptedStudent.StudentID);

                Message = $"{AcceptedStudent.FirstName} {AcceptedStudent.LastName} was enrolled :{Confirmation} in the {ProgramCodeField} program";
            }
            else
            {
                Message = $"Not Valid";
            }
        }