Exemple #1
0
        /// <summary>
        /// Adds the course to examination.
        /// </summary>
        /// <param name="exams">Exams.</param>
        /// <param name="courseId">Course identifier.</param>
        public void AddCourseToExamination(List <ResCourseToExam> exams, int courseId)
        {
            if (exams.Count > 0)
            {
                var examSql       = "Res_CourseToExam.CourseId = " + courseId;
                var list          = _dataAccess.GetList <ResCourseToExam>(examSql);
                var manager       = new ExampaperManager();
                var exampaperlist = new List <tbExampaperRedundancy>();
                if (list.Count > 0)
                {
                    exampaperlist = manager.GetAllExampaperRedundancy(list.Select(p => p.ExampaperId));
                }

                foreach (var item in exams)
                {
                    var tmp = exampaperlist.FirstOrDefault(p => p.ExampaperId == item.ExampaperId);
                    if (tmp == null)
                    {
                        item.ExampaperId = manager.InsertExampaperRedundancy(item.ExampaperId, 0);
                    }
                    else
                    {
                        item.ExampaperId = tmp._id;
                    }
                }
            }
            _dataAccess.DeleteEntities <ResCourseToExam>("Res_CourseToExam.CourseId = " + courseId);
            if (exams.Count > 0)
            {
                _dataAccess.AddEntities(exams);
            }
        }
Exemple #2
0
        /// <summary>
        /// Loads the course examinations.
        /// </summary>
        /// <returns>The course examinations.</returns>
        /// <param name="courseId">Course identifier.</param>
        public List <ResCourseToExam> LoadCourseExaminations(int courseId)
        {
            var sqlwhere = "Res_CourseToExam.CourseId=" + courseId;
            var list     = _dataAccess.GetList <ResCourseToExam>(sqlwhere);

            if (list.Count > 0)
            {
                var manager = new ExampaperManager();
                var exampaperRedundancys = manager.GetAllExampaperRedundancy(list.Select(p => p.ExampaperId));
                var sortmanager          = new ExampaperSortManager();
                var sortlist             = sortmanager.GetAllExampaperSortList(exampaperRedundancys.First().TenantId);
                foreach (var exam in list)
                {
                    var tmp = exampaperRedundancys.FirstOrDefault(p => p._id == exam.ExampaperId);
                    if (tmp == null)
                    {
                        list.Remove(exam);
                        continue;
                    }
                    exam.Exampaper             = tmp;
                    exam.ExampaperId           = tmp.ExampaperId;
                    exam.ExampaperRedundancyId = tmp._id;
                    exam.SortName = sortlist.Any(p => p._id == tmp.ExamSortID) ? sortlist.Find(p => p._id == tmp.ExamSortID).Title : "";
                }
            }
            return(list);
        }