Cleanup .net warnings

This commit is contained in:
Michał Zieliński
2023-11-29 22:14:37 +01:00
parent 03cf1a5e07
commit e174a02b54
10 changed files with 304 additions and 332 deletions

View File

@@ -9,7 +9,7 @@ namespace WebAPI.Controllers
{
public class LogsController : Controller
{
private SpreadsheetsResource.ValuesResource googleSheetValues;
private SpreadsheetsResource.ValuesResource? googleSheetValues;
private GoogleDriveHelper googleDriveHelper;
private readonly IConfiguration configuration;
public LogsController(
@@ -17,13 +17,18 @@ namespace WebAPI.Controllers
GoogleDriveHelper _googleDriveHelper,
IConfiguration _configuration)
{
googleSheetValues = _googleSheetsHelper.Service.Spreadsheets.Values;
if (_googleSheetsHelper.Service is not null) {
googleSheetValues = _googleSheetsHelper.Service.Spreadsheets.Values;
}
googleDriveHelper = _googleDriveHelper;
configuration = _configuration;
}
public void AddEntry(LogEntry entry)
{
if (googleSheetValues is null) {
throw new Exception("Google Sheets API not initialized");
}
String type;
switch (entry.LogType) {
case LogType.import:
@@ -42,8 +47,8 @@ namespace WebAPI.Controllers
var response = googleSheetValues.Get(configuration["appLogsFile"], $"{type}!A:A").Execute();
var data = response.Values;
int row = 1;
if (data != null) {
row = data.Count + 1;
if (data != null) {
row = data.Count + 1;
}
var range = $"{type}!A{row}:D{row}";