Exemple #1
0
 /// <summary>
 /// 审核
 /// </summary>
 /// <param name="id">课程ID</param>
 /// <param name="auditID">审核ID</param>
 /// <returns></returns>
 public BaseObject AuditCourse(int id, int auditID)
 {
     using (CourseLogic logic = new CourseLogic())
     {
         return(logic.AuditCourse(id, auditID));
     }
 }
Exemple #2
0
 public List <CourseEntity> GetCourseList()
 {
     using (CourseLogic logic = new CourseLogic())
     {
         return(logic.GetCourseList());
     }
 }
Exemple #3
0
 protected override void OnLoad(EventArgs e)
 {
     this.StudentField.DataSource = StudentLogic.GetAll();
     this.StudentField.DataBind();
     this.CourseField.DataSource = CourseLogic.GetAll();
     this.CourseField.DataBind();
 }
Exemple #4
0
 public CourseTypeEntity GetCourseTypeByID(int id)
 {
     using (CourseLogic logic = new CourseLogic())
     {
         return(logic.GetCourseTypeByID(id));
     }
 }
Exemple #5
0
 public BaseObject InsertCourseType(CourseTypeEntity param)
 {
     using (CourseLogic logic = new CourseLogic())
     {
         return(logic.InsertCourseType(param));
     }
 }
Exemple #6
0
 /// <summary>
 /// 课程列表
 /// </summary>
 /// <param name="param"></param>
 /// <param name="totalCount"></param>
 /// <returns></returns>
 public List <CourseEntity> GetCourseReport(GetReportDataParams param, out int totalCount)
 {
     using (CourseLogic logic = new CourseLogic())
     {
         return(logic.GetCourseReport(param, out totalCount));
     }
 }
Exemple #7
0
 public List <KeyName> GetCourseTypeKeyName()
 {
     using (CourseLogic logic = new CourseLogic())
     {
         return(logic.GetCourseTypeKeyName());
     }
 }
Exemple #8
0
 public BaseObject UpdateCourse(CourseEntity param)
 {
     using (CourseLogic logic = new CourseLogic())
     {
         return(logic.UpdateCourse(param));
     }
 }
Exemple #9
0
 public BaseObject DeleteCourse(int id)
 {
     using (CourseLogic logic = new CourseLogic())
     {
         return(logic.DeleteCourse(id));
     }
 }
Exemple #10
0
        public CourseController(ApplicationDbContext context, UserManager <ApplicationUser> userManager)
        {
            _context     = context;
            _userManager = userManager;

            _courseLogic = new CourseLogic(context, userManager);
        }
        public async Task <Result> AddAsync(CourseLogic course, UserLogic user)
        {
            try
            {
                course.Id           = Guid.NewGuid().ToString();
                course.Author       = user;
                course.CreationDate = DateTime.Now;
                course.Raiting      = null;
                course.Duration     = course.Audios.Aggregate(0, (x, y) => x + y.Duration);
                user.UploadedCourses.Add(course);
                var userDb   = mapper.Map <UserLogic, UserDb>(user);
                var courseDb = mapper.Map <CourseLogic, CourseDb>(course);
                await UdbManager.UpdateAsync(userDb);

                var result = await dbmanager.AddAsync(courseDb);

                return(Result.Ok());
            }
            catch (DbUpdateConcurrencyException e)
            {
                return(Result.Fail(e.Message));
            }
            catch (DbUpdateException e)
            {
                return(Result.Fail(e.Message));
            }
            catch (DbEntityValidationException e)
            {
                return(Result.Fail(e.Message));
            }
            catch (Exception)
            {
                return(Result.Fail("Exception"));
            }
        }
        public async Task <Result> BuyAsync(CourseLogic courselogic, UserLogic userId)
        {
            try
            {
                userId.BoughtCourses.Add(courselogic);
                var userDb = mapper.Map <UserLogic, UserDb>(userId);
                await UdbManager.UpdateAsync(userDb);

                return(Result.Ok());
            }
            catch (DbUpdateConcurrencyException e)
            {
                return(Result.Fail(e.Message));
            }
            catch (DbUpdateException e)
            {
                return(Result.Fail(e.Message));
            }
            catch (DbEntityValidationException e)
            {
                return(Result.Fail(e.Message));
            }
            catch (Exception)
            {
                return(Result.Fail("Exception"));
            }
        }
        public async Task <Result> UpdateAsync(CourseLogic course, UserLogic user)
        {
            try
            {
                if (user.UploadedCourses.Contains(course) || user.IsAdmin)
                {
                    var courseDb = mapper.Map <CourseLogic, CourseDb>(course);
                    await dbmanager.UpdateAsync(courseDb);

                    return(Result.Ok());
                }
                else
                {
                    return(Result.Fail("Unathorized"));
                }
            }
            catch (DbUpdateConcurrencyException e)
            {
                return(Result.Fail(e.Message));
            }
            catch (DbUpdateException e)
            {
                return(Result.Fail(e.Message));
            }
            catch (DbEntityValidationException e)
            {
                return(Result.Fail(e.Message));
            }
            catch (Exception)
            {
                return(Result.Fail("Exception"));
            }
        }
Exemple #14
0
        public void TestGetRecommendationsList()
        {
            List <Course> result = CourseLogic.GetRecommendationsList(testCourseList);

            Assert.IsNotNull(result);
            Assert.IsTrue(!result.Contains(testCourse1));
            Assert.IsTrue(result.Contains(testCourse2));
        }
Exemple #15
0
        public void TestGetAllDepartments()
        {
            List <string> result = CourseLogic.GetAllDepartments(testCourseList);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Contains("Test Department 1"));
            Assert.IsTrue(result.Contains("Test Department 2"));
        }
Exemple #16
0
 public TimetableController()
 {
     _logic        = new TimetableLogic();
     _logicCourse  = new CourseLogic();
     _logicModule  = new ModuleLogic();
     _logicTeacher = new TeacherLogic();
     _repo         = new AttendanceRepository();
 }
Exemple #17
0
 public AttendanceController()
 {
     _studentLogic    = new StudentLogic();
     _eventLogic      = new EventLogic();
     _absentTypeLogic = new AbsentTypeLogic();
     _attendanceLogic = new AttendanceLogic();
     _absentLogLogic  = new AbsentLogLogic();
     _courseLogic     = new CourseLogic();
 }
 public ClientMenuHandler(LogsLogic logs, Socket clientSocket, Socket notificationSocket, StudentLogic studentLogicHandler, CourseLogic courseLogicHandler, ref List <Utils.StudentSocket> pClients)
 {
     Protocol           = new Protocol();
     ClientSocket       = clientSocket;
     NotificationSocket = notificationSocket;
     studentLogic       = studentLogicHandler;
     courseLogic        = courseLogicHandler;
     clients            = pClients;
     Logs = logs;
 }
Exemple #19
0
        /// <summary>Gets a list of all of the Courses in the database which are associated with the Teacher table via the ID column.</summary>
        /// <param name="teacherID">The ID of the Teacher for which to retrieve the child Courses.</param>
        /// <returns>An IEnumerable of Courses.</returns>
        public IEnumerable <SO.Course> GetCoursesByTeacherID(string teacherID, string page)
        {
            IEnumerable <DA.Course> returnValue = CourseLogic.GetByTeacherID(ParseInt("id", teacherID));

            if (returnValue != null)
            {
                return(ServiceUtil.GetPage(returnValue, ParseInt("page", page)).Select(o => SO.Course.FromDataAccessObject(o)));
            }

            return(null);
        }
Exemple #20
0
        public void TestUpdateSectionRatingNewInstructor()
        {
            int    updateRating  = 3;
            string newInstructor = "Test Instructor 42";

            CourseLogic.UpdateSectionRating(newInstructor, updateRating, testCourse1);

            Assert.IsTrue(testCourse1.SectionRatings.ContainsKey("Test Instructor 42"));
            Assert.AreEqual(testCourse1.SectionRatings["Test Instructor 42"]["count"], 1);
            Assert.AreEqual(testCourse1.SectionRatings["Test Instructor 42"]["rating"], updateRating);
        }
        /// <summary>Gets a list of all of the Courses in the database which are associated with the Teacher table via the ID column.</summary>
        /// <param name="teacherID">The ID of the Teacher for which to retrieve the child Courses.</param>
        /// <returns>An IEnumerable of Courses.</returns>
        public IEnumerable <SO.Course> GetCoursesByTeacherID(int teacherID, int page)
        {
            IEnumerable <DA.Course> returnValue = CourseLogic.GetByTeacherID(teacherID);

            if (returnValue != null)
            {
                return(ServiceUtil.GetPage(returnValue, page).Select(o => SO.Course.FromDataAccessObject(o)));
            }

            return(null);
        }
        public JsonResult GetCourses(int progId, int deptId, int levelId)
        {
            List <COURSE>         courses          = new List <COURSE>();
            List <SelectListItem> courseSelectList = new List <SelectListItem>();

            try
            {
                if (progId > 0 && deptId > 0 && levelId > 0)
                {
                    CourseLogic courseLogic = new CourseLogic();

                    courses = courseLogic.GetEntitiesBy(c => c.Department_Id == deptId && c.Level_Id == levelId && c.Programme_Id == progId && c.Active);
                    if (User.IsInRole("Lecturer"))
                    {
                        UserLogic        userLogic        = new UserLogic();
                        USER             user             = userLogic.GetEntityBy(u => u.Username == User.Identity.Name);
                        StaffLogic       staffLogic       = new StaffLogic();
                        StaffCourseLogic staffCourseLogic = new StaffCourseLogic();
                        STAFF            staff            = staffLogic.GetEntitiesBy(s => s.Person_Id == user.Person_Id).LastOrDefault();
                        if (staff != null)
                        {
                            List <STAFF_COURSE> staffCourses = staffCourseLogic.GetEntitiesBy(s => s.Staff_Id == staff.Person_Id);
                            if (staffCourses != null)
                            {
                                courses = staffCourses.Select(s => s.COURSE).ToList();
                            }
                            else
                            {
                                courses = new List <COURSE>();
                            }
                        }
                    }

                    SelectListItem list = new SelectListItem();
                    list.Value = "";
                    list.Text  = "-- Select Course --";
                    courseSelectList.Add(list);

                    courses.ForEach(c =>
                    {
                        SelectListItem myList = new SelectListItem();
                        myList.Value          = c.Id.ToString();
                        myList.Text           = c.Code + " - " + c.Name;
                        courseSelectList.Add(myList);
                    });
                }
            }
            catch (Exception ex)
            {
            }

            return(Json(courseSelectList, JsonRequestBehavior.AllowGet));
        }
Exemple #23
0
        public void TestGetCoursesForDept()
        {
            List <Course> result1 = CourseLogic.GetCoursesForDept(testCourseList, "Test Department 1");

            Assert.IsNotNull(result1);
            Assert.IsTrue(result1.Contains(testCourse1));

            List <Course> result2 = CourseLogic.GetCoursesForDept(testCourseList, "Test Department 2");

            Assert.IsNotNull(result2);
            Assert.IsTrue(result2.Contains(testCourse2));
        }
Exemple #24
0
        public void TestUpdateDifficulty()
        {
            int    updateDiff    = 5;
            double initDiff      = testCourse1.Difficulty;
            int    initDiffCount = testCourse1.DifficultyCount;
            double expectedDiff  = ((initDiff * initDiffCount) + updateDiff) / (initDiffCount + 1);

            expectedDiff = Math.Round(expectedDiff, 1);

            CourseLogic.UpdateDifficulty(updateDiff, testCourse1);

            Assert.AreEqual(testCourse1.DifficultyCount, initDiffCount + 1);
            Assert.AreEqual(testCourse1.Difficulty, expectedDiff);
        }
Exemple #25
0
        public void TestUpdateSectionRatingSameInstructor()
        {
            int    updateRating   = 3;
            double initRating     = testCourse1.SectionRatings["Instructor 1"]["rating"];
            double initCount      = testCourse1.SectionRatings["Instructor 1"]["count"];
            double expectedRating = ((initRating * initCount) + updateRating) / (initCount + 1);

            expectedRating = Math.Round(expectedRating, 1);

            CourseLogic.UpdateSectionRating("Instructor 1", updateRating, testCourse1);

            Assert.AreEqual(testCourse1.SectionRatings["Instructor 1"]["count"], initCount + 1);
            Assert.AreEqual(testCourse1.SectionRatings["Instructor 1"]["rating"], expectedRating);
        }
        protected void Grid_ItemCommand(object sender, DataGridCommandEventArgs e)
        {
            if ("Edit".Equals(e.CommandName))
            {
                int primaryKey = (int)this.Grid.DataKeys[e.Item.ItemIndex];

                this.OnEdit(CourseLogic.GetByID(this.DataContext, primaryKey));
            }
            else if ("Delete".Equals(e.CommandName))
            {
                int primaryKey = (int)this.Grid.DataKeys[e.Item.ItemIndex];

                this.OnDelete(CourseLogic.GetByID(this.DataContext, primaryKey));
            }
        }
Exemple #27
0
        public JsonResult SaveCourse(long courseId, string code, string name, int progId, int deptId, int levelId)
        {
            JsonResponseModel result = new JsonResponseModel();

            try
            {
                if (courseId > 0 && !string.IsNullOrEmpty(code) && !string.IsNullOrEmpty(name) && progId > 0 && deptId > 0 && levelId > 0)
                {
                    CourseLogic courseLogic = new CourseLogic();
                    COURSE      course      = courseLogic.GetEntityBy(c => c.Id == courseId);

                    COURSE existingCourse = courseLogic.GetEntitiesBy(c => c.Code.ToLower().Trim() == code.ToLower().Trim() && c.Id != courseId).LastOrDefault();
                    if (existingCourse == null)
                    {
                        if (course != null)
                        {
                            course.Department_Id = deptId;
                            course.Programme_Id  = progId;
                            course.Level_Id      = levelId;
                            course.Code          = code;
                            course.Name          = name;

                            courseLogic.Modify(course);
                        }

                        result.IsError = false;
                        result.Message = "Operation Successful!";
                    }
                    else
                    {
                        result.IsError = true;
                        result.Message = "Course with the same code exists.";
                    }
                }
                else
                {
                    result.IsError = true;
                    result.Message = "Invalid parameter";
                }
            }
            catch (Exception ex)
            {
                result.IsError = true;
                result.Message = ex.Message;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public async void UpdateExistingCourse(string key, int newDifficulty, string instructorName, int newRating)
        {
            var item = await _context.LoadAsync <Course>(key);

            if (item != null)
            {
                CourseLogic.UpdateDifficulty(newDifficulty, item);
                CourseLogic.UpdateSectionRating(instructorName, newRating, item);

                await _context.SaveAsync(item);
            }
            else
            {
                throw new SimpliPassException("Failed to update existing course: course not found in database.");
            }
        }
        public async Task <List <string> > GetAllDepartments()
        {
            List <string> departmentList = new List <string>();

            var courses = await _context.ScanAsync <Course>(new List <ScanCondition>()).GetRemainingAsync();

            if (courses != null)
            {
                departmentList = CourseLogic.GetAllDepartments(courses);
            }
            else
            {
                throw new SimpliPassException("Failed to get Courses Table.");
            }

            return(departmentList);
        }
        public async Task <List <Course> > GetRecommendations()
        {
            List <Course> list = new List <Course>();

            var courses = await _context.ScanAsync <Course>(new List <ScanCondition>()).GetRemainingAsync();

            if (courses != null)
            {
                list = CourseLogic.GetRecommendationsList(courses);
            }
            else
            {
                throw new SimpliPassException("Failed to get Courses Table.");
            }

            return(list);
        }