Update: Device Count Details

More information about device membership in Batches, Profiles and
Models.
This commit is contained in:
Gary Sharp
2013-07-25 17:47:40 +10:00
parent ad6b1b19b6
commit 19503366c4
27 changed files with 883 additions and 482 deletions
@@ -17,16 +17,22 @@ namespace Disco.Web.Areas.Config.Controllers
{
if (id.HasValue)
{
var m = new Models.DeviceModel.ShowModel()
var m = dbContext.DeviceModels.Include("DeviceComponents").Where(dm => dm.Id == id.Value).Select(dm => new Models.DeviceModel.ShowModel()
{
DeviceModel = dbContext.DeviceModels.Include("DeviceComponents.JobSubTypes").Where(dm => dm.Id == id.Value).FirstOrDefault(),
WarrantyProviders = Plugins.GetPluginFeatures(typeof(WarrantyProviderFeature))
};
DeviceModel = dm,
DeviceCount = dm.Devices.Count(),
DeviceDecommissionedCount = dm.Devices.Where(d => d.DecommissionedDate.HasValue).Count()
}).FirstOrDefault();
if (m == null || m.DeviceModel == null)
throw new ArgumentException("Invalid Device Model Id", "id");
m.WarrantyProviders = Plugins.GetPluginFeatures(typeof(WarrantyProviderFeature));
m.DeviceComponentsModel = new Models.DeviceModel.ComponentsModel()
{
DeviceModelId = m.DeviceModel.Id,
DeviceComponents = m.DeviceModel.DeviceComponents.ToList(),
DeviceComponents = dbContext.DeviceComponents.Include("JobSubTypes").Where(dc => dc.DeviceModelId == m.DeviceModel.Id).ToList(),
JobSubTypes = dbContext.JobSubTypes.Where(jst => jst.JobTypeId == Disco.Models.Repository.JobType.JobTypeIds.HNWar).ToList()
};