Feature: Decommission Reasons

As requested in #1
This commit is contained in:
Gary Sharp
2013-09-05 18:23:59 +10:00
parent f3efa56750
commit 29a6057443
11 changed files with 406 additions and 57 deletions
@@ -58,12 +58,13 @@ namespace Disco.BI.Extensions
return true;
}
public static void OnDecommission(this Device d)
public static void OnDecommission(this Device d, Disco.Models.Repository.Device.DecommissionReasons Reason)
{
if (!d.CanDecommission())
throw new InvalidOperationException("Decommission of Device is Denied");
d.DecommissionedDate = DateTime.Now;
d.DecommissionReason = Reason;
// Disable AD Account
if (d.ComputerName != null)
@@ -87,6 +88,7 @@ namespace Disco.BI.Extensions
throw new InvalidOperationException("Recommission of Device is Denied");
d.DecommissionedDate = null;
d.DecommissionReason = null;
// Enable AD Account
if (d.ComputerName != null)
+30 -1
View File
@@ -178,10 +178,39 @@ namespace Disco.BI.Extensions
return null;
}
public static string ReasonMessage(this Disco.Models.Repository.Device.DecommissionReasons r)
{
switch (r)
{
case Device.DecommissionReasons.EndOfLife:
return "End of Life";
case Device.DecommissionReasons.Sold:
return "Sold";
case Device.DecommissionReasons.Stolen:
return "Stolen";
case Device.DecommissionReasons.Lost:
return "Lost";
case Device.DecommissionReasons.Damaged:
return "Damaged";
case Device.DecommissionReasons.Donated:
return "Donated";
default:
return "Unknown";
}
}
public static string ReasonMessage(this Disco.Models.Repository.Device.DecommissionReasons? r)
{
if (!r.HasValue)
return "Not Decommissioned";
return r.Value.ReasonMessage();
}
public static string Status(this Device Device)
{
if (Device.DecommissionedDate.HasValue)
return "Decommissioned";
return string.Format("Decommissioned ({0})", Device.DecommissionReason.ReasonMessage());
if (!Device.EnrolledDate.HasValue)
return "Not Enrolled";