Feature #2: Implement Repair Provider

Logging Repair for Non-Warranty jobs has been brought into line with
Logging Warranty. RepairProviderFeature implemented which allows plugins
to be used in submitting jobs to third-parties for repair.
This commit is contained in:
Gary Sharp
2014-07-10 17:45:13 +10:00
parent 5ba9fde10f
commit f4394fe2a0
47 changed files with 4471 additions and 1163 deletions
+8
View File
@@ -133,6 +133,7 @@ namespace Disco.Services.Authorization
{ "Job.Properties.NonWarrantyProperties.PurchaseOrderRaised", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.NonWarrantyProperties.PurchaseOrderRaised, (c, v) => c.Job.Properties.NonWarrantyProperties.PurchaseOrderRaised = v, "Purchase Order Raised Property", "Can update property", false) },
{ "Job.Properties.NonWarrantyProperties.PurchaseOrderReference", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.NonWarrantyProperties.PurchaseOrderReference, (c, v) => c.Job.Properties.NonWarrantyProperties.PurchaseOrderReference = v, "Purchase Order Reference Property", "Can update property", false) },
{ "Job.Properties.NonWarrantyProperties.PurchaseOrderSent", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.NonWarrantyProperties.PurchaseOrderSent, (c, v) => c.Job.Properties.NonWarrantyProperties.PurchaseOrderSent = v, "Purchase Order Sent Property", "Can update property", false) },
{ "Job.Properties.NonWarrantyProperties.RepairProviderDetails", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.NonWarrantyProperties.RepairProviderDetails, (c, v) => c.Job.Properties.NonWarrantyProperties.RepairProviderDetails = v, "Repair Provider Details", "Can access repair provider details", false) },
{ "Job.Properties.NonWarrantyProperties.RepairerCompletedDate", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.NonWarrantyProperties.RepairerCompletedDate, (c, v) => c.Job.Properties.NonWarrantyProperties.RepairerCompletedDate = v, "Repairer Completed Date Property", "Can update property", false) },
{ "Job.Properties.NonWarrantyProperties.RepairerLoggedDate", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.NonWarrantyProperties.RepairerLoggedDate, (c, v) => c.Job.Properties.NonWarrantyProperties.RepairerLoggedDate = v, "Repairer Logged Date Property", "Can update property", false) },
{ "Job.Properties.NonWarrantyProperties.RepairerName", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.NonWarrantyProperties.RepairerName, (c, v) => c.Job.Properties.NonWarrantyProperties.RepairerName = v, "Repairer Name Property", "Can update property", false) },
@@ -352,6 +353,7 @@ namespace Disco.Services.Authorization
new ClaimNavigatorItem("Job.Properties.NonWarrantyProperties.PurchaseOrderRaised", false),
new ClaimNavigatorItem("Job.Properties.NonWarrantyProperties.PurchaseOrderReference", false),
new ClaimNavigatorItem("Job.Properties.NonWarrantyProperties.PurchaseOrderSent", false),
new ClaimNavigatorItem("Job.Properties.NonWarrantyProperties.RepairProviderDetails", false),
new ClaimNavigatorItem("Job.Properties.NonWarrantyProperties.RepairerCompletedDate", false),
new ClaimNavigatorItem("Job.Properties.NonWarrantyProperties.RepairerLoggedDate", false),
new ClaimNavigatorItem("Job.Properties.NonWarrantyProperties.RepairerName", false),
@@ -645,6 +647,7 @@ namespace Disco.Services.Authorization
c.Job.Properties.NonWarrantyProperties.PurchaseOrderRaised = true;
c.Job.Properties.NonWarrantyProperties.PurchaseOrderReference = true;
c.Job.Properties.NonWarrantyProperties.PurchaseOrderSent = true;
c.Job.Properties.NonWarrantyProperties.RepairProviderDetails = true;
c.Job.Properties.NonWarrantyProperties.RepairerCompletedDate = true;
c.Job.Properties.NonWarrantyProperties.RepairerLoggedDate = true;
c.Job.Properties.NonWarrantyProperties.RepairerName = true;
@@ -1424,6 +1427,11 @@ namespace Disco.Services.Authorization
/// </summary>
public const string PurchaseOrderSent = "Job.Properties.NonWarrantyProperties.PurchaseOrderSent";
/// <summary>Repair Provider Details
/// <para>Can access repair provider details</para>
/// </summary>
public const string RepairProviderDetails = "Job.Properties.NonWarrantyProperties.RepairProviderDetails";
/// <summary>Repairer Completed Date Property
/// <para>Can update property</para>
/// </summary>
@@ -44,6 +44,9 @@ namespace Disco.Services.Authorization.Roles.ClaimGroups.Job
[ClaimDetails("Repairer Reference Property", "Can update property")]
public bool RepairerReference { get; set; }
[ClaimDetails("Repair Provider Details", "Can access repair provider details")]
public bool RepairProviderDetails { get; set; }
[ClaimDetails("Insurance Detail Properties", "Can update insurance detail properties")]
public bool InsuranceDetails { get; set; }
}
@@ -157,12 +157,15 @@ namespace Disco.Services.Authorization.Roles
/// </summary>
private static void MigrateAuthorizationRoles(DiscoDataContext Database)
{
// Use 'MyJobs' (A new claim) to detect if the Role hasn't been migrated yet
var affectedRoles = Database.AuthorizationRoles.Where(r => !r.ClaimsJson.Contains("MyJobs")).ToList();
// Determine roles which need migration from DBv11 -> DBv14
var affectedRoles_DBv14 = Database.AuthorizationRoles.Where(r => !r.ClaimsJson.Contains("MyJobs")).ToList();
// Determine roles which need migration from DBv14 -> DBv15
var affectedRoles_DBv15 = Database.AuthorizationRoles.Where(r => !r.ClaimsJson.Contains("RepairProviderDetails")).ToList();
if (affectedRoles.Count > 0)
if (affectedRoles_DBv14.Count > 0)
{
foreach (var role in affectedRoles)
foreach (var role in affectedRoles_DBv14)
{
var claims = JsonConvert.DeserializeObject<RoleClaims>(role.ClaimsJson);
@@ -204,6 +207,24 @@ namespace Disco.Services.Authorization.Roles
Database.SaveChanges();
}
if (affectedRoles_DBv15.Count > 0)
{
foreach (var role in affectedRoles_DBv15)
{
var claims = JsonConvert.DeserializeObject<RoleClaims>(role.ClaimsJson);
// If the user previously had the ability to view warranty provider details, they probably should be able to view repair provider details (new feature).
if (claims.Job.Properties.WarrantyProperties.ProviderDetails)
{
claims.Job.Properties.NonWarrantyProperties.RepairProviderDetails = true;
}
role.ClaimsJson = Newtonsoft.Json.JsonConvert.SerializeObject(claims);
}
Database.SaveChanges();
}
}
}
}