Cleanup .net warnings
This commit is contained in:
@@ -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}";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user