Ejemplo n.º 1
0
        public JsonResultGenerics <int> GetWxClassesQuantity(VM_Wx_ClassFilter f)
        {
            var queryClasses = (IQueryable <microclass>)MClassService.GetMicroclasses(m => !m.is_deleted);

            queryClasses = queryClasses.Where(f.CombineExpression());
            return(new JsonResultGenerics <int>
            {
                Result = true,
                Value = queryClasses.Count()
            });
        }
        public List <VM_Wx_ClassInfo> GetWxClassOfSubject(VM_Wx_SubjectFilter f)
        {
            var ret = new List <VM_Wx_ClassInfo>();
            var ent = MSubjectService.GetSubject(f.subjectId);

            if (ent == null)
            {
                return(ret);
            }

            List <int> selectDiseaseIds = null;

            if (ent.subject_diseases != null && ent.subject_diseases.Count > 0)
            {
                selectDiseaseIds = ent.subject_diseases.Select(m => m.disease_id).ToList();
            }
            var selectedDoctorIds = MDoctorService.GetDoctors(GetDoctorIdExpBuilder(ent)).Select(doc => doc.id)
                                    .ToList();
            var expClass = PredicateBuilder.Create <microclass>(m => !m.is_deleted);
            var isAddConditionalFilter = false;

            if (selectDiseaseIds != null && selectDiseaseIds.Count > 0)
            {
                isAddConditionalFilter = true;
                expClass = expClass.And(s => selectDiseaseIds.Contains(s.DiseaseCategoryID));
            }
            if (selectedDoctorIds.Count > 0)
            {
                isAddConditionalFilter = true;
                expClass = expClass.And(s =>
                                        s.microclass_livedoctor
                                        .Select(d => d.doctor_id)
                                        .Intersect(selectedDoctorIds).Any());
            }
            if (!isAddConditionalFilter)
            {
                expClass = PredicateBuilder.False <microclass>();
            }
            ret.AddRange(
                MClassService.GetMicroclasses(expClass)
                .OrderByDescending(c => c.start_time)
                .Select(m => new VM_Wx_ClassInfo(m,
                                                 id => MDoctorService.GetDoctor(id),
                                                 hid => MHospitalService.GetHospitalProfileByID(hid),
                                                 cid => MClassService.GetOnlineUserCountByType(cid, 0))
                        ));
            return(ret);
        }
Ejemplo n.º 3
0
        public async Task <List <VM_Wx_ClassInfo> > GetUserFavoriteClasses(long userId)
        {
            var userClassIds = await MUserService.GetMemberFavoriteMicrocalssIds(userId);

            if (userClassIds == null || userClassIds.Count == 0)
            {
                return(new List <VM_Wx_ClassInfo>());
            }
            return(MClassService.GetMicroclasses(m => userClassIds.Contains(m.id) && !m.is_deleted).Select(m =>
            {
                var vo = new VM_Wx_ClassInfo(m,
                                             id => MDoctorService.GetDoctor(id),
                                             hid => MHospitalService.GetHospitalProfileByID(hid),
                                             cid => MClassService.GetOnlineUserCountByType(cid, 0));
                return vo;
            }).ToList());
        }
Ejemplo n.º 4
0
        public List <VM_Wx_ClassInfo> GetWxClasses(VM_Wx_ClassFilter f)
        {
            if (f.CourseId > 0 && f.IsAddViewCount)
            {
                var addViewCountClass = MClassService.GetMicroclass(f.CourseId);
                addViewCountClass.view_count++;
                MClassService.UpdateMicroclass(addViewCountClass, false);
            }

            var queryClasses = (IQueryable <microclass>)MClassService.GetMicroclasses(m => !m.is_deleted);

            queryClasses = queryClasses.Where(f.CombineExpression());
            return(f.GetPageAndSortItiteral(queryClasses).Select(m =>
            {
                return new VM_Wx_ClassInfo(m,
                                           id => MDoctorService.GetDoctor(id),
                                           hid => MHospitalService.GetHospitalProfileByID(hid),
                                           cid => MClassService.GetOnlineUserCountByType(cid, 0));
            }).ToList());
        }