using System; using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using MongoDB.Driver; using Retroactiune.Models; using Retroactiune.Settings; namespace Retroactiune.Services { /// /// Service that simplifies access to the database for managing FeedbackReceiver items. /// /// public class FeedbackReceiverService { private readonly IMongoCollection _collection; private readonly ILogger _logger; public FeedbackReceiverService(IMongoDbSettings settings, ILogger logger) { var client = new MongoClient(settings.ConnectionString); var database = client.GetDatabase(settings.DatabaseName); _collection = database.GetCollection(settings.FeedbackReceiverCollectionName); _logger = logger; } public async Task CreateMany(IEnumerable items) { try { await _collection.InsertManyAsync(items); } catch (Exception e) { throw new GenericServiceException($"Operation failed: {e.Message}"); } } } }