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
@@ -2,6 +2,7 @@
using Disco.Models.Repository;
using Disco.Services.Authorization;
using Disco.Services.Plugins;
using Disco.Services.Plugins.Features.RepairProvider;
using Disco.Services.Plugins.Features.WarrantyProvider;
using Disco.Services.Web;
using System;
@@ -18,6 +19,7 @@ namespace Disco.Web.Areas.API.Controllers
const string pDescription = "description";
const string pDefaultPurchaseDate = "defaultpurchasedate";
const string pDefaultWarrantyProvider = "defaultwarrantyprovider";
const string pDefaultRepairProvider = "defaultrepairprovider";
[DiscoAuthorize(Claims.Config.DeviceModel.Configure)]
public virtual ActionResult Update(int id, string key, string value = null, bool redirect = false)
@@ -44,6 +46,9 @@ namespace Disco.Web.Areas.API.Controllers
case pDefaultWarrantyProvider:
UpdateDefaultWarrantyProvider(deviceModel, value);
break;
case pDefaultRepairProvider:
UpdateDefaultRepairProvider(deviceModel, value);
break;
default:
throw new Exception("Invalid Update Key");
}
@@ -86,6 +91,12 @@ namespace Disco.Web.Areas.API.Controllers
return Update(id, pDefaultWarrantyProvider, DefaultWarrantyProvider, redirect);
}
[DiscoAuthorize(Claims.Config.DeviceModel.Configure)]
public virtual ActionResult UpdateDefaultRepairProvider(int id, string DefaultRepairProvider = null, bool redirect = false)
{
return Update(id, pDefaultRepairProvider, DefaultRepairProvider, redirect);
}
#endregion
#region Update Properties
@@ -131,6 +142,20 @@ namespace Disco.Web.Areas.API.Controllers
}
Database.SaveChanges();
}
private void UpdateDefaultRepairProvider(Disco.Models.Repository.DeviceModel deviceModel, string DefaultRepairProvider)
{
if (string.IsNullOrEmpty(DefaultRepairProvider))
{
deviceModel.DefaultRepairProvider = null;
}
else
{
// Validate
var RepairProvider = Plugins.GetPluginFeature(DefaultRepairProvider, typeof(RepairProviderFeature));
deviceModel.DefaultRepairProvider = RepairProvider.Id;
}
Database.SaveChanges();
}
#endregion
#region ModelImage