public async Task AddUrl(TheUrl item) { try { await _context.Urls.InsertOneAsync(item); } catch (Exception ex) { _log.LogCritical($"Add failed for item {item.ToString()}", ex); throw ex; } }
public async Task <bool> UpdateUrl(string id, TheUrl item) { try { ReplaceOneResult actionResult = await _context.Urls .ReplaceOneAsync(n => n.Id.Equals(id) , item , new UpdateOptions { IsUpsert = true }); return(actionResult.IsAcknowledged && actionResult.ModifiedCount > 0); } catch (Exception ex) { _log.LogCritical($"UpdateUrl failed for id {id} and item: {item.ToString()}", ex); throw ex; } }