qol: simplify default
This commit is contained in:
@@ -282,7 +282,7 @@ namespace Disco.Data.Configuration
|
|||||||
Type valueType = typeof(T);
|
Type valueType = typeof(T);
|
||||||
string stringValue;
|
string stringValue;
|
||||||
|
|
||||||
if (comparer.Equals(Value, default(T)))
|
if (comparer.Equals(Value, default))
|
||||||
{
|
{
|
||||||
stringValue = null;
|
stringValue = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,12 +86,12 @@ namespace Disco.Services
|
|||||||
|
|
||||||
|
|
||||||
// Batch
|
// Batch
|
||||||
DeviceBatch db = default(DeviceBatch);
|
var db = default(DeviceBatch);
|
||||||
if (d.DeviceBatchId.HasValue)
|
if (d.DeviceBatchId.HasValue)
|
||||||
db = Database.DeviceBatches.Find(d.DeviceBatchId.Value);
|
db = Database.DeviceBatches.Find(d.DeviceBatchId.Value);
|
||||||
|
|
||||||
// Default Device Model
|
// Default Device Model
|
||||||
DeviceModel dm = default(DeviceModel);
|
var dm = default(DeviceModel);
|
||||||
if (db != null && db.DefaultDeviceModelId.HasValue)
|
if (db != null && db.DefaultDeviceModelId.HasValue)
|
||||||
dm = Database.DeviceModels.Find(db.DefaultDeviceModelId); // From Batch
|
dm = Database.DeviceModels.Find(db.DefaultDeviceModelId); // From Batch
|
||||||
else
|
else
|
||||||
@@ -158,7 +158,7 @@ namespace Disco.Services
|
|||||||
|
|
||||||
public static DeviceUserAssignment AssignDevice(this Device d, DiscoDataContext Database, User u)
|
public static DeviceUserAssignment AssignDevice(this Device d, DiscoDataContext Database, User u)
|
||||||
{
|
{
|
||||||
DeviceUserAssignment newDua = default(DeviceUserAssignment);
|
DeviceUserAssignment newDua = default;
|
||||||
|
|
||||||
// Mark existing assignments as Unassigned
|
// Mark existing assignments as Unassigned
|
||||||
foreach (var dua in Database.DeviceUserAssignments.Where(m => m.DeviceSerialNumber == d.SerialNumber && !m.UnassignedDate.HasValue))
|
foreach (var dua in Database.DeviceUserAssignments.Where(m => m.DeviceSerialNumber == d.SerialNumber && !m.UnassignedDate.HasValue))
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace Disco.Services.Expressions
|
|||||||
|
|
||||||
public T EvaluateFirst<T>(object ExpressionContext, IDictionary Variables)
|
public T EvaluateFirst<T>(object ExpressionContext, IDictionary Variables)
|
||||||
{
|
{
|
||||||
T result = default(T);
|
T result = default;
|
||||||
if (Count > 0)
|
if (Count > 0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace Disco.Services.Expressions.Extensions
|
|||||||
{
|
{
|
||||||
var objectValue = GetActiveDirectoryObjectValue(Device, PropertyName, Index);
|
var objectValue = GetActiveDirectoryObjectValue(Device, PropertyName, Index);
|
||||||
if (objectValue == null)
|
if (objectValue == null)
|
||||||
return default(int);
|
return default;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int intValue;
|
int intValue;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace Disco.Services.Expressions.Extensions
|
|||||||
{
|
{
|
||||||
var objectValue = GetActiveDirectoryObjectValue(User, PropertyName, Index);
|
var objectValue = GetActiveDirectoryObjectValue(User, PropertyName, Index);
|
||||||
if (objectValue == null)
|
if (objectValue == null)
|
||||||
return default(int);
|
return default;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int intValue;
|
int intValue;
|
||||||
|
|||||||
@@ -76,13 +76,10 @@ namespace Disco.Services.Interop.ActiveDirectory
|
|||||||
|
|
||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
long lastLogonValue = default(long);
|
var lastLogonValue = result.Value<long>("lastLogon");
|
||||||
long lastLogonTimestampValue = default(long);
|
var lastLogonTimestampValue = result.Value<long>("lastLogonTimestamp");
|
||||||
|
|
||||||
lastLogonValue = result.Value<long>("lastLogon");
|
var highedValue = Math.Max(lastLogonValue, lastLogonTimestampValue);
|
||||||
lastLogonTimestampValue = result.Value<long>("lastLogonTimestamp");
|
|
||||||
|
|
||||||
long highedValue = Math.Max(lastLogonValue, lastLogonTimestampValue);
|
|
||||||
|
|
||||||
if (highedValue > 0)
|
if (highedValue > 0)
|
||||||
return (DateTime?)new DateTime((DateTime.FromFileTime(highedValue).Ticks / 10000000L) * 10000000L);
|
return (DateTime?)new DateTime((DateTime.FromFileTime(highedValue).Ticks / 10000000L) * 10000000L);
|
||||||
@@ -151,8 +148,8 @@ namespace Disco.Services.Interop.ActiveDirectory
|
|||||||
{
|
{
|
||||||
var samAccountName = result.Value<string>("sAMAccountName");
|
var samAccountName = result.Value<string>("sAMAccountName");
|
||||||
|
|
||||||
long lastLogonValue = default(long);
|
long lastLogonValue = default;
|
||||||
long lastLogonTimestampValue = default(long);
|
long lastLogonTimestampValue = default;
|
||||||
|
|
||||||
lastLogonValue = result.Value<long>("lastLogon");
|
lastLogonValue = result.Value<long>("lastLogon");
|
||||||
lastLogonTimestampValue = result.Value<long>("lastLogonTimestamp");
|
lastLogonTimestampValue = result.Value<long>("lastLogonTimestamp");
|
||||||
|
|||||||
@@ -17,15 +17,14 @@ namespace Disco.Services.Searching
|
|||||||
#region Jobs
|
#region Jobs
|
||||||
public static List<JobSearchResultItem> SearchJobs(DiscoDataContext Database, string Term, int? LimitCount = ActiveDirectory.DefaultSearchResultLimit)
|
public static List<JobSearchResultItem> SearchJobs(DiscoDataContext Database, string Term, int? LimitCount = ActiveDirectory.DefaultSearchResultLimit)
|
||||||
{
|
{
|
||||||
|
var query = (IQueryable<Job>)Database.Jobs;
|
||||||
IQueryable<Job> query = default(IQueryable<Job>);
|
|
||||||
|
|
||||||
string userIdTerm = Term.Contains('\\') ? Term : ActiveDirectory.ParseDomainAccountId(Term);
|
string userIdTerm = Term.Contains('\\') ? Term : ActiveDirectory.ParseDomainAccountId(Term);
|
||||||
|
|
||||||
if (int.TryParse(Term, out var termInt))
|
if (int.TryParse(Term, out var termInt))
|
||||||
{
|
{
|
||||||
// Term is a Number (int)
|
// Term is a Number (int)
|
||||||
query = Database.Jobs.Where(j =>
|
query = query.Where(j =>
|
||||||
j.Id == termInt ||
|
j.Id == termInt ||
|
||||||
j.Device.SerialNumber.Contains(Term) ||
|
j.Device.SerialNumber.Contains(Term) ||
|
||||||
j.Device.AssetNumber.Contains(Term) ||
|
j.Device.AssetNumber.Contains(Term) ||
|
||||||
@@ -34,7 +33,7 @@ namespace Disco.Services.Searching
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
query = Database.Jobs.Where(j =>
|
query = query.Where(j =>
|
||||||
j.Device.SerialNumber.Contains(Term) ||
|
j.Device.SerialNumber.Contains(Term) ||
|
||||||
j.Device.AssetNumber.Contains(Term) ||
|
j.Device.AssetNumber.Contains(Term) ||
|
||||||
j.User.UserId == userIdTerm ||
|
j.User.UserId == userIdTerm ||
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace Disco.Web.Extensions
|
|||||||
{
|
{
|
||||||
public static List<SelectListItem> ToSelectListItems(this IEnumerable<OrganisationAddress> organisationAddressess, OrganisationAddress SelectedItem)
|
public static List<SelectListItem> ToSelectListItems(this IEnumerable<OrganisationAddress> organisationAddressess, OrganisationAddress SelectedItem)
|
||||||
{
|
{
|
||||||
int? selectedId = default(int?);
|
var selectedId = default(int?);
|
||||||
|
|
||||||
if (SelectedItem != null)
|
if (SelectedItem != null)
|
||||||
selectedId = SelectedItem.Id;
|
selectedId = SelectedItem.Id;
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ namespace Disco.Web.Extensions
|
|||||||
|
|
||||||
public static List<SelectListItem> ToSelectListItems(this IEnumerable<PluginManifest> PluginFeatureDefinitions, PluginManifest SelectedItem)
|
public static List<SelectListItem> ToSelectListItems(this IEnumerable<PluginManifest> PluginFeatureDefinitions, PluginManifest SelectedItem)
|
||||||
{
|
{
|
||||||
string selectedId = default(string);
|
var selectedId = default(string);
|
||||||
|
|
||||||
if (SelectedItem != null)
|
if (SelectedItem != null)
|
||||||
selectedId = SelectedItem.Id;
|
selectedId = SelectedItem.Id;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace Disco.Web.Extensions
|
|||||||
{
|
{
|
||||||
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobSubType> jobSubTypes, IEnumerable<JobSubType> SelectedItems, bool IncludeQueueIcons = false)
|
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobSubType> jobSubTypes, IEnumerable<JobSubType> SelectedItems, bool IncludeQueueIcons = false)
|
||||||
{
|
{
|
||||||
List<string> selectedIds = default(List<string>);
|
var selectedIds = default(List<string>);
|
||||||
|
|
||||||
if (SelectedItems != null)
|
if (SelectedItems != null)
|
||||||
selectedIds = SelectedItems.Select(i => $"{i.JobTypeId}_{i.Id}").ToList();
|
selectedIds = SelectedItems.Select(i => $"{i.JobTypeId}_{i.Id}").ToList();
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace Disco.Web.Extensions
|
|||||||
{
|
{
|
||||||
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobType> jobTypes, JobType SelectedItem)
|
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobType> jobTypes, JobType SelectedItem)
|
||||||
{
|
{
|
||||||
string selectedId = default(string);
|
var selectedId = default(string);
|
||||||
|
|
||||||
if (SelectedItem != null)
|
if (SelectedItem != null)
|
||||||
selectedId = SelectedItem.Id;
|
selectedId = SelectedItem.Id;
|
||||||
@@ -27,7 +27,7 @@ namespace Disco.Web.Extensions
|
|||||||
|
|
||||||
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobType> jobTypes, IEnumerable<JobType> SelectedItems)
|
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobType> jobTypes, IEnumerable<JobType> SelectedItems)
|
||||||
{
|
{
|
||||||
List<string> selectedIds = default(List<string>);
|
var selectedIds = default(List<string>);
|
||||||
|
|
||||||
if (SelectedItems != null)
|
if (SelectedItems != null)
|
||||||
selectedIds = SelectedItems.Select(i => i.Id).ToList();
|
selectedIds = SelectedItems.Select(i => i.Id).ToList();
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace Disco.Web.Models.Job
|
|||||||
public string ProviderPropertiesJson { get; set; }
|
public string ProviderPropertiesJson { get; set; }
|
||||||
public Dictionary<string, string> ProviderProperties()
|
public Dictionary<string, string> ProviderProperties()
|
||||||
{
|
{
|
||||||
Dictionary<string, string> p = default(Dictionary<string, string>);
|
var p = default(Dictionary<string, string>);
|
||||||
if (!string.IsNullOrEmpty(ProviderPropertiesJson))
|
if (!string.IsNullOrEmpty(ProviderPropertiesJson))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace Disco.Web.Models.Job
|
|||||||
public string ProviderPropertiesJson { get; set; }
|
public string ProviderPropertiesJson { get; set; }
|
||||||
public Dictionary<string, string> ProviderProperties()
|
public Dictionary<string, string> ProviderProperties()
|
||||||
{
|
{
|
||||||
Dictionary<string, string> p = default(Dictionary<string, string>);
|
var p = default(Dictionary<string, string>);
|
||||||
if (!string.IsNullOrEmpty(ProviderPropertiesJson))
|
if (!string.IsNullOrEmpty(ProviderPropertiesJson))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
Reference in New Issue
Block a user