2021-07-04 17:34:10 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Ardalis.GuardClauses;
|
|
|
|
|
using MongoDB.Driver;
|
|
|
|
|
using Retroactiune.Core.Entities;
|
|
|
|
|
using Retroactiune.Core.Interfaces;
|
|
|
|
|
|
|
|
|
|
namespace Retroactiune.Core.Services
|
|
|
|
|
{
|
|
|
|
|
public class FeedbacksService : IFeedbacksService
|
|
|
|
|
{
|
|
|
|
|
private readonly IMongoCollection<Feedback> _collection;
|
|
|
|
|
|
|
|
|
|
public FeedbacksService(IMongoClient client, IDatabaseSettings settings)
|
|
|
|
|
{
|
|
|
|
|
var database = client.GetDatabase(settings.DatabaseName);
|
2021-07-11 13:26:01 +00:00
|
|
|
|
_collection = database.GetCollection<Feedback>(settings.FeedbacksCollectionName);
|
2021-07-04 17:34:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task AddFeedbackAsync(Feedback feedback, FeedbackReceiver receiver)
|
|
|
|
|
{
|
|
|
|
|
Guard.Against.Null(feedback, nameof(feedback));
|
|
|
|
|
Guard.Against.Null(receiver, nameof(receiver));
|
|
|
|
|
|
|
|
|
|
feedback.FeedbackReceiverId = receiver.Id;
|
|
|
|
|
await _collection.InsertOneAsync(feedback);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|