public bool AddUpdateWorker(Workers worker) { if (worker == null) { throw new ArgumentNullException(nameof(worker)); } if (!worker.IsValid()) { throw new ValidationException("Not all required fields are set"); } try { worker.LastConnected = DateTime.Now; var dbHost = _database.GetOne <Workers>(a => a.Name == worker.Name); if (dbHost == null) { _database.Insert(worker); } else { dbHost.Active = true; dbHost.LastConnected = worker.LastConnected; dbHost.NumCores = worker.NumCores; dbHost.OSVersion = worker.OSVersion; _database.Update(dbHost); } return(true); } catch (Exception ex) { Log.Error($"Failed to Add or Update Worker {worker} due to {ex}"); return(false); } }