Ejemplo n.º 1
0
        public IEnumerable <SubscriptionForSubmitView> CreateSubscriptionsBySchoolId(string term, string schoolId)
        {
            //删除未征订的订单
            RemoveNotSubscription();
            _subscriptionRepo.Context.Commit();

            var id = schoolId.ConvertToGuid();
            //取未征订的申报
            var studentDeclarations = GetNotSubscriptionStudentDeclarationJiaoWu(term)
                                      .Where(t => t.School_Id == id);
            var teacherDeclarations = GetNotSubscriptionTeacherDeclarationJiaoWu(term)
                                      .Where(t => t.School_Id == id);

            //创建订单
            var subscriptions = SubscriptionService.CreateSubscriptionsBySchool(studentDeclarations, teacherDeclarations);

            //写入DB
            subscriptions.ToList().ForEach(t => _subscriptionRepo.Add(t));
            _subscriptionRepo.Context.Commit();
            //DTO
            var result = _adapter.Adapt <SubscriptionForSubmitView>(subscriptions.OrderBy(t => t.Textbook.Name));

            return(result);
        }