diff --git a/WebAPI/Calculators/BaseCalc.cs b/WebAPI/Calculators/BaseCalc.cs index 4e05abb..25dba7c 100644 --- a/WebAPI/Calculators/BaseCalc.cs +++ b/WebAPI/Calculators/BaseCalc.cs @@ -21,7 +21,7 @@ public class BaseCalc public bool IsFormulaCorrect() { // check left side of expression - if (!ResultCode.StartsWith("[") || !ResultCode.EndsWith("]")) + if (!ResultCode.StartsWith('[') || !ResultCode.EndsWith(']')) { return false; } diff --git a/WebAPI/Controllers/LayersController.cs b/WebAPI/Controllers/LayersController.cs index 83da2fc..60c1c6d 100644 --- a/WebAPI/Controllers/LayersController.cs +++ b/WebAPI/Controllers/LayersController.cs @@ -208,7 +208,7 @@ public class LayersController : Controller .ToList(); try { - if (!importWorkerLayers.Any()) + if (importWorkerLayers.Count == 0) { _logsController.AddEntry(new LogEntry { @@ -346,7 +346,7 @@ public class LayersController : Controller } string[] processTypes = - { + [ "T3-SingleSource", "T3-SourceYearSummary", "T3-MultiSourceSummary", // AA @@ -354,7 +354,7 @@ public class LayersController : Controller "T4-SingleSource", "T1-R1", "T4-R2" - }; + ]; foreach (var type in processTypes) { @@ -378,7 +378,7 @@ public class LayersController : Controller .OrderBy(x => x.CreatedAt) .ToList(); - if (!processWorkerLayers.Any()) + if (processWorkerLayers.Count == 0) { _logsController.AddEntry(new LogEntry { diff --git a/WebAPI/GoogleDriveHelper.cs b/WebAPI/GoogleDriveHelper.cs index 4e2d3b4..d588a85 100644 --- a/WebAPI/GoogleDriveHelper.cs +++ b/WebAPI/GoogleDriveHelper.cs @@ -8,7 +8,7 @@ public class GoogleDriveHelper { public DriveService? Service { get; private set; } private const string ApplicationName = "Diuna"; - private static readonly string[] Scopes = { DriveService.Scope.Drive }; + private static readonly string[] Scopes = [DriveService.Scope.Drive]; public GoogleDriveHelper() { InitializeService(); diff --git a/WebAPI/GoogleSheetsHelper.cs b/WebAPI/GoogleSheetsHelper.cs index 3d424ce..4a06596 100644 --- a/WebAPI/GoogleSheetsHelper.cs +++ b/WebAPI/GoogleSheetsHelper.cs @@ -8,7 +8,7 @@ public class GoogleSheetsHelper { public SheetsService? Service { get; private set; } private const string ApplicationName = "Diuna"; - private static readonly string[] Scopes = { SheetsService.Scope.Spreadsheets }; + private static readonly string[] Scopes = [SheetsService.Scope.Spreadsheets]; public GoogleSheetsHelper() { InitializeService(); diff --git a/WebAPI/Program.cs b/WebAPI/Program.cs index 37cc80d..4c6bdd4 100644 --- a/WebAPI/Program.cs +++ b/WebAPI/Program.cs @@ -59,11 +59,11 @@ var app = builder.Build(); app.Use(async (context, next) => { - var token = context.Request.Headers["Authorization"].ToString(); + var token = context.Request.Headers.Authorization.ToString(); if (token.Length > 0 && !context.Request.Path.ToString().Contains("getForPowerBI")) { var handler = new JwtSecurityTokenHandler(); var data = handler.ReadJwtToken(token.Split(' ')[1]); - context.Request.Headers.Add("UserId", new Microsoft.Extensions.Primitives.StringValues(data.Subject)); + context.Request.Headers.Append("UserId", new Microsoft.Extensions.Primitives.StringValues(data.Subject)); } await next(context); }); diff --git a/WebAPI/dataProcessors/t1.r1.processor.cs b/WebAPI/dataProcessors/t1.r1.processor.cs index 04cfb3d..c17863f 100644 --- a/WebAPI/dataProcessors/t1.r1.processor.cs +++ b/WebAPI/dataProcessors/t1.r1.processor.cs @@ -31,7 +31,7 @@ public class T1R1Processor { var year = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Year")?.Desc1!); var sources = processWorker.Records?.Where(x => x.Code == "Source").ToList(); - if (!sources!.Any()) + if (sources!.Count == 0) { throw new Exception("Source record not found"); } @@ -71,7 +71,7 @@ public class T1R1Processor var dataSources = new List(); - foreach (var source in sources!) + foreach (var source in sources) { for (var month = 1; month <= DateTime.UtcNow.Month; month++) { diff --git a/WebAPI/dataProcessors/t3.MultiSourceCopySelectedCodes.processor.cs b/WebAPI/dataProcessors/t3.MultiSourceCopySelectedCodes.processor.cs index c172d47..8664fd4 100644 --- a/WebAPI/dataProcessors/t3.MultiSourceCopySelectedCodes.processor.cs +++ b/WebAPI/dataProcessors/t3.MultiSourceCopySelectedCodes.processor.cs @@ -23,7 +23,7 @@ public class T3MultiSourceCopySelectedCodesProcessor var year = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Year")?.Desc1!); var month = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Month")?.Desc1!); var sources = processWorker.Records?.Where(x => x.Code == "Source").ToList(); - if (!sources!.Any()) + if (sources!.Count == 0) { throw new Exception("Source record not found"); } @@ -62,7 +62,7 @@ public class T3MultiSourceCopySelectedCodesProcessor processedLayer.ModifiedById = Guid.Parse("F392209E-123E-4651-A5A4-0B1D6CF9FF9D"); processedLayer.ModifiedAt = DateTime.UtcNow; - var dataSources = sources!.Select(source => _db.Layers.Where(x => x.Type == LayerType.Processed && !x.IsDeleted && x.Name != null && x.Name.Contains($"{year}/{month}-{source.Desc1}-T3")) + var dataSources = sources.Select(source => _db.Layers.Where(x => x.Type == LayerType.Processed && !x.IsDeleted && x.Name != null && x.Name.Contains($"{year}/{month}-{source.Desc1}-T3")) .Include(x => x.Records) .FirstOrDefault()) .OfType() diff --git a/WebAPI/dataProcessors/t3.MultiSourceSummary.processor.cs b/WebAPI/dataProcessors/t3.MultiSourceSummary.processor.cs index 3dae937..f2f8d3f 100644 --- a/WebAPI/dataProcessors/t3.MultiSourceSummary.processor.cs +++ b/WebAPI/dataProcessors/t3.MultiSourceSummary.processor.cs @@ -27,7 +27,7 @@ public class T3MultiSourceSummaryProcessor var year = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Year")?.Desc1!); var month = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Month")?.Desc1!); var sources = processWorker.Records?.Where(x => x.Code == "Source").ToList(); - if (!sources!.Any()) + if (sources!.Count == 0) { throw new Exception("Source record not found"); } @@ -61,7 +61,7 @@ public class T3MultiSourceSummaryProcessor var newRecords = new List(); - var dataSources = sources!.Select(source => _db.Layers.Where(x => x.Type == LayerType.Processed && !x.IsDeleted && x.Name != null && x.Name.Contains($"{year}/{month}-{source.Desc1}-T3")) + var dataSources = sources.Select(source => _db.Layers.Where(x => x.Type == LayerType.Processed && !x.IsDeleted && x.Name != null && x.Name.Contains($"{year}/{month}-{source.Desc1}-T3")) .Include(x => x.Records) .FirstOrDefault()) .OfType() @@ -98,7 +98,7 @@ public class T3MultiSourceSummaryProcessor // Dynamic Codes var dynamicCodes = processWorker.Records?.Where(x => x.Code == "DynamicCode").ToList(); - if (dynamicCodes != null && dynamicCodes.Any()) + if (dynamicCodes != null && dynamicCodes.Count != 0) { foreach (var dynamicCode in dynamicCodes) { diff --git a/WebAPI/dataProcessors/t3.MultiSourceYearSummary.processor.cs b/WebAPI/dataProcessors/t3.MultiSourceYearSummary.processor.cs index 35f02e2..73729c7 100644 --- a/WebAPI/dataProcessors/t3.MultiSourceYearSummary.processor.cs +++ b/WebAPI/dataProcessors/t3.MultiSourceYearSummary.processor.cs @@ -26,7 +26,7 @@ public class T3MultiSourceYearSummaryProcessor { var year = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Year")?.Desc1!); var sources = processWorker.Records?.Where(x => x.Code == "Source").ToList(); - if (!sources!.Any()) + if (sources!.Count == 0) { throw new Exception("Source record not found"); } @@ -60,7 +60,7 @@ public class T3MultiSourceYearSummaryProcessor var newRecords = new List(); - var dataSources = sources!.Select(source => _db.Layers.Where(x => x.Type == LayerType.Processed && !x.IsDeleted && x.Name != null && x.Name.Contains($"{year}/13-{source.Desc1}-T3")) + var dataSources = sources.Select(source => _db.Layers.Where(x => x.Type == LayerType.Processed && !x.IsDeleted && x.Name != null && x.Name.Contains($"{year}/13-{source.Desc1}-T3")) .Include(x => x.Records) .FirstOrDefault()) .OfType() @@ -120,7 +120,7 @@ public class T3MultiSourceYearSummaryProcessor // Dynamic Codes var dynamicCodes = processWorker.Records?.Where(x => x.Code == "DynamicCode").ToList(); - if (dynamicCodes != null && dynamicCodes.Any()) + if (dynamicCodes != null && dynamicCodes.Count != 0) { foreach (var dynamicCode in dynamicCodes) { diff --git a/WebAPI/dataProcessors/t4.r2.processor.cs b/WebAPI/dataProcessors/t4.r2.processor.cs index f651260..2a8d791 100644 --- a/WebAPI/dataProcessors/t4.r2.processor.cs +++ b/WebAPI/dataProcessors/t4.r2.processor.cs @@ -26,7 +26,7 @@ public class T4R2Processor { var year = int.Parse(processWorker.Records?.SingleOrDefault(x => x.Code == "Year")?.Desc1!); var sources = processWorker.Records?.Where(x => x.Code == "Source").ToList(); - if (!sources!.Any()) + if (sources!.Count == 0) { throw new Exception("Source record not found"); } @@ -68,7 +68,7 @@ public class T4R2Processor var newRecords = new List(); - foreach (var source in sources!) + foreach (var source in sources) { var rawSourceCodes = processWorker.Records?.SingleOrDefault(x => x.Code == $"Codes-{source.Desc1}") ?.Desc1;