diff --git a/Disco.Services/Devices/Exporting/DeviceExport.cs b/Disco.Services/Devices/Exporting/DeviceExport.cs index a164e0d4..b435a5a3 100644 --- a/Disco.Services/Devices/Exporting/DeviceExport.cs +++ b/Disco.Services/Devices/Exporting/DeviceExport.cs @@ -120,7 +120,10 @@ namespace Disco.Services.Devices.Exporting case DeviceExportTypes.All: return GenerateExport(Database, Database.Devices, Options, TaskStatus); case DeviceExportTypes.Batch: - return GenerateExport(Database, Database.Devices.Where(d => d.DeviceBatchId == Options.ExportTypeTargetId), Options, TaskStatus); + if (Options.ExportTypeTargetId.HasValue && Options.ExportTypeTargetId.Value > 0) + return GenerateExport(Database, Database.Devices.Where(d => d.DeviceBatchId == Options.ExportTypeTargetId), Options, TaskStatus); + else + return GenerateExport(Database, Database.Devices.Where(d => d.DeviceBatchId == null), Options, TaskStatus); case DeviceExportTypes.Model: return GenerateExport(Database, Database.Devices.Where(d => d.DeviceModelId == Options.ExportTypeTargetId), Options, TaskStatus); case DeviceExportTypes.Profile: diff --git a/Disco.Web/Controllers/DeviceController.cs b/Disco.Web/Controllers/DeviceController.cs index 3bf01a56..93da3705 100644 --- a/Disco.Web/Controllers/DeviceController.cs +++ b/Disco.Web/Controllers/DeviceController.cs @@ -93,7 +93,7 @@ namespace Disco.Web.Controllers var m = new Models.Device.ExportModel() { Options = Database.DiscoConfiguration.Devices.LastExportOptions, - DeviceBatches = Database.DeviceBatches.OrderBy(db => db.Name).Select(db => new { Key = db.Id, Value = db.Name }).ToList().Select(i => new KeyValuePair(i.Key, i.Value)), + DeviceBatches = new KeyValuePair[] { new KeyValuePair(0, "") }.Concat(Database.DeviceBatches.OrderBy(db => db.Name).Select(db => new { Key = db.Id, Value = db.Name }).ToList().Select(i => new KeyValuePair(i.Key, i.Value))), DeviceModels = Database.DeviceModels.OrderBy(dm => dm.Description).Select(dm => new { Key = dm.Id, Value = dm.Description }).ToList().Select(i => new KeyValuePair(i.Key, i.Value)), DeviceProfiles = Database.DeviceProfiles.OrderBy(dp => dp.Name).Select(dp => new { Key = dp.Id, Value = dp.Name }).ToList().Select(i => new KeyValuePair(i.Key, i.Value)) };