public ActionResult AddNewSection_Post(TaxCourse taxcourse)
        {
            CourseSection        objcoursesection        = new CourseSection();
            CourseSectionContent objcourcesectioncontent = new CourseSectionContent();

            objcoursesection.CourseSectionName = taxcourse.SectionTitle;
            objcoursesection.CourseId          = taxcourse.Id;
            objcoursesection.IsDeleted         = false;

            this._coursesection.Add(objcoursesection);

            objcourcesectioncontent.CourseSectionID     = objcoursesection.CourseSectionId;
            objcourcesectioncontent.CourseContentTypeId = taxcourse.SectionType;
            objcourcesectioncontent.IsDeleted           = false;

            switch (taxcourse.SectionType)
            {
            case (int)Core.SectionType.Content:
                objcourcesectioncontent.CourseSectionContent1 = taxcourse.Text;
                break;

            case (int)Core.SectionType.Video:
                objcourcesectioncontent.CourseSectionContent1 = taxcourse.File;
                break;
            }


            this._coursesectioncontent.Add(objcourcesectioncontent);
            taxcourse.Text      = string.Empty;
            taxcourse.SectionID = objcoursesection.CourseSectionId;
            taxcourse.Type      = Convert.ToInt32(taxcourse.SectionType);

            return(RedirectToAction("GetContent", taxcourse));
        }
Exemple #2
0
 public IEnumerable <CourseSection> AddCourseSection(int CrsId, CourseSection courseSection)
 {
     courseSection.CrsId = CrsId;
     _db.CourseSections.Add(courseSection);
     _db.SaveChanges();
     return(GetCourseSections(CrsId));
 }
Exemple #3
0
        public async Task <IActionResult> Edit(int id, [Bind("CRN,FacultyId,Name")] CourseSection courseSection)
        {
            if (id != courseSection.CRN)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(courseSection);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CourseSectionExists(courseSection.CRN))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FacultyId"] = new SelectList(_context.Faculty, "Id", "Id", courseSection.FacultyId);
            return(View(courseSection));
        }
Exemple #4
0
        protected void dgUpdate_CourseSection(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            Label        lblTempID         = (Label)e.Item.Cells[0].FindControl("txtID");
            DropDownList txtTempCourseCode = (DropDownList)e.Item.Cells[0].FindControl("ddlCourseCode");
            TextBox      txtTempSectionNo  = (TextBox)e.Item.Cells[1].FindControl("txtSectionNo");

            Regex sectionRegex = new Regex(@"^\d{1,5}$");
            Match checkSection = sectionRegex.Match(txtTempSectionNo.Text);


            if (lblTempID.Text.Trim() == "" || txtTempCourseCode.Text.Trim() == "" || txtTempSectionNo.Text.Trim() == "")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type='text/javascript'>swal('Error!', 'Please fill in the course section information first!', 'error')</script>'");
            }
            else if (!checkSection.Success)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type='text/javascript'>swal('Error!', 'Section number must be digit only', 'error')</script>'");
            }
            else
            {
                CourseSection lec = new CourseSection();
                if (lec.Update(lblTempID.Text, txtTempCourseCode.Text, txtTempSectionNo.Text) == false)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type='text/javascript'>swal('Error!', 'This " + txtTempSectionNo.Text + " course section cannot have same section no, try another number!', 'error')</script>'");
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Success", "<script type='text/javascript'>swal({title: 'Updated!', text: 'This course section " + txtTempSectionNo.Text + " (" + txtTempCourseCode.Text + ") course section is updated successfully', type : 'success', confirmButtonText : 'OK'}, function (isConfirm) { if (isConfirm) { window.location.href = 'cpCourseSection.aspx'; }});</script>'");
                }
            }
        }
Exemple #5
0
        public async Task <IActionResult> Edit(int id, [Bind("CourseSectionId,Code,DateFrom,DateTo,Observations")] CourseSection courseSection)
        {
            if (id != courseSection.CourseSectionId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(courseSection);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CourseSectionExists(courseSection.CourseSectionId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(courseSection));
        }
Exemple #6
0
        public void TestMethod1()
        {
            string          content       = File.ReadAllText("C:\\Users\\renme_000\\Downloads\\run_results.json");
            dynamic         allCourseData = JsonConvert.DeserializeObject(content);
            List <UTCourse> allCourses    = new List <UTCourse>();

            foreach (dynamic category in allCourseData.categorydata)
            {
                foreach (dynamic course in category.course)
                {
                    UTCourse courseObj = new UTCourse();
                    string   code      = course.code;
                    courseObj.Code = code.Substring(0, 6);
                    string secstring = course.section;
                    if (code.Length > 8)
                    {
                        courseObj.Semester = code.Substring(9, 1);
                    }
                    else
                    {
                        courseObj.Semester = secstring.Substring(0, 1);
                    }
                    courseObj.SemesterPrefix = code.Substring(6, 2);
                    courseObj.Name           = course.name;
                    Trace.Write(courseObj.Abbr);
                    try
                    {
                        foreach (dynamic activity in course.activities)
                        {
                            CourseSection section = new CourseSection();
                            section.Name = activity.name;
                            Trace.Write(" " + section.Name);
                            List <CourseSectionTimeSpan> meetTimes = new List <CourseSectionTimeSpan>();
                            foreach (dynamic time in activity.times)
                            {
                                string day      = time.dayofweek;
                                string timeFrom = time.time_from;
                                string timeTo   = time.time_to;
                                CourseSectionTimeSpan timespan;
                                timespan.Day   = ((DayOfWeek)Enum.Parse(typeof(DayOfWeek), day));
                                timespan.Start = (byte)(Convert.ToInt32(timeFrom.Substring(0, 2)) * 4 + Convert.ToInt32(timeFrom.Substring(3, 2)));
                                timespan.End   = (byte)(Convert.ToInt32(timeTo.Substring(0, 2)) * 4 + Convert.ToInt32(timeTo.Substring(3, 2)));
                                meetTimes.Add(timespan);
                            }
                            section.Time = new CourseSectionTime(meetTimes).ToString();
                            courseObj.Sections.Add(section);
                        }
                    }
                    catch (NullReferenceException e)
                    {
                        Trace.WriteLine(e.ToString());
                        continue;
                    }
                    Trace.WriteLine("");
                    allCourses.Add(courseObj);
                }
            }
            Trace.WriteLine(string.Format("Total number of courses: {0}", allCourses.Count));
        }
Exemple #7
0
        public IEnumerable <CourseSection> DeleteCourseSection(int crsId, int sectionId)
        {
            CourseSection courseSection = _db.CourseSections.FirstOrDefault(obj => obj.CrsId == crsId && obj.SectionId == sectionId);

            _db.CourseSections.Remove(courseSection);
            _db.SaveChanges();
            return(GetCourseSections(crsId));
        }
Exemple #8
0
        public void SetupCourseSection()
        {
            dgCourseSection.ShowFooter = true;
            CourseSection courseSection = new CourseSection();
            DataSet       ds            = courseSection.GetDisplay();

            dgCourseSection.DataSource = ds.Tables["CourseSection"];
            dgCourseSection.DataBind();
        }
Exemple #9
0
 public SectionCardViewModel(CourseSection section, int customisationId, bool showPercentageCourseSetting)
 {
     Title           = section.Title;
     SectionId       = section.Id;
     PercentComplete = section.HasLearning && showPercentageCourseSetting
         ? $"{Convert.ToInt32(Math.Floor(section.PercentComplete))}% learning complete"
         : "";
     CustomisationId = customisationId;
     PostLearningAssessmentPassed = section.PostLearningAssessmentPassed;
 }
        public IActionResult GetCourseSection(int SecID)
        {
            CourseSection courseSection = _db.GetCourseSection(SecID);

            if (courseSection == null)
            {
                return(BadRequest("Not Exist"));
            }
            return(Ok(courseSection));
        }
        public void SetupStudentRegisterCourse()
        {
            dgStudentRegisterCourse.ShowFooter = true;
            string        StudentID = Session["StudentID"].ToString();
            CourseSection lec       = new CourseSection();
            DataSet       ds        = lec.GetDisplayBasedStudent();

            dgStudentRegisterCourse.DataSource = ds.Tables["CourseSection"];
            dgStudentRegisterCourse.DataBind();
        }
Exemple #12
0
        public CourseSection CourseSectionFind(string ChapterID)
        {
            String    stmtId = "CourseSection_Find";
            Hashtable ht     = new Hashtable();

            ht.Add("ChapterID", ChapterID);

            CourseSection result = ExecuteQueryForObject <CourseSection>(stmtId, ht);

            return(result);
        }
Exemple #13
0
        public async Task <IActionResult> Create([Bind("CourseSectionId,Code,DateFrom,DateTo,Observations")] CourseSection courseSection)
        {
            if (ModelState.IsValid)
            {
                _context.Add(courseSection);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(courseSection));
        }
Exemple #14
0
 public void DataBind(CourseSection data = null)
 {
     if (data == null)
     {
         courseSection = new CourseSection();
         state         = FormState.Add;
     }
     else
     {
         state = FormState.Modify;
     }
 }
Exemple #15
0
        public async Task <IActionResult> Create([Bind("CRN,FacultyId,Name")] CourseSection courseSection)
        {
            if (ModelState.IsValid)
            {
                _context.Add(courseSection);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FacultyId"] = new SelectList(_context.Faculty, "Id", "Id", courseSection.FacultyId);
            return(View(courseSection));
        }
Exemple #16
0
        protected void dgCourseSection_ItemCommand(object sender, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            CourseSection lec = new CourseSection();

            if (e.CommandName == "AddCourseSection")
            {
                DropDownList txtTempCourseCode = (DropDownList)e.Item.Cells[0].FindControl("ddlCourseCodeNew");
                TextBox      txtTempSectionNo  = (TextBox)e.Item.Cells[1].FindControl("txtSectionNoNew");

                Regex sectionRegex = new Regex(@"^\d{1,5}$");
                Match checkSection = sectionRegex.Match(txtTempSectionNo.Text);

                if (txtTempCourseCode.Text.Trim() == "")
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type='text/javascript'>swal('Error!', 'Please fill in the course code!', 'error')</script>'");
                }
                else if (!checkSection.Success)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type='text/javascript'>swal('Error!', 'Section number must be digit only', 'error')</script>'");
                }
                else if (txtTempSectionNo.Text.Trim() == "")
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type='text/javascript'>swal('Error!', 'Please fill in the section number!', 'error')</script>'");
                }
                else
                {
                    if (lec.Add(txtTempCourseCode.Text, txtTempSectionNo.Text) == false)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type='text/javascript'>swal('Error!', 'This " + txtTempSectionNo.Text + " course section cannot have same section no, try another number!', 'error')</script>'");
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "Success", "<script type='text/javascript'>swal({title: 'Added!', text: 'This course section " + txtTempSectionNo.Text + " (" + txtTempCourseCode.Text + ") course section is added successfully', type : 'success', confirmButtonText : 'OK'}, function (isConfirm) { if (isConfirm) { window.location.href = 'cpCourseSection.aspx'; }});</script>'");
                    }
                }
            }

            else if (e.CommandName == "DeleteCourseSection")
            {
                Label rowCourseSectionID = (Label)e.Item.Cells[0].FindControl("lblID");

                if (lec.DeleteCourseSection(rowCourseSectionID.Text) == false)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type='text/javascript'>swal('Error!', 'Delete this course section record unsuccessfully', 'error')</script>'");
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Success", "<script type='text/javascript'>swal({title: 'Deleted!', text: 'Deleted this course section record successfully', type : 'success', confirmButtonText : 'OK'}, function (isConfirm) { if (isConfirm) { window.location.href = 'cpCourseSection.aspx'; }});</script>'");
                }
            }
        }
Exemple #17
0
        // GET: Courses/Details/5
        public ActionResult CSDetails(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CourseSection courseSection = Repository.getCourseAndSections(id);

            if (courseSection == null)
            {
                return(HttpNotFound());
            }
            return(View(courseSection));
        }
        public IActionResult AddCourseSection(int CrsId, CourseSection courseSection)
        {
            if (CrsId > 0)
            {
                IEnumerable <CourseSection> CrsSections = _db.AddCourseSection(CrsId, courseSection);
                if (CrsSections != null)
                {
                    return(Ok(CrsSections));
                }

                return(BadRequest("Error"));
            }
            return(BadRequest("Error"));
        }
Exemple #19
0
        public Guid SaveTimetable(TimetableModel timetable)
        {
            if (timetable == null)
            {
                throw new ArgumentNullException("timetable");
            }

            if (timetable.Id == null)
            {
                throw new ArgumentNullException("timetable.Id");
            }

            Timetable tt = this.UnitOfWork.TimetableRepository.GetById(timetable.Id);

            if (tt == null)
            {
                throw new InvalidOperationException($"Timetable ({timetable.Id}) does not exist.");
            }


            for (int i = 0; i < timetable.ShiftPerDay * timetable.SlotPerShift; i++)
            {
                for (int j = 0; j < Commons.Constants.DAY_OF_WEEK; j++)
                {
                    CourseSectionSchedule cs = timetable.TimeTableMatrix[i, j];
                    if (cs.Checked && (cs.Id == null || cs.Id == Guid.Empty))
                    {// Added
                        //CourseSection courseSection = Mapper.Map<CourseSectionSchedule, CourseSection>(cs);
                        CourseSection courseSection = new CourseSection();
                        courseSection.Day         = (DayOfWeek)j;
                        courseSection.Id          = Guid.NewGuid();
                        courseSection.TimetableId = timetable.Id;
                        courseSection.Stage       = COURSE_SECTION_STAGE.OPEN;
                        courseSection.Shift       = cs.Shift;
                        courseSection.Slot        = cs.Slot;

                        this.UnitOfWork.CourseSectionRepository.Insert(courseSection);
                    }
                    else if (!cs.Checked && (cs.Id != Guid.Empty))
                    {// Remove
                        //CourseSection courseSection = Mapper.Map<CourseSectionSchedule, CourseSection>(cs);
                        this.UnitOfWork.CourseSectionRepository.DeleteCourseSection(cs.Id);
                    }
                }
            }

            this.UnitOfWork.SaveChanges();

            return(tt.Id);
        }
        static void Main(string[] args)
        {
            Student student = new Student(123);
            Instructor instructor = new Instructor(100);
            Course course = new Course(2070, "Data Structures and Algo", 3);
            CourseSection section = new CourseSection(1005, course, instructor);

            section.addStudent(student);
            // Class period
            ClassPeriod period = new ClassPeriod(1, section);
            period.markStudentPresent(student);
            period.printStatus();

            Console.ReadLine();
        }
        private Faculty MapLineToFaculty(string line)
        {
            string[]      column = line.Split(',');
            CourseSection course = new CourseSection {
                CRN       = Convert.ToInt32(column[4]),
                Name      = column[3],
                FacultyId = Convert.ToInt32(column[0])
            };
            ICollection <CourseSection> courseList = new List <CourseSection>()
            {
                course
            };

            return(new Faculty {
                Id = Convert.ToInt32(column[0]), FirstName = column[1], LastName = column[2], CourseSections = courseList
            });
        }
Exemple #22
0
        public void SaveScheduleBoard(UpdateTimetableBoardModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            if (model.CourseSections == null)
            {
                throw new ArgumentNullException("model.CourseSections");
            }

            foreach (CourseSectionModel csModel in model.CourseSections)
            {
                CourseSection cs = new CourseSection()
                {
                    ClassCourseId = csModel.ClassCourseId,
                    Id            = csModel.Id,
                    Day           = csModel.Day,
                    Shift         = csModel.Shift,
                    Slot          = csModel.Slot,
                    TimetableId   = csModel.TimetableId
                };

                if (cs.Id == Guid.Empty)
                {
                    if (csModel.ClassCourse != null)
                    {
                        cs.Id            = Guid.NewGuid();
                        cs.ClassCourseId = csModel.ClassCourse.Id;

                        this.UnitOfWork.CourseSectionRepository.Insert(cs);
                    }
                }
                else
                {
                    this.UnitOfWork.CourseSectionRepository.Update(cs, x => x.ClassCourseId);
                }
            }

            if (model.CourseSections.Count > 0)
            {
                this.UnitOfWork.SaveChanges();
            }
        }
        public void Test_GetAllOpportunity()
        {
            //Initialize SqlQueryHelper object
            var sqlConnection = new SqlConnection(ConnectionString);

            sqlConnection.Open();

            var command = new SqlCommand("select count(*) from opportunity_section where OpportunityID = 10", sqlConnection);
            var csCount = Convert.ToInt32(command.ExecuteScalar());

            //Opportunity

            CourseSection cs = new CourseSection();

            List <CourseSection> csList = cs.GetAssignedCourseSection(10);

            Assert.AreEqual(csCount, csList.Count);
        }
Exemple #24
0
        public CourseSection GetSection(int id)
        {
            CourseSection item = null;

            DataProvider.ExecuteCmd(GetConnection, "dbo.Sections_SelectByCourseId",
                                    inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@Id", id);
            },
                                    map : delegate(IDataReader reader, short set)
            {
                item = new CourseSection();
                int startingIndex = 0;

                item.Id       = reader.GetSafeInt32(startingIndex++);
                item.CourseId = reader.GetSafeInt32(startingIndex++);
                item.Info     = reader.GetSafeString(startingIndex++);
            }
                                    );
            return(item);
        }
Exemple #25
0
        protected void dgCourseSection_ItemDataBound(object source, System.Web.UI.WebControls.DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                ((Button)e.Item.FindControl("btnDeleteCourseSection")).Attributes.Add("onClick", "return confirmDeleteCourseSection(this);");
                ((WebControl)e.Item.Cells[2].Controls[0]).CssClass = "btn btn-warning";
            }

            if (e.Item.ItemType == ListItemType.EditItem)
            {
                ((WebControl)e.Item.Cells[2].Controls[0]).CssClass = "btn btn-warning";
                ((WebControl)e.Item.Cells[2].Controls[2]).CssClass = "btn btn-secondary";
            }
            if (e.Item.ItemType == ListItemType.Footer)
            {
                CourseSection courseSection = new CourseSection();
                ArrayList     courseList    = courseSection.SelectCourseCode("", "");
                DropDownList  dddl          = (e.Item.FindControl("ddlCourseCodeNew") as DropDownList);

                dddl.DataSource     = courseList;
                dddl.DataTextField  = "Value";
                dddl.DataValueField = "Key";
                dddl.DataBind();
            }
            else if (e.Item.ItemType == ListItemType.EditItem)
            {
                CourseSection courseSection  = new CourseSection();
                ArrayList     courseList     = courseSection.SelectCourseCode("", "");
                DropDownList  dddl           = (e.Item.FindControl("ddlCourseCode") as DropDownList);
                Label         CourseCodeEdit = (Label)e.Item.Cells[0].FindControl("lblCourseCodeEdit");

                dddl.DataSource     = courseList;
                dddl.DataTextField  = "Value";
                dddl.DataValueField = "Key";
                dddl.DataBind();
                dddl.SelectedIndex = dddl.Items.IndexOf(dddl.Items.FindByText(CourseCodeEdit.Text));
            }
        }
Exemple #26
0
        public async Task <bool> SaveVideoInfoAsync(CourseVideoDto videoInfo)
        {
            var video = EntityMapper.Map <CourseVideoDto, Video>(videoInfo);

            var coursesection = new CourseSection
            {
                CourseId = videoInfo.CourseSectionId,
                Title    = videoInfo.SectionTitle,
                Order    = videoInfo.Order,
            };

            _unitOfWork.CoursesRepository.AddCourseSection(coursesection);
            await _unitOfWork.SaveWorkAsync();

            video.Duration = "5:00";
            _unitOfWork.CoursesRepository.AddVideoInfo(video);

            if (await _unitOfWork.SaveWorkAsync() > 0)
            {
                return(true);
            }
            return(false);
        }
Exemple #27
0
        static void Main(string[] args)
        {
            CatalogContext con = new CatalogContext();

            int choice = -1;

            do
            {
                Console.WriteLine("Menu:\n0. Quit\n1. Populate database\n2. Show courses\n3. Show course sections\n"
                                  + "4. Print transcript");
                choice = Convert.ToInt32(Console.ReadLine());

                switch (choice)
                {
                case 1:
                    // Add some courses to the catalog
                    var cecs174 = new CatalogCourse()
                    {
                        DepartmentName = "CECS",
                        CourseNumber   = "174",
                    };
                    con.Courses.Add(cecs174);

                    var cecs274 = new CatalogCourse()
                    {
                        DepartmentName = "CECS",
                        CourseNumber   = "274",
                    };
                    cecs274.Prerequisites.Add(cecs174);
                    con.Courses.Add(cecs274);

                    var cecs228 = new CatalogCourse()
                    {
                        DepartmentName = "CECS",
                        CourseNumber   = "228",
                    };
                    cecs228.Prerequisites.Add(cecs174);
                    con.Courses.Add(cecs228);

                    var cecs277 = new CatalogCourse()
                    {
                        DepartmentName = "CECS",
                        CourseNumber   = "277",
                    };
                    cecs277.Prerequisites.Add(cecs274);
                    cecs277.Prerequisites.Add(cecs228);
                    con.Courses.Add(cecs277);

                    // Add a semester term
                    var spring2017 = new SemesterTerm()
                    {
                        Name      = "Spring 2017",
                        StartDate = new DateTime(2017, 1, 23),
                        EndDate   = new DateTime(2017, 5, 26)
                    };
                    con.SemesterTerms.Add(spring2017);
                    var fall2017 = new SemesterTerm()
                    {
                        Name      = "Fall 2017",
                        StartDate = new DateTime(2017, 8, 21),
                        EndDate   = new DateTime(2017, 12, 22)
                    };
                    con.SemesterTerms.Add(fall2017);

                    // Add instructors
                    var neal = new Instructor()
                    {
                        FirstName = "Neal",
                        LastName  = "Terrell",
                    };
                    con.Instructors.Add(neal);
                    var anthony = new Instructor()
                    {
                        FirstName = "Anthony",
                        LastName  = "Giacalone"
                    };
                    con.Instructors.Add(anthony);

                    // Add sections
                    var cecs174_99 = new CourseSection()
                    {
                        CatalogCourse = cecs174,
                        SectionNumber = 1,
                        Instructor    = neal,
                        MeetingDays   = DaysOfWeek.Monday | DaysOfWeek.Wednesday,
                        StartTime     = new DateTime(2017, 1, 1, 8, 0, 0),                             // 9 am
                        EndTime       = new DateTime(2017, 1, 1, 8, 50, 0),
                    };
                    spring2017.CourseSections.Add(cecs174_99);

                    var cecs228_99 = new CourseSection()
                    {
                        CatalogCourse = cecs228,
                        SectionNumber = 1,
                        Instructor    = anthony,
                        MeetingDays   = DaysOfWeek.Friday,
                        StartTime     = new DateTime(2017, 1, 1, 10, 0, 0),                             // 9 am
                        EndTime       = new DateTime(2017, 1, 1, 11, 50, 0),
                    };
                    spring2017.CourseSections.Add(cecs228_99);

                    var cecs228_01 = new CourseSection()
                    {
                        CatalogCourse = cecs228,
                        SectionNumber = 1,
                        Instructor    = neal,
                        MeetingDays   = DaysOfWeek.Tuesday | DaysOfWeek.Thursday,
                        StartTime     = new DateTime(2017, 1, 1, 9, 0, 0),                             // 9 am
                        EndTime       = new DateTime(2017, 1, 1, 9, 50, 0),
                    };
                    fall2017.CourseSections.Add(cecs228_01);

                    //var cecs228_03 = new CourseSection() {
                    //	CatalogCourse = cecs228,
                    //	SectionNumber = 1,
                    //	Instructor = neal,
                    //	MeetingDays = DaysOfWeek.Monday | DaysOfWeek.Wednesday,
                    //	StartTime = new DateTime(2017, 1, 1, 12, 30, 0), // 9 am
                    //	EndTime = new DateTime(2017, 1, 1, 13, 20, 0),
                    //};
                    //fall2017.CourseSections.Add(cecs228_03);

                    var cecs274_05 = new CourseSection()
                    {
                        CatalogCourse = cecs274,
                        SectionNumber = 5,
                        Instructor    = anthony,
                        MeetingDays   = DaysOfWeek.Tuesday | DaysOfWeek.Thursday,
                        StartTime     = new DateTime(2017, 1, 1, 9, 30, 0),                             // 9 am
                        EndTime       = new DateTime(2017, 1, 1, 10, 20, 0),
                    };
                    fall2017.CourseSections.Add(cecs274_05);

                    var cecs274_11 = new CourseSection()
                    {
                        CatalogCourse = cecs274,
                        SectionNumber = 11,
                        Instructor    = anthony,
                        MeetingDays   = DaysOfWeek.Monday | DaysOfWeek.Wednesday | DaysOfWeek.Friday,
                        StartTime     = new DateTime(2017, 1, 1, 13, 0, 0),                             // 1 pm
                        EndTime       = new DateTime(2017, 1, 1, 13, 50, 0),
                    };
                    fall2017.CourseSections.Add(cecs274_11);

                    Student s1 = new Student()
                    {
                        FirstName = "A",
                        LastName  = "B",
                    };
                    s1.Transcript.Add(new CourseGrade()
                    {
                        CourseSection = cecs174_99,
                        Grade         = GradeTypes.A
                    });
                    s1.Transcript.Add(new CourseGrade()
                    {
                        CourseSection = cecs228_99,
                        Grade         = GradeTypes.D
                    });
                    con.Students.Add(s1);

                    Student s2 = new Student()
                    {
                        FirstName = "C",
                        LastName  = "D",
                    };
                    con.Students.Add(s2);

                    con.SaveChanges();
                    break;

                case 2:
                    // Print all courses in the catalog
                    foreach (var course in con.Courses.OrderBy(c => c.CourseNumber))
                    {
                        Console.Write($"{course.DepartmentName} {course.CourseNumber}");
                        if (course.Prerequisites.Count > 0)
                        {
                            Console.Write(" (Prerequisites: ");
                            Console.Write(string.Join(", ", course.Prerequisites));
                            Console.Write(")");
                        }
                        Console.WriteLine();
                    }

                    break;

                case 3:
                    // Print all offered sections for Fall 2017
                    var fallSem = con.SemesterTerms.Where(s => s.Name == "Fall 2017").FirstOrDefault();
                    if (fallSem == null)
                    {
                        break;
                    }

                    Console.WriteLine($"{fallSem.Name}: {fallSem.StartDate.ToString("MMM dd")} - {fallSem.EndDate.ToString("MMM dd")}");
                    foreach (var section in fallSem.CourseSections)
                    {
                        Console.WriteLine($"{section.CatalogCourse}-{section.SectionNumber.ToString("D2")} -- " +
                                          $"{section.Instructor.FirstName[0]} {section.Instructor.LastName} -- " +
                                          $"{section.MeetingDays}, {section.StartTime.ToShortTimeString()} to {section.EndTime.ToShortTimeString()}");
                    }
                    break;

                case 4:
                    Console.WriteLine("Enter a name:");
                    string   name = Console.ReadLine();
                    string[] split = name.Split(' ');
                    string   f = split[0], l = split[1];
                    Student  tStudent = con.Students.Where(s => s.FirstName == f && s.LastName == l)
                                        .FirstOrDefault();
                    if (tStudent == null)
                    {
                        Console.WriteLine("Not found");
                        break;
                    }
                    Console.WriteLine($"{tStudent.FirstName} {tStudent.LastName}");
                    Console.WriteLine("Transcript: {0}",
                                      string.Join(", ", tStudent.Transcript));

                    break;

                case 5:
                    Console.WriteLine("Enter a name:");
                    string   ename = Console.ReadLine();
                    string[] esplit = ename.Split(' ');
                    string   ef = esplit[0], el = esplit[1];
                    Student  eStudent = con.Students.Where(s => s.FirstName == ef && s.LastName == el)
                                        .FirstOrDefault();
                    if (eStudent == null)
                    {
                        Console.WriteLine("Not found");
                        break;
                    }

                    Console.WriteLine("Enter a course section for Fall 2017:");
                    string   cName  = Console.ReadLine();
                    string[] csplit = cName.Split(new char[] { ' ', '-' });
                    string   dept   = csplit[0];
                    string   num    = csplit[1];
                    int      sec    = Convert.ToInt32(csplit[2]);

                    SemesterTerm  f2017 = con.SemesterTerms.Where(s => s.Name == "Fall 2017").First();
                    CourseSection sec2  = f2017.CourseSections.Where(
                        c => c.CatalogCourse.DepartmentName == dept &&
                        c.CatalogCourse.CourseNumber == num &&
                        c.SectionNumber == sec).FirstOrDefault();

                    if (sec2 == null)
                    {
                        Console.WriteLine("not found");
                        break;
                    }

                    var register = eStudent.CanRegisterForCourseSection(sec2);
                    Console.WriteLine(register);
                    break;
                }
                Console.WriteLine();
                Console.WriteLine();
            } while (choice != 0);
        }
 public ClassPeriod(int classPeriodId, CourseSection section)
 {
     this.classPeriodId = classPeriodId;
     this.section = section;
 }
Exemple #29
0
        public void SaveScheduleBoard(ScheduleBoard scheduleBoard)
        {
            if (scheduleBoard == null)
            {
                Logger.Error($"scheduleBoard is empty.");
                throw new ArgumentNullException("scheduleBoard");
            }

            Logger.Debug($"Start saving schedule board: {scheduleBoard.Id}");

            Schedule.Models.SchedulingTable schedule = this.UnitOfWork.SchedulingTableRepository.GetById(scheduleBoard.Id);

            if (schedule == null)
            {
                Logger.Error($"Schedule ({scheduleBoard.Id}) does not exist.");
                throw new InvalidOperationException($"Schedule ({scheduleBoard.Id}) does not exist.");
            }

            var mapper = config.CreateMapper();

            foreach (ClassGroupSchedule cg in scheduleBoard.ClassGroups)
            {
                foreach (ClassRoomSchedule crs in cg.ClassRooms)
                {
                    Timetable tt = new Timetable()
                    {
                        Id           = Guid.NewGuid(),
                        Name         = crs.Name,
                        ShiftPerDay  = crs.Timetable.ShiftPerDay,
                        SlotPerShift = crs.Timetable.SlotPerShift,
                    };

                    this.UnitOfWork.ClassTimetableRepository.Create(scheduleBoard.Id, crs.Id, tt);

                    for (int i = 0; i < crs.Timetable.ShiftPerDay * crs.Timetable.SlotPerShift; i++)
                    {
                        for (int j = 0; j < Commons.Constants.DAY_OF_WEEK; j++)
                        {
                            CourseSectionSchedule cs = crs.Timetable.TimeTableMatrix[i, j];

                            if (cs != null && (cs.Id != null && cs.Id != Guid.Empty) && (cs.ClassCourse != null && (cs.ClassCourse.Id != null && cs.ClassCourse.Id != Guid.Empty)))
                            {// Added
                                //CourseSection courseSection = mapper.Map<CourseSectionSchedule, CourseSection>(cs);
                                CourseSection courseSection = new CourseSection();
                                courseSection.Day           = (DayOfWeek)j;
                                courseSection.Id            = Guid.NewGuid();
                                courseSection.TimetableId   = tt.Id;
                                courseSection.ClassCourseId = cs.ClassCourse.Id;
                                courseSection.Stage         = cs.Stage;
                                courseSection.Shift         = cs.Shift;
                                courseSection.Slot          = cs.Slot;

                                this.UnitOfWork.CourseSectionRepository.Insert(courseSection);
                            }
                        }
                    }
                }
            }

            this.UnitOfWork.SaveChanges();

            Logger.Debug($"Complete saving schedule board: {scheduleBoard.Id}");
        }
        public CourseSection GetSection(int id)
        {
            CourseSection item = null;

            DataProvider.ExecuteCmd(GetConnection, "dbo.Sections_SelectByCourseId",
                inputParamMapper: delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@Id", id);
            },
            map: delegate(IDataReader reader, short set)
             {
             item = new CourseSection();
             int startingIndex = 0;

             item.Id = reader.GetSafeInt32(startingIndex++);
             item.CourseId = reader.GetSafeInt32(startingIndex++);
             item.Info = reader.GetSafeString(startingIndex++);

             }
            );
            return item;
        }
Exemple #31
0
        public void CourseSectionUpdate(CourseSection courseSection)
        {
            String stmtId = "CourseSection_Update";

            ExecuteUpdate(stmtId, courseSection);
        }
Exemple #32
0
        public void CourseSectionInsert(CourseSection courseSection)
        {
            String stmtId = "CourseSection_Insert";

            ExecuteInsert(stmtId, courseSection);
        }
Exemple #33
0
        public override IEnumerable <UTCourse> FetchItems()
        {
            List <UTCourse> results = new List <UTCourse>();

            if (this.Content == null)
            {
                return(results);
            }

            this.Content = this.Content.Replace("\r\n", String.Empty);

            MatchCollection matches = CourseRegex.Matches(this.Content);

            // Used to accumulating course meet times
            string tempTime     = "";
            string tempLocation = "";

            foreach (Match match in matches)
            {
                string line = match.Value;
                line = line.Replace("</td>", "|");
                line = AngleRegex.Replace(line, String.Empty);
                line = CircleRegex.Replace(line, String.Empty);

                string[] properties = line.Split('|');

                Match codeMatch = CodeRegex.Match(properties[0]);

                // Get rid of those which the first course in the page does not start with legit course code
                if (!codeMatch.Success && results.Count == 0)
                {
                    continue;
                }

                string        code          = codeMatch.Groups["code"].ToString();
                string        prefix        = codeMatch.Groups["prefix"].ToString();
                CourseSection courseSection = null;

                if (properties.Length < 4)
                {
                    continue;
                }
                string semester        = properties[1].Trim(' ');
                string name            = properties[2].Trim(' ');
                string section         = properties[3].Trim(' ');
                string wait            = null;
                string time            = null;
                string location        = null;
                string instructor      = null;
                string matchedLocation = null;


                // Meaning this section of this course is not cancelled
                if (properties.Length >= 8)
                {
                    wait       = properties[4].Trim(' ');
                    time       = properties[5].Replace(" ", "").Replace(",", "");
                    location   = properties[6].Replace(" ", "");
                    instructor = properties[7].Trim(' ').Replace("&nbsp;", "");

                    if (wait.Contains("Cancel"))
                    {
                        continue;
                    }

                    CourseSectionTime ptime;
                    if (UTCourseSectionTime.TryParseRawTime(time, out ptime))
                    {
                        // Construct same location n times matching the meeting times
                        if (!location.Equals("&nbsp;"))
                        {
                            matchedLocation = location;
                            for (int i = 1; i < ptime.MeetTimes.Count(); i++)
                            {
                                matchedLocation = String.Join(" ", matchedLocation, location);
                            }
                        }
                        else
                        {
                            // Get the location from the previous section
                            if (section.Equals("&nbsp;"))
                            {
                                if (results.Count > 0)
                                {
                                    if (results.Last <UTCourse>().Sections.Count > 0)
                                    {
                                        location = results.Last <UTCourse>().Sections.Last <CourseSection>().Location;
                                        if (location != null)
                                        {
                                            location        = location.Split(' ')[0];
                                            matchedLocation = location;
                                            for (int i = 1; i < ptime.MeetTimes.Count(); i++)
                                            {
                                                matchedLocation = String.Join(" ", matchedLocation, location);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                // For some exceptions, section time is not written in one string, need to accumulating meet times
                if (section.Equals("&nbsp;"))
                {
                    if (properties.Length >= 8)
                    {
                        tempTime    += time;
                        tempLocation = String.Join(" ", tempLocation, matchedLocation);
                    }
                    else
                    {
                        tempTime     = "";
                        tempLocation = "";
                    }
                }
                else
                {
                    if (properties.Length >= 8)
                    {
                        courseSection = new UTCourseSection()
                        {
                            Name       = section,
                            WaitList   = wait.Equals("Y"),
                            Instructor = instructor,
                            Time       = time,
                            Location   = location
                        };
                    }

                    UTCourse lastCourse = null;

                    if (results.Count > 0)
                    {
                        lastCourse = results.Last <UTCourse>();

                        if (!String.IsNullOrEmpty(tempTime))
                        {
                            if (lastCourse.Sections.Count > 0)
                            {
                                // Update the last tempTime and tempLocation
                                CourseSection lastSection = lastCourse.Sections.Last <CourseSection>();
                                lastSection.Time     = tempTime;
                                lastSection.Location = tempLocation;
                            }
                        }
                    }

                    tempTime     = time;
                    tempLocation = matchedLocation;

                    // Only need to add a section
                    if (!codeMatch.Success)
                    {
                        if (lastCourse != null)
                        {
                            if (courseSection != null)
                            {
                                lastCourse.Sections.Add(courseSection);
                                Console.Write(" {0} ", courseSection.Name);
                            }
                        }
                        continue;
                    }

                    // Construct a course
                    UTCourse course = new UTCourse()
                    {
                        Code           = code,
                        Name           = name,
                        Semester       = semester,
                        SemesterPrefix = prefix,
                        Campus         = "UTSG"
                    };

                    // Add the newly constructed courseSection (if not cancelled) into the course
                    if (courseSection != null)
                    {
                        course.Sections.Add(courseSection);
                        Console.Write("{0}Course: {1} {2}", Environment.NewLine, course.Abbr, courseSection.Name);
                    }
                    else
                    {
                        Console.Write("{0}Course: {1} ", Environment.NewLine, course.Abbr);
                    }
                    results.Add(course);
                }
            }

            if (results.Count > 0)
            {
                // Commit the last change to the last section
                if (results.Last <UTCourse>().Sections.Count > 0)
                {
                    CourseSection lastSec = results.Last <UTCourse>().Sections.Last <CourseSection>();
                    lastSec.Time     = tempTime;
                    lastSec.Location = tempLocation;
                }
            }
            return(results);
        }