Feature: Device Importing & Exporting

This commit is contained in:
Gary Sharp
2013-07-25 17:46:20 +10:00
parent a3aaed1d13
commit ad6b1b19b6
67 changed files with 3058 additions and 266 deletions
@@ -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
}
}