public void Test_ModifyCourse()
        {
            var service   = new DataService();
            var person    = service.GetPerson(2);
            var professor = service.GetPerson(5);
            var course    = new CourseDAO()
            {
                Title = "TS-001", Department = "Testing", Professor = professor, StartTime = 20, EndTime = 21, Capacity = 1, Credit = 1, Active = true
            };
            var actual = false;

            if (service.AddCourse(course))
            {
                foreach (var item in service.GetCourses())
                {
                    if (item.Title == course.Title && item.Department == course.Department && item.Professor.Id == course.Professor.Id && item.StartTime == course.StartTime && item.EndTime == course.EndTime)
                    {
                        actual = service.ModifyCourse(item, 3, 21, 22);

                        if (service.CancelCourse(item))
                        {
                            Assert.True(actual);
                        }
                        else
                        {
                            Assert.True(false);
                        }
                    }
                }
            }

            Assert.True(actual);
        }
    protected void AddCourse_Click(object sender, EventArgs e)
    {
        if (Page.IsValid == true)
        {
            DataService d = new DataService();

            if (!d.IsCourseAlreadyExist(CourseName.Text))
            {
                d.AddCourse(CourseName.Text, Price.Text, Description.Text, RoomType.SelectedItem.Value.ToString());
                Server.Transfer("CoverPage.aspx");
            }
            else
            {
                message.Visible   = true;
                message.Text      = "Course name already exist.";
                message.ForeColor = System.Drawing.Color.OrangeRed;
            }
        }
        else
        {
            message.Visible   = true;
            message.Text      = "Page is not valid";
            message.ForeColor = System.Drawing.Color.OrangeRed;
        }
    }
Exemplo n.º 3
0
        private bool AddCourseValidated()
        {
            if (string.IsNullOrWhiteSpace(PersonId_Text.Text))
            {
                return(false);
            }

            var person = data.GetPerson(int.Parse(PersonId_Text.Text));
            var course = new CourseDAO()
            {
                Title      = CourseTitle_Text.Text,
                Department = CourseDepartment_Text.Text,
                Professor  = person,
                StartTime  = int.Parse(CourseStart_Text.Text),
                EndTime    = int.Parse(CourseEnd_Text.Text),
                Capacity   = int.Parse(CourseCapacity_Text.Text),
                Credit     = int.Parse(CourseCredit_Text.Text),
                Active     = true
            };

            var result = data.AddCourse(course);

            if (result)
            {
                CourseTitle_Text.Text      = "";
                CourseDepartment_Text.Text = "";
                CourseStart_Text.Text      = "";
                CourseEnd_Text.Text        = "";
                CourseCapacity_Text.Text   = "";
                CourseCredit_Text.Text     = "";
                CourseTitle2_List.Items.Clear();
                CourseTitle3_List.Items.Clear();
                CourseTitle4_List.Items.Clear();

                foreach (var item in data.GetCourses())
                {
                    if (item.Professor.Id == person.Id)
                    {
                        CourseTitle2_List.Items.Add(new ListItem()
                        {
                            Text = item.Title, Value = item.Id.ToString()
                        });
                        CourseTitle3_List.Items.Add(new ListItem()
                        {
                            Text = item.Title, Value = item.Id.ToString()
                        });
                        CourseTitle4_List.Items.Add(new ListItem()
                        {
                            Text = item.Title, Value = item.Id.ToString()
                        });
                    }
                }
            }

            return(result);
        }
Exemplo n.º 4
0
        public void AddCourse(object sender, EventArgs e)
        {
            var       data   = new DataService();
            CourseDAO course = new CourseDAO();

            course.name           = coursename_textbox.Text;
            course.number         = int.Parse(coursenumber_textbox.Text);
            course.maxStudents    = int.Parse(coursemax_textbox.Text);
            course.StartClassTime = TimeSpan.Parse(starttime_textbox.Text);
            course.EndClassTime   = TimeSpan.Parse(endtime_textbox.Text);

            data.AddCourse(course);
            coursename_textbox.Text   = string.Empty;
            coursenumber_textbox.Text = string.Empty;
            coursemax_textbox.Text    = string.Empty;
            starttime_textbox.Text    = string.Empty;
            endtime_textbox.Text      = string.Empty;
            addcoursefields.Visible   = false;
            addremovecourse_listbox.Items.Clear();
            addremovecourse_div.Visible = false;
        }