Example #1
0
        public Tuple <bool, string, List <SubStructureModel> > GetSubStructurebyPost(PostType postType, long levelId)
        {
            try
            {
                var aaa = _collegeRepository.Where(u => u.UniversityId == levelId).ToList();

                var sss = (from a in _collegeRepository.Where(u => u.UniversityId == levelId).Include(i => i.OrganizationStructureName).AsEnumerable()
                           select
                           new SubStructureModel
                {
                    Id = a.Id,
                    Name = a.OrganizationStructureName.Name,
                    StructureType = StructureType.College
                }).ToList();

                var listSubStructure = (postType == PostType.University
                    ? (from a in _universityRepository.Where(u => u.Id == levelId).AsEnumerable()
                       select
                       new SubStructureModel {
                    Id = a.Id, Name = a.Name, StructureType = StructureType.University
                })
                    : (postType == PostType.College
                        ? (from a in _collegeRepository.Where(u => u.UniversityId == levelId)
                           .Include(i => i.OrganizationStructureName).AsEnumerable()
                           select
                           new SubStructureModel
                {
                    Id = a.Id,
                    Name = a.OrganizationStructureName.Name,
                    StructureType = StructureType.College
                })
                        :(postType == PostType.EducationalGroup? (from a in
                                                                  _educationalGroupRepository.Where(u => u.College.UniversityId == levelId)
                                                                  .Include(i => i.OrganizationStructureName).AsEnumerable()
                                                                  select
                                                                  new SubStructureModel
                {
                    Id = a.Id,
                    Name = a.OrganizationStructureName.Name,
                    StructureType = StructureType.EducationalGroup
                })
                          : (from a in
                             _fieldofStudyRepository.Where(u => u.EducationalGroup.College.UniversityId == levelId)
                             .Include(i => i.OrganizationStructureName).AsEnumerable()
                             select
                             new SubStructureModel
                {
                    Id = a.Id,
                    Name = a.OrganizationStructureName.Name,
                    StructureType = StructureType.FieldofStudy
                })
                          ))).ToList();
                return(new Tuple <bool, string, List <SubStructureModel> >(true, "", listSubStructure));
            }
            catch (Exception exception)
            {
                return(new Tuple <bool, string, List <SubStructureModel> >(false, "خطا در لود اطلاعات", null));
            }
        }