Permissions & Authorization for Users #24

Initial Release; Includes Database and MVC refactoring
This commit is contained in:
Gary Sharp
2013-10-10 19:13:16 +11:00
parent 172ce5524a
commit a099d68915
458 changed files with 40221 additions and 12130 deletions
+119 -98
View File
@@ -1,23 +1,21 @@
using System;
using Disco.BI.Extensions;
using Disco.BI.JobBI;
using Disco.Models.Repository;
using Disco.Models.UI.Job;
using Disco.Services.Authorization;
using Disco.Services.Plugins.Features.UIExtension;
using Disco.Services.Plugins.Features.WarrantyProvider;
using Disco.Services.Users;
using Disco.Services.Web;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Disco.Data.Repository;
using Disco.BI;
using Disco.BI.Extensions;
using Disco.Models.Repository;
using System.Web.Script.Serialization;
using Disco.Services.Plugins.Features.WarrantyProvider;
using Disco.Services.Plugins;
using Disco.Models.UI.Job;
using Disco.Services.Plugins.Features.UIExtension;
using Disco.BI.JobBI;
using Newtonsoft.Json;
namespace Disco.Web.Controllers
{
public partial class JobController : dbAdminController
public partial class JobController : AuthorizedDatabaseController
{
#region Index
@@ -47,7 +45,7 @@ namespace Disco.Web.Controllers
&& (j.DeviceHeld == null || j.DeviceReturnedDate != null || j.DeviceReadyForReturn == null)),
SortFunction = q => q.OrderBy(j => j.Id),
ShowStatus = true
}.Initialize(dbContext);
}.Initialize(Database);
}
}
}
@@ -65,14 +63,17 @@ namespace Disco.Web.Controllers
FilterFunction = q => q.Where(j => j.ClosedDate == null && j.OpenedDate < longRunningThreshold),
SortFunction = q => q.OrderBy(j => j.Id),
ShowStatus = true
}.Initialize(dbContext);
}.Initialize(Database);
}
}
}
m.OpenJobs = jobList_OpenJobs;
m.LongRunningJobs = jobList_LongRunning;
m.DailyOpenedClosedStatistics = Disco.BI.JobBI.Statistics.DailyOpenedClosed.Data(dbContext, true);
if (Authorization.Has(Claims.Job.Lists.AwaitingTechnicianAction))
m.OpenJobs = jobList_OpenJobs;
if (Authorization.Has(Claims.Job.Lists.LongRunningJobs))
m.LongRunningJobs = jobList_LongRunning;
if (Authorization.Has(Claims.Job.ShowDailyChart))
m.DailyOpenedClosedStatistics = Disco.BI.JobBI.Statistics.DailyOpenedClosed.Data(Database, true);
// UI Extensions
UIExtensions.ExecuteExtensions<JobIndexModel>(this.ControllerContext, m);
@@ -82,24 +83,27 @@ namespace Disco.Web.Controllers
#endregion
#region Lists
[DiscoAuthorize(Claims.Job.Lists.AllOpen)]
public virtual ActionResult AllOpen()
{
dbContext.Configuration.LazyLoadingEnabled = true;
Database.Configuration.LazyLoadingEnabled = true;
var m = new Models.Job.ListModel() { Title = "All Open Jobs" };
m.JobTable = new Disco.Models.BI.Job.JobTableModel() { ShowStatus = true };
m.JobTable.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.ClosedDate == null).OrderBy(j => j.Id));
m.JobTable.Fill(Database, BI.JobBI.Searching.BuildJobTableModel(Database).Where(j => j.ClosedDate == null).OrderBy(j => j.Id));
// UI Extensions
UIExtensions.ExecuteExtensions<JobListModel>(this.ControllerContext, m);
return View(Views.List, m);
}
[DiscoAuthorize(Claims.Job.Lists.DevicesReadyForReturn)]
public virtual ActionResult DevicesReadyForReturn()
{
dbContext.Configuration.LazyLoadingEnabled = true;
Database.Configuration.LazyLoadingEnabled = true;
var m = new Models.Job.ListModel() { Title = "Jobs with Devices Ready for Return" };
m.JobTable = new Disco.Models.BI.Job.JobTableModel() { ShowStatus = true };
m.JobTable.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => !j.WaitingForUserAction.HasValue
m.JobTable.Fill(Database, BI.JobBI.Searching.BuildJobTableModel(Database).Where(j => !j.WaitingForUserAction.HasValue
&& j.DeviceHeld != null && j.DeviceReturnedDate == null && j.DeviceReadyForReturn != null &&
((!j.JobMetaNonWarranty.AccountingChargeRequiredDate.HasValue && !j.JobMetaNonWarranty.AccountingChargeAddedDate.HasValue) || j.JobMetaNonWarranty.AccountingChargePaidDate.HasValue)
&& j.ClosedDate == null).OrderBy(j => j.Id));
@@ -109,12 +113,14 @@ namespace Disco.Web.Controllers
return View(Views.List, m);
}
[DiscoAuthorize(Claims.Job.Lists.DevicesAwaitingRepair)]
public virtual ActionResult DevicesAwaitingRepair()
{
dbContext.Configuration.LazyLoadingEnabled = true;
Database.Configuration.LazyLoadingEnabled = true;
var m = new Models.Job.ListModel() { Title = "Jobs with Devices Awaiting Repair" };
m.JobTable = new Disco.Models.BI.Job.JobTableModel() { ShowStatus = true };
m.JobTable.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.ClosedDate == null &&
m.JobTable.Fill(Database, BI.JobBI.Searching.BuildJobTableModel(Database).Where(j => j.ClosedDate == null &&
(
(j.JobMetaNonWarranty.RepairerLoggedDate != null && j.JobMetaNonWarranty.RepairerCompletedDate == null) ||
(j.JobMetaWarranty.ExternalLoggedDate != null && j.JobMetaWarranty.ExternalCompletedDate == null)
@@ -127,12 +133,13 @@ namespace Disco.Web.Controllers
}
#region "Finance Lists"
[DiscoAuthorize(Claims.Job.Lists.AwaitingFinance)]
public virtual ActionResult AwaitingFinance()
{
dbContext.Configuration.LazyLoadingEnabled = true;
Database.Configuration.LazyLoadingEnabled = true;
var m = new Models.Job.ListModel() { Title = "Jobs Awaiting Finance" };
m.JobTable = new Disco.Models.BI.Job.JobTableModel() { ShowStatus = true };
m.JobTable.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.ClosedDate == null &&
m.JobTable.Fill(Database, BI.JobBI.Searching.BuildJobTableModel(Database).Where(j => j.ClosedDate == null &&
(
(j.JobTypeId == JobType.JobTypeIds.HNWar && (j.JobMetaNonWarranty.IsInsuranceClaim && !j.JobMetaInsurance.ClaimFormSentDate.HasValue)) ||
(j.JobTypeId == JobType.JobTypeIds.HNWar && (j.JobMetaNonWarranty.AccountingChargeRequiredDate.HasValue && (!j.JobMetaNonWarranty.AccountingChargeAddedDate.HasValue && !j.JobMetaNonWarranty.AccountingChargePaidDate.HasValue))) ||
@@ -146,12 +153,13 @@ namespace Disco.Web.Controllers
return View(Views.List, m);
}
[DiscoAuthorizeAll(Claims.Job.Lists.AwaitingFinance, Claims.Job.Lists.AwaitingFinanceCharge)]
public virtual ActionResult AwaitingFinanceCharge()
{
dbContext.Configuration.LazyLoadingEnabled = true;
Database.Configuration.LazyLoadingEnabled = true;
var m = new Models.Job.ListModel() { Title = "Jobs Awaiting Finance - Accounting Charge" };
m.JobTable = new Disco.Models.BI.Job.JobTableModel() { ShowStatus = true };
m.JobTable.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.ClosedDate == null &&
m.JobTable.Fill(Database, BI.JobBI.Searching.BuildJobTableModel(Database).Where(j => j.ClosedDate == null &&
(j.JobTypeId == JobType.JobTypeIds.HNWar && (j.JobMetaNonWarranty.AccountingChargeRequiredDate.HasValue && (!j.JobMetaNonWarranty.AccountingChargeAddedDate.HasValue && !j.JobMetaNonWarranty.AccountingChargePaidDate.HasValue)))
).OrderBy(j => j.Id));
@@ -160,12 +168,14 @@ namespace Disco.Web.Controllers
return View(Views.List, m);
}
[DiscoAuthorizeAll(Claims.Job.Lists.AwaitingFinance, Claims.Job.Lists.AwaitingFinancePayment)]
public virtual ActionResult AwaitingFinancePayment()
{
dbContext.Configuration.LazyLoadingEnabled = true;
Database.Configuration.LazyLoadingEnabled = true;
var m = new Models.Job.ListModel() { Title = "Jobs Awaiting Finance - Accounting Payment" };
m.JobTable = new Disco.Models.BI.Job.JobTableModel() { ShowStatus = true };
m.JobTable.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.ClosedDate == null &&
m.JobTable.Fill(Database, BI.JobBI.Searching.BuildJobTableModel(Database).Where(j => j.ClosedDate == null &&
(j.JobTypeId == JobType.JobTypeIds.HNWar && (!j.JobMetaNonWarranty.AccountingChargeAddedDate.HasValue || !j.JobMetaNonWarranty.AccountingChargePaidDate.HasValue))
).OrderBy(j => j.Id));
@@ -174,12 +184,14 @@ namespace Disco.Web.Controllers
return View(Views.List, m);
}
[DiscoAuthorizeAll(Claims.Job.Lists.AwaitingFinance, Claims.Job.Lists.AwaitingFinanceInsuranceProcessing)]
public virtual ActionResult AwaitingFinanceInsuranceProcessing()
{
dbContext.Configuration.LazyLoadingEnabled = true;
Database.Configuration.LazyLoadingEnabled = true;
var m = new Models.Job.ListModel() { Title = "Jobs Awaiting Finance - Insurance Processing" };
m.JobTable = new Disco.Models.BI.Job.JobTableModel() { ShowStatus = true };
m.JobTable.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.ClosedDate == null &&
m.JobTable.Fill(Database, BI.JobBI.Searching.BuildJobTableModel(Database).Where(j => j.ClosedDate == null &&
(j.JobTypeId == JobType.JobTypeIds.HNWar && (j.JobMetaNonWarranty.IsInsuranceClaim && !j.JobMetaInsurance.ClaimFormSentDate.HasValue))
).OrderBy(j => j.Id));
@@ -188,12 +200,14 @@ namespace Disco.Web.Controllers
return View(Views.List, m);
}
[DiscoAuthorizeAll(Claims.Job.Lists.AwaitingFinance, Claims.Job.Lists.AwaitingFinanceAgreementBreach)]
public virtual ActionResult AwaitingFinanceAgreementBreach()
{
dbContext.Configuration.LazyLoadingEnabled = true;
Database.Configuration.LazyLoadingEnabled = true;
var m = new Models.Job.ListModel() { Title = "Jobs Awaiting Finance - Agreement Breach" };
m.JobTable = new Disco.Models.BI.Job.JobTableModel() { ShowStatus = true };
m.JobTable.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.ClosedDate == null &&
m.JobTable.Fill(Database, BI.JobBI.Searching.BuildJobTableModel(Database).Where(j => j.ClosedDate == null &&
(j.JobTypeId == JobType.JobTypeIds.UMgmt && Job.UserManagementFlags.Infringement_BreachFinancialAgreement == (j.Flags & Job.UserManagementFlags.Infringement_BreachFinancialAgreement))
).OrderBy(j => j.Id));
@@ -202,15 +216,15 @@ namespace Disco.Web.Controllers
return View(Views.List, m);
}
#endregion
[DiscoAuthorize(Claims.Job.Lists.AwaitingUserAction)]
public virtual ActionResult AwaitingUserAction()
{
dbContext.Configuration.LazyLoadingEnabled = true;
Database.Configuration.LazyLoadingEnabled = true;
var m = new Models.Job.ListModel() { Title = "Jobs Awaiting User Action" };
m.JobTable = new Disco.Models.BI.Job.JobTableModel() { ShowStatus = true };
m.JobTable.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => (j.WaitingForUserAction.HasValue || (j.JobMetaNonWarranty.AccountingChargeAddedDate != null && j.JobMetaNonWarranty.AccountingChargePaidDate == null))
m.JobTable.Fill(Database, BI.JobBI.Searching.BuildJobTableModel(Database).Where(j => (j.WaitingForUserAction.HasValue || (j.JobMetaNonWarranty.AccountingChargeAddedDate != null && j.JobMetaNonWarranty.AccountingChargePaidDate == null))
&& j.ClosedDate == null).OrderBy(j => j.Id));
// UI Extensions
@@ -218,9 +232,11 @@ namespace Disco.Web.Controllers
return View(Views.List, m);
}
[DiscoAuthorize(Claims.Job.Lists.RecentlyClosed)]
public virtual ActionResult RecentlyClosed()
{
dbContext.Configuration.LazyLoadingEnabled = true;
Database.Configuration.LazyLoadingEnabled = true;
var m = new Models.Job.ListModel() { Title = "Recently Closed Jobs" };
m.JobTable = new Disco.Models.BI.Job.JobTableModel() { ShowStatus = true };
@@ -230,19 +246,21 @@ namespace Disco.Web.Controllers
closedThreshold = closedThreshold.AddDays(-2);
if (dateTimeNow.DayOfWeek == DayOfWeek.Tuesday)
closedThreshold = closedThreshold.AddDays(-1);
m.JobTable.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.ClosedDate > closedThreshold).OrderBy(j => j.Id));
m.JobTable.Fill(Database, BI.JobBI.Searching.BuildJobTableModel(Database).Where(j => j.ClosedDate > closedThreshold).OrderBy(j => j.Id));
// UI Extensions
UIExtensions.ExecuteExtensions<JobListModel>(this.ControllerContext, m);
return View(Views.List, m);
}
[DiscoAuthorize(Claims.Job.Lists.Locations)]
public virtual ActionResult Locations()
{
dbContext.Configuration.LazyLoadingEnabled = true;
Database.Configuration.LazyLoadingEnabled = true;
var m = new Models.Job.ListModel() { Title = "Held Device Locations" };
m.JobTable = new Disco.Models.BI.Job.JobTableModel() { ShowStatus = true, ShowLocation = true, ShowTechnician = false, ShowType = false };
m.JobTable.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.ClosedDate == null && j.DeviceHeld.HasValue && !j.DeviceReturnedDate.HasValue).OrderBy(j => j.DeviceHeldLocation));
m.JobTable.Fill(Database, BI.JobBI.Searching.BuildJobTableModel(Database).Where(j => j.ClosedDate == null && j.DeviceHeld.HasValue && !j.DeviceReturnedDate.HasValue).OrderBy(j => j.DeviceHeldLocation));
// UI Extensions
UIExtensions.ExecuteExtensions<JobListModel>(this.ControllerContext, m);
@@ -253,23 +271,57 @@ namespace Disco.Web.Controllers
#endregion
#region Show
[DiscoAuthorize(Claims.Job.Show)]
public virtual ActionResult Show(int? id)
{
if (!id.HasValue)
return RedirectToAction(MVC.Job.Index());
dbContext.Configuration.LazyLoadingEnabled = true;
Database.Configuration.LazyLoadingEnabled = true;
var m = new Models.Job.ShowModel();
m.Job = (from j in dbContext.Jobs.Include("Device.DeviceModel").Include("Device.DeviceBatch").Include("DeviceHeldTechUser").Include("DeviceReadyForReturnTechUser").Include("DeviceReturnedTechUser")
m.Job = (from j in Database.Jobs.Include("Device.DeviceModel").Include("Device.DeviceBatch").Include("DeviceHeldTechUser").Include("DeviceReadyForReturnTechUser").Include("DeviceReturnedTechUser")
.Include("OpenedTechUser").Include("ClosedTechUser").Include("JobType").Include("JobSubTypes").Include("User").Include("JobLogs.TechUser")
where (j.Id == id.Value)
select j).FirstOrDefault();
m.UpdatableJobSubTypes = m.Job.JobType.JobSubTypes.OrderBy(jst => jst.Description).ToList();
if (m.Job == null)
throw new ArgumentException(string.Format("Unknown Job: [{0}]", id), "id");
m.AvailableDocumentTemplates = m.Job.AvailableDocumentTemplates(dbContext, DiscoApplication.CurrentUser, DateTime.Now);
// Validate Authorization
switch (m.Job.JobTypeId)
{
case JobType.JobTypeIds.HMisc:
Authorization.Require(Claims.Job.Types.ShowHMisc);
break;
case JobType.JobTypeIds.HNWar:
Authorization.Require(Claims.Job.Types.ShowHNWar);
break;
case JobType.JobTypeIds.HWar:
Authorization.Require(Claims.Job.Types.ShowHWar);
break;
case JobType.JobTypeIds.SApp:
Authorization.Require(Claims.Job.Types.ShowSApp);
break;
case JobType.JobTypeIds.SImg:
Authorization.Require(Claims.Job.Types.ShowSImg);
break;
case JobType.JobTypeIds.SOS:
Authorization.Require(Claims.Job.Types.ShowSOS);
break;
case JobType.JobTypeIds.UMgmt:
Authorization.Require(Claims.Job.Types.ShowUMgmt);
break;
default:
throw new InvalidOperationException("Unknown JobType");
}
if (Authorization.Has(Claims.Job.Actions.UpdateSubTypes))
m.UpdatableJobSubTypes = m.Job.JobType.JobSubTypes.OrderBy(jst => jst.Description).ToList();
if (Authorization.Has(Claims.Job.Actions.GenerateDocuments))
m.AvailableDocumentTemplates = m.Job.AvailableDocumentTemplates(Database, UserService.CurrentUser, DateTime.Now);
// UI Extensions
UIExtensions.ExecuteExtensions<JobShowModel>(this.ControllerContext, m);
@@ -279,6 +331,7 @@ namespace Disco.Web.Controllers
#endregion
#region Create
[DiscoAuthorize(Claims.Job.Actions.Create)]
public virtual ActionResult Create(string DeviceSerialNumber, string UserId)
{
var m = new Models.Job.CreateModel()
@@ -286,17 +339,17 @@ namespace Disco.Web.Controllers
DeviceSerialNumber = DeviceSerialNumber,
UserId = UserId
};
m.UpdateModel(dbContext);
m.UpdateModel(Database);
// UI Extensions
UIExtensions.ExecuteExtensions<JobCreateModel>(this.ControllerContext, m);
return View(m);
}
[HttpPost]
[HttpPost, DiscoAuthorize(Claims.Job.Actions.Create)]
public virtual ActionResult Create(Models.Job.CreateModel m)
{
m.UpdateModel(dbContext);
m.UpdateModel(Database);
if (!ModelState.IsValid)
{
@@ -308,8 +361,8 @@ namespace Disco.Web.Controllers
else
{
// Create New Job
var currentUser = dbContext.Users.Find(DiscoApplication.CurrentUser.Id);
var j = BI.JobBI.Utilities.Create(dbContext, m.Device, m.User, m.GetJobType, m.GetJobSubTypes, currentUser);
var currentUser = Database.Users.Find(UserService.CurrentUserId);
var j = BI.JobBI.Utilities.Create(Database, m.Device, m.User, m.GetJobType, m.GetJobSubTypes, currentUser);
if (m.DeviceHeld.Value)
{
@@ -342,10 +395,10 @@ namespace Disco.Web.Controllers
Timestamp = DateTime.Now,
Comments = m.Comments
};
dbContext.JobLogs.Add(jl);
Database.JobLogs.Add(jl);
}
dbContext.SaveChanges();
Database.SaveChanges();
// Return Dialog Redirect
var redirectModel = new Models.Job.CreateRedirectModel();
@@ -359,46 +412,13 @@ namespace Disco.Web.Controllers
}
#endregion
// Decommissioned 2012-11-28 G# - Moved to new infrastructure
#region Create - Old
//public virtual ActionResult Create(string DeviceSerialNumber, string UserId)
//{
// var m = new Models.Job.CreateModel()
// {
// DeviceSerialNumber = DeviceSerialNumber,
// UserId = UserId
// };
// m.UpdateModel(dbContext);
// return View(m);
//}
//[HttpPost]
//public virtual ActionResult Create(Models.Job.CreateModel m)
//{
// m.UpdateModel(dbContext);
// if (!ModelState.IsValid)
// {
// return View(m);
// }
// else
// {
// // Create New Job
// var currentUser = dbContext.Users.Find(DiscoApplication.CurrentUser.Id);
// var j = BI.JobBI.Utilities.Create(dbContext, m.Device, m.User, m.GetJobType, m.GetJobSubTypes, currentUser);
// dbContext.SaveChanges();
// return RedirectToAction(MVC.Job.Show(j.Id));
// }
//}
#endregion
// End Decommissioned 2012-11-28 G#
#region Log Warranty
[DiscoAuthorize(Claims.Job.Actions.LogWarranty)]
public virtual ActionResult LogWarranty(int id, string WarrantyProviderId, int? OrganisationAddressId)
{
var m = new Models.Job.LogWarrantyModel() { JobId = id, WarrantyProviderId = WarrantyProviderId, OrganisationAddressId = OrganisationAddressId };
m.UpdateModel(dbContext, false);
m.FaultDescription = m.Job.GenerateFaultDescription(dbContext);
m.UpdateModel(Database, false);
m.FaultDescription = m.Job.GenerateFaultDescription(Database);
if (m.WarrantyProvider != null)
{
@@ -407,17 +427,17 @@ namespace Disco.Web.Controllers
if (wp.SubmitJobViewType != null)
{
m.WarrantyProviderSubmitJobViewType = wp.SubmitJobViewType;
m.WarrantyProviderSubmitJobModel = wp.SubmitJobViewModel(dbContext, this, m.Job, m.OrganisationAddress, m.TechUser);
m.WarrantyProviderSubmitJobModel = wp.SubmitJobViewModel(Database, this, m.Job, m.OrganisationAddress, m.TechUser);
}
}
}
return View(m);
}
[HttpPost]
[HttpPost, DiscoAuthorize(Claims.Job.Actions.LogWarranty)]
public virtual ActionResult LogWarranty(Models.Job.LogWarrantyModel m, FormCollection form)
{
m.UpdateModel(dbContext, true);
m.UpdateModel(Database, true);
if (ModelState.IsValid)
{
@@ -429,7 +449,7 @@ namespace Disco.Web.Controllers
Dictionary<string, string> warrantyProviderProperties;
try
{
warrantyProviderProperties = p.SubmitJobParseProperties(dbContext, form, this, m.Job, m.OrganisationAddress, m.TechUser, m.FaultDescription);
warrantyProviderProperties = p.SubmitJobParseProperties(Database, form, this, m.Job, m.OrganisationAddress, m.TechUser, m.FaultDescription);
}
catch (Exception ex)
{
@@ -443,14 +463,14 @@ namespace Disco.Web.Controllers
{
m.WarrantyProviderPropertiesJson = JsonConvert.SerializeObject(warrantyProviderProperties);
}
m.DiscloseProperties = p.SubmitJobDiscloseInfo(dbContext, m.Job, m.OrganisationAddress, m.TechUser, m.FaultDescription, warrantyProviderProperties);
m.DiscloseProperties = p.SubmitJobDiscloseInfo(Database, m.Job, m.OrganisationAddress, m.TechUser, m.FaultDescription, warrantyProviderProperties);
return View(Views.LogWarrantyDisclose, m);
}
case "Submit":
try
{
m.Job.OnLogWarranty(dbContext, m.FaultDescription, m.WarrantyProvider, m.OrganisationAddress, m.TechUser, m.WarrantyProviderProperties());
dbContext.SaveChanges();
m.Job.OnLogWarranty(Database, m.FaultDescription, m.WarrantyProvider, m.OrganisationAddress, m.TechUser, m.WarrantyProviderProperties());
Database.SaveChanges();
return RedirectToAction(MVC.Job.Show(m.JobId));
}
catch (Exception ex)
@@ -470,11 +490,12 @@ namespace Disco.Web.Controllers
}
}
[DiscoAuthorize(Claims.Job.Properties.WarrantyProperties.ProviderDetails)]
public virtual ActionResult WarrantyProviderJobDetails(int id)
{
Models.Job.WarrantyProviderJobDetailsModel model = new Models.Job.WarrantyProviderJobDetailsModel();
Job job = dbContext.Jobs.Include("Device.DeviceModel").Include("JobMetaWarranty").Include("JobSubTypes").Where(j => j.Id == id).FirstOrDefault();
Job job = Database.Jobs.Include("Device.DeviceModel").Include("JobMetaWarranty").Include("JobSubTypes").Where(j => j.Id == id).FirstOrDefault();
if (job != null)
{
if (job.JobMetaWarranty != null && !string.IsNullOrEmpty(job.JobMetaWarranty.ExternalName))
@@ -489,7 +510,7 @@ namespace Disco.Web.Controllers
{
try
{
object providerModel = providerInstance.JobDetailsViewModel(dbContext, this, job);
object providerModel = providerInstance.JobDetailsViewModel(Database, this, job);
model.JobDetailsSupported = true;
model.ViewType = providerInstance.JobDetailsViewType;