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