// GET: Groups public ActionResult List() { GroupsService groupService = new GroupsService(); GroupListVM model = new GroupListVM(); TryUpdateModel(model); //model.Groups = groupService.GetAll(); model.Groups = new Dictionary <Group, IEnumerable <SelectListItem> >(); foreach (var group in groupService.GetAll()) { IEnumerable <SelectListItem> contacts = groupService.GetContactsByGroup(group); model.Groups.Add(group, contacts); } if (model.Search != null) { model.Groups = model.Groups.Where(g => g.Key.Name.Contains(model.Search)).ToDictionary(v => v.Key, v => v.Value); } switch (model.SortOrder) { case "name_desc": model.Groups = model.Groups.OrderByDescending(g => g.Key.Name).ToDictionary(v => v.Key, v => v.Value); break; case "name_asc": default: model.Groups = model.Groups.OrderBy(g => g.Key.Name).ToDictionary(v => v.Key, v => v.Value); break; } return(View(model)); }
public ActionResult GroupList() { List <GroupListVM> groupList = new List <GroupListVM>(); GroupListVM l_oGroup; using (MasterDbContext db = new MasterDbContext()) { foreach (var obj in db.groups) { l_oGroup = new GroupListVM(); l_oGroup.id = obj.id; l_oGroup.groupName = obj.groupName; groupList.Add(l_oGroup); } } return(View(groupList)); }
public GroupListVM GetAllGroups(GroupFilter filter, int pageIndex) { var cityTC = UserSettingsService.CityTC; var leftBeginDate = filter.BeginDate; var rightBeginDate = filter.EndDate; var courseTCs = new List <string>(); if (!filter.CourseTC.IsEmpty()) { courseTCs.Add(filter.CourseTC); } else { if (filter.SectionId.HasValue) { var mainSection = SectionService.GetSectionsTree() .FirstOrDefault(x => x.Section_ID == filter.SectionId.Value); var sectionIds = new List <int>(); if (mainSection != null && mainSection.SubSections.Any()) { sectionIds = mainSection.SubSections.Select(x => x.Section_ID).ToList(); } else { sectionIds.Add(filter.SectionId.Value); } courseTCs.AddRange(CourseService.GetCourseTCListForSections(sectionIds)); } } var groupQuery = GroupService.GetGroupsForCourse(courseTCs, cityTC, leftBeginDate, rightBeginDate, filter.DayShiftTC, filter.ComplexTC, filter.DaySequenceTC); switch (filter.StudyTypeId) { case GroupFilter.StudyType.Intramural: groupQuery = groupQuery.Where(x => !x.ForWebinarOnly); break; case GroupFilter.StudyType.Webinar: groupQuery = groupQuery.Where(x => x.WebinarExists); break; case GroupFilter.StudyType.OpenLearning: groupQuery = groupQuery.Where(x => x.MegaGroup_ID != null); break; case GroupFilter.StudyType.IntraExtra: groupQuery = groupQuery.Where(x => x.IsIntraExtramural); break; } if (!filter.EmployeeTC.IsEmpty()) { groupQuery = groupQuery.Where(x => x.Teacher_TC == filter.EmployeeTC); } groupQuery = groupQuery.NotSpecial(); var groups = groupQuery.ToPagedList(pageIndex); var result = new GroupListVM { Groups = groups, Filter = filter, }; if (!filter.CourseTC.IsEmpty()) { var course = CourseService.GetByPK(filter.CourseTC); filter.CourseName = course.GetOrDefault(x => x.Name); result.Course = course; } return(result); }