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
@@ -20,18 +20,25 @@ namespace Disco.Web.Areas.Config.Controllers
if (id.HasValue)
{
var m = new Models.DeviceBatch.ShowModel()
{
DeviceBatch = dbContext.DeviceBatches.Find(id)
};
if (m.DeviceBatch == null)
{
return RedirectToAction(MVC.Config.DeviceBatch.Index(null));
}
m.CanDelete = m.DeviceBatch.CanDelete(dbContext);
var m = dbContext.DeviceBatches.Where(db => db.Id == id.Value)
.Select(db => new Models.DeviceBatch.ShowModel()
{
DeviceBatch = db,
DeviceCount = db.Devices.Count(),
DeviceDecommissionedCount = db.Devices.Count(d => d.DecommissionedDate.HasValue)
}).FirstOrDefault();
m.DeviceCount = m.DeviceBatch.Devices.Count();
m.DeviceDecommissionedCount = m.DeviceBatch.Devices.Count(d => d.DecommissionedDate.HasValue);
if (m == null || m.DeviceBatch == null)
throw new ArgumentException("Invalid Device Batch Id", "id");
m.DeviceModelMembers = m.DeviceBatch.Devices.GroupBy(d => d.DeviceModel).Select(dG => new Models.DeviceBatch._ShowModelMembership()
{
DeviceModel = dG.Key,
DeviceCount = dG.Count(),
DeviceDecommissionedCount = dG.Count(d => d.DecommissionedDate.HasValue)
}).ToArray().Cast<ConfigDeviceBatchShowModelMembership>().ToList();
m.CanDelete = m.DeviceBatch.CanDelete(dbContext);
m.DeviceModels = dbContext.DeviceModels.ToList();
@@ -46,7 +53,7 @@ namespace Disco.Web.Areas.Config.Controllers
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceBatchIndexModel>(this.ControllerContext, m);
return View(m);
}
}
@@ -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()
};
@@ -20,14 +20,18 @@ namespace Disco.Web.Areas.Config.Controllers
{
if (id.HasValue)
{
var m = new Models.DeviceProfile.ShowModel()
var m = dbContext.DeviceProfiles.Where(dp => dp.Id == id.Value).Select(dp => new Models.DeviceProfile.ShowModel()
{
DeviceProfile = dbContext.DeviceProfiles.Find(id.Value),
OrganisationAddresses = dbContext.DiscoConfiguration.OrganisationAddresses.Addresses,
CertificateProviders = Plugins.GetPluginFeatures(typeof(CertificateProviderFeature))
};
DeviceProfile = dp,
DeviceCount = dp.Devices.Count(),
DeviceDecommissionedCount = dp.Devices.Where(d => d.DecommissionedDate.HasValue).Count()
}).FirstOrDefault();
//m.Devices = BI.DeviceBI.SelectDeviceSearchResultItem(dbContext.Devices.Where(d => d.DeviceProfileId == m.DeviceProfile.Id));
if (m == null || m.DeviceProfile == null)
throw new ArgumentException("Invalid Device Profile Id", "id");
m.OrganisationAddresses = dbContext.DiscoConfiguration.OrganisationAddresses.Addresses;
m.CertificateProviders = Plugins.GetPluginFeatures(typeof(CertificateProviderFeature));
var DistributionValues = Enum.GetValues(typeof(Disco.Models.Repository.DeviceProfile.DistributionTypes));
m.DeviceProfileDistributionTypes = new List<SelectListItem>();