Feature: Device Importing & Exporting
This commit is contained in:
@@ -465,5 +465,22 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Exporting
|
||||
public virtual ActionResult ExportDevices(int id)
|
||||
{
|
||||
DeviceBatch db = dbContext.DeviceBatches.Find(id);
|
||||
if (db == null)
|
||||
throw new ArgumentNullException("id", "Invalid Device Batch Id");
|
||||
|
||||
var devices = dbContext.Devices.Where(d => !d.DecommissionedDate.HasValue && d.DeviceBatchId == db.Id);
|
||||
|
||||
var export = BI.DeviceBI.Importing.Export.GenerateExport(devices);
|
||||
|
||||
var filename = string.Format("DiscoDeviceExport-Batch_{0}-{1:yyyyMMdd-HHmmss}.csv", db.Id, DateTime.Now);
|
||||
|
||||
return File(export, "text/csv", filename);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user