qol: remove this

This commit is contained in:
Gary Sharp
2025-07-20 11:39:42 +10:00
parent b4e54c9edf
commit 4e518d6684
56 changed files with 282 additions and 282 deletions
+20 -20
View File
@@ -42,24 +42,24 @@ namespace Disco.Web.Models.Job
public void UpdateModel(DiscoDataContext Database, AuthorizationToken Authorization)
{
if (this.JobTypes == null)
this.JobTypes = Database.JobTypes.Include("JobSubTypes.JobQueues").FilterCreatableTypePermissions(Authorization).ToList();
if (JobTypes == null)
JobTypes = Database.JobTypes.Include("JobSubTypes.JobQueues").FilterCreatableTypePermissions(Authorization).ToList();
if (!string.IsNullOrEmpty(DeviceSerialNumber))
{
this.Device = Database.Devices.Include("DeviceModel").Where(d => d.SerialNumber == DeviceSerialNumber).FirstOrDefault();
if (this.Device == null)
Device = Database.Devices.Include("DeviceModel").Where(d => d.SerialNumber == DeviceSerialNumber).FirstOrDefault();
if (Device == null)
{
throw new ArgumentException("Invalid Device Serial Number Specified", "DeviceSerialNumber");
}
if (string.IsNullOrEmpty(this.UserId) && !string.IsNullOrEmpty(this.Device.AssignedUserId))
if (string.IsNullOrEmpty(UserId) && !string.IsNullOrEmpty(Device.AssignedUserId))
{
this.UserId = this.Device.AssignedUserId;
UserId = Device.AssignedUserId;
}
if (string.IsNullOrEmpty(this.Type))
this.Type = this.JobTypes.Any(jt => jt.Id == Disco.Models.Repository.JobType.JobTypeIds.HWar) ? Disco.Models.Repository.JobType.JobTypeIds.HWar : this.JobTypes.First().Id;
if (string.IsNullOrEmpty(Type))
Type = JobTypes.Any(jt => jt.Id == Disco.Models.Repository.JobType.JobTypeIds.HWar) ? Disco.Models.Repository.JobType.JobTypeIds.HWar : JobTypes.First().Id;
if (string.IsNullOrEmpty(this.UserId))
if (string.IsNullOrEmpty(UserId))
{
// No User - Remove User Types
foreach (var jobType in JobTypes.ToArray())
@@ -94,20 +94,20 @@ namespace Disco.Web.Models.Job
}
// Set Default Job Type for Users
if (string.IsNullOrEmpty(this.Type))
this.Type = this.JobTypes.Any(jt => jt.Id == Disco.Models.Repository.JobType.JobTypeIds.SApp) ? Disco.Models.Repository.JobType.JobTypeIds.SApp : this.JobTypes.First().Id;
if (string.IsNullOrEmpty(Type))
Type = JobTypes.Any(jt => jt.Id == Disco.Models.Repository.JobType.JobTypeIds.SApp) ? Disco.Models.Repository.JobType.JobTypeIds.SApp : JobTypes.First().Id;
}
if (!string.IsNullOrEmpty(UserId))
{
this.User = Database.Users.Find(UserId);
if (this.User == null)
User = Database.Users.Find(UserId);
if (User == null)
{
throw new ArgumentException("Invalid User Id Specified", "UserId");
}
if (string.IsNullOrEmpty(this.Type))
this.Type = Disco.Models.Repository.JobType.JobTypeIds.SApp;
if (string.IsNullOrEmpty(Type))
Type = Disco.Models.Repository.JobType.JobTypeIds.SApp;
}
if (this.User == null && this.Device == null)
if (User == null && Device == null)
{
throw new InvalidOperationException("A Job must reference a Device and/or a User");
}
@@ -118,9 +118,9 @@ namespace Disco.Web.Models.Job
{
get
{
if (!string.IsNullOrEmpty(this.Type))
if (!string.IsNullOrEmpty(Type))
{
return this.JobTypes.FirstOrDefault(m => m.Id == this.Type);
return JobTypes.FirstOrDefault(m => m.Id == Type);
}
return null;
}
@@ -131,8 +131,8 @@ namespace Disco.Web.Models.Job
{
if (SubTypes != null)
{
var subTypes = this.SubTypes;
return this.JobTypes.SelectMany(jt => jt.JobSubTypes).Where(m => subTypes.Contains(String.Format("{0}_{1}", m.JobTypeId, m.Id))).ToList();
var subTypes = SubTypes;
return JobTypes.SelectMany(jt => jt.JobSubTypes).Where(m => subTypes.Contains(String.Format("{0}_{1}", m.JobTypeId, m.Id))).ToList();
}
return null;
}
+7 -7
View File
@@ -50,11 +50,11 @@ namespace Disco.Web.Models.Job
public Dictionary<string, string> ProviderProperties()
{
Dictionary<string, string> p = default(Dictionary<string, string>);
if (!string.IsNullOrEmpty(this.ProviderPropertiesJson))
if (!string.IsNullOrEmpty(ProviderPropertiesJson))
{
try
{
p = JsonConvert.DeserializeObject<Dictionary<string, string>>(this.ProviderPropertiesJson);
p = JsonConvert.DeserializeObject<Dictionary<string, string>>(ProviderPropertiesJson);
}
catch (Exception)
{
@@ -98,7 +98,7 @@ namespace Disco.Web.Models.Job
}
// Update TechUser's Details [#12]
this.TechUser = UserService.GetUser(UserService.CurrentUserId, Database, true);
TechUser = UserService.GetUser(UserService.CurrentUserId, Database, true);
RepairProviders = Plugins.GetPluginFeatures(typeof(RepairProviderFeature));
@@ -113,16 +113,16 @@ namespace Disco.Web.Models.Job
if (!string.IsNullOrEmpty(RepairProviderId) && RepairProviderId != "MANUAL")
RepairProvider = Plugins.GetPluginFeature(RepairProviderId, typeof(RepairProviderFeature));
this.OrganisationAddresses = Database.DiscoConfiguration.OrganisationAddresses.Addresses.OrderBy(a => a.Name).ToList();
OrganisationAddresses = Database.DiscoConfiguration.OrganisationAddresses.Addresses.OrderBy(a => a.Name).ToList();
if (!IsPostBack && !this.OrganisationAddressId.HasValue)
if (!IsPostBack && !OrganisationAddressId.HasValue)
{
OrganisationAddressId = Job.Device.DeviceProfile.DefaultOrganisationAddress;
if (!OrganisationAddressId.HasValue && OrganisationAddresses.Count == 1)
OrganisationAddressId = OrganisationAddresses[0].Id;
}
if (this.OrganisationAddressId.HasValue)
this.OrganisationAddress = this.OrganisationAddresses.FirstOrDefault(oa => oa.Id == this.OrganisationAddressId.Value);
if (OrganisationAddressId.HasValue)
OrganisationAddress = OrganisationAddresses.FirstOrDefault(oa => oa.Id == OrganisationAddressId.Value);
if (!string.IsNullOrEmpty(RepairDescription))
RepairDescription = RepairDescription.Trim();
+7 -7
View File
@@ -51,11 +51,11 @@ namespace Disco.Web.Models.Job
public Dictionary<string, string> ProviderProperties()
{
Dictionary<string, string> p = default(Dictionary<string, string>);
if (!string.IsNullOrEmpty(this.ProviderPropertiesJson))
if (!string.IsNullOrEmpty(ProviderPropertiesJson))
{
try
{
p = JsonConvert.DeserializeObject<Dictionary<string, string>>(this.ProviderPropertiesJson);
p = JsonConvert.DeserializeObject<Dictionary<string, string>>(ProviderPropertiesJson);
}
catch (Exception)
{
@@ -98,7 +98,7 @@ namespace Disco.Web.Models.Job
}
// Update TechUser's Details [#12]
this.TechUser = UserService.GetUser(UserService.CurrentUserId, Database, true);
TechUser = UserService.GetUser(UserService.CurrentUserId, Database, true);
WarrantyProviders = Plugins.GetPluginFeatures(typeof(WarrantyProviderFeature));
@@ -113,16 +113,16 @@ namespace Disco.Web.Models.Job
if (!string.IsNullOrEmpty(WarrantyProviderId) && WarrantyProviderId != "MANUAL")
WarrantyProvider = Plugins.GetPluginFeature(WarrantyProviderId, typeof(WarrantyProviderFeature));
this.OrganisationAddresses = Database.DiscoConfiguration.OrganisationAddresses.Addresses.OrderBy(a => a.Name).ToList();
OrganisationAddresses = Database.DiscoConfiguration.OrganisationAddresses.Addresses.OrderBy(a => a.Name).ToList();
if (!IsPostBack && !this.OrganisationAddressId.HasValue)
if (!IsPostBack && !OrganisationAddressId.HasValue)
{
OrganisationAddressId = Job.Device.DeviceProfile.DefaultOrganisationAddress;
if (!OrganisationAddressId.HasValue && OrganisationAddresses.Count == 1)
OrganisationAddressId = OrganisationAddresses[0].Id;
}
if (this.OrganisationAddressId.HasValue)
this.OrganisationAddress = this.OrganisationAddresses.FirstOrDefault(oa => oa.Id == this.OrganisationAddressId.Value);
if (OrganisationAddressId.HasValue)
OrganisationAddress = OrganisationAddresses.FirstOrDefault(oa => oa.Id == OrganisationAddressId.Value);
if (!string.IsNullOrEmpty(FaultDescription))
FaultDescription = FaultDescription.Trim();