public QueryResult<DeviceInfo> GetDevices(DeviceQuery query) { IEnumerable<DeviceInfo> devices = _repo.GetDevices().OrderByDescending(i => i.DateLastModified); if (query.SupportsContentUploading.HasValue) { var val = query.SupportsContentUploading.Value; devices = devices.Where(i => GetCapabilities(i.Id).SupportsContentUploading == val); } if (query.SupportsSync.HasValue) { var val = query.SupportsSync.Value; devices = devices.Where(i => GetCapabilities(i.Id).SupportsSync == val); } if (query.SupportsUniqueIdentifier.HasValue) { var val = query.SupportsUniqueIdentifier.Value; devices = devices.Where(i => GetCapabilities(i.Id).SupportsUniqueIdentifier == val); } var array = devices.ToArray(); return new QueryResult<DeviceInfo> { Items = array, TotalRecordCount = array.Length }; }
public QueryResult<DeviceInfo> GetDevices(DeviceQuery query) { IEnumerable<DeviceInfo> devices = _repo.GetDevices().OrderByDescending(i => i.DateLastModified); if (query.SupportsContentUploading.HasValue) { var val = query.SupportsContentUploading.Value; devices = devices.Where(i => GetCapabilities(i.Id).SupportsContentUploading == val); } if (query.SupportsSync.HasValue) { var val = query.SupportsSync.Value; devices = devices.Where(i => GetCapabilities(i.Id).SupportsSync == val); } if (query.SupportsPersistentIdentifier.HasValue) { var val = query.SupportsPersistentIdentifier.Value; devices = devices.Where(i => { var caps = GetCapabilities(i.Id); var deviceVal = caps.SupportsPersistentIdentifier; return deviceVal == val; }); } if (!string.IsNullOrWhiteSpace(query.UserId)) { devices = devices.Where(i => CanAccessDevice(query.UserId, i.Id)); } var array = devices.ToArray(); return new QueryResult<DeviceInfo> { Items = array, TotalRecordCount = array.Length }; }