private static string GetIncludeProperties(GroupRelatedData includes) { string includeProperties = ""; switch (includes) { case GroupRelatedData.None: break; case GroupRelatedData.Owner: includeProperties = @"User"; break; case GroupRelatedData.Users: includeProperties = @"UsersToGroups.User"; break; case GroupRelatedData.UsersAndGroupInvite: includeProperties = @"UsersToGroups.User,GroupInvites"; break; case GroupRelatedData.Events: includeProperties = @"Events"; break; case GroupRelatedData.ALL: includeProperties = @"Events.UsersToEvents,UsersToGroups,GroupInvites"; break; default: break; } return(includeProperties); }
public static Group GetGroupByID(int id, GroupRelatedData relatedData = GroupRelatedData.None) { using (IUnitOfWork unitOfWork = new cmiUnitOfWork()) { Repository <Group> repository = new Repository <Group>(unitOfWork); Group singleGroup = repository.Get(g => g.ID == id, GetIncludeProperties(relatedData)).SingleOrDefault(); return(singleGroup); } }
public static GroupEventItems GetGroupEventItemsByID(int id, int pageNumber, int pageSize = int.MaxValue, GroupRelatedData relatedData = GroupRelatedData.None) { using (IUnitOfWork unitOfWork = new cmiUnitOfWork()) { GroupEventItems groupEvents = new GroupEventItems(); Repository <Group> repositoryGroup = new Repository <Group>(unitOfWork); groupEvents.Group = repositoryGroup.Get(g => g.ID == id, GetIncludeProperties(relatedData)).SingleOrDefault(); Repository <Event> repositoryEvent = new Repository <Event>(unitOfWork); groupEvents.Events = repositoryEvent.Get(e => e.GroupID == id, "UsersToEvents").OrderBy(e => e.StartTime).ToPagedList(pageNumber, pageSize); return(groupEvents); } }