using System.Globalization; using Google.Apis.Sheets.v4; using Google.Apis.Sheets.v4.Data; using Google.Cloud.Firestore; using Microsoft.AspNetCore.Mvc; using WebAPI.Models; namespace WebAPI.Controllers; public class LogsController : Controller { private readonly FirestoreDb _firestoreDb; private readonly Guid _SessionId = Guid.NewGuid(); public LogsController( FirestoreDb firestoreDb ) { _firestoreDb = firestoreDb; } public void AddEntry(LogEntry entry) { entry.SessionId = _SessionId; entry.Instance = LogInstance.Morska; try { var collection = _firestoreDb.Collection("ApiLogs"); var document = collection.Document(); document.SetAsync(new { entry.Message, entry.Title, Type = Enum.GetName(typeof(LogEntryType), entry.Type), LogType = Enum.GetName(typeof(LogType), entry.LogType), Instance = Enum.GetName(typeof(LogInstance), entry.Instance), entry.CreatedAt, SessionId = entry.SessionId.ToString() }).Wait(); } catch (Exception e) { Console.WriteLine(e.Message); } } }