| | 1 | | using MongoDB.Bson.Serialization.Attributes; |
| | 2 | | using MongoDB.Bson; |
| | 3 | | using MRA.Infrastructure.Database.Documents.Interfaces; |
| | 4 | | using MongoDB.Driver; |
| | 5 | | using MRA.Infrastructure.Database.Providers; |
| | 6 | |
|
| | 7 | | namespace MRA.Infrastructure.Database.Documents.MongoDb; |
| | 8 | |
|
| | 9 | | public class InspirationMongoDocument : MongoDocumentBase, IInspirationDocument |
| | 10 | | { |
| | 11 | | [BsonElement("name")] |
| 5 | 12 | | public string Name { get; set; } |
| | 13 | |
|
| | 14 | | [BsonElement("instagram")] |
| 5 | 15 | | public string Instagram { get; set; } |
| | 16 | |
|
| | 17 | | [BsonElement("twitter")] |
| 5 | 18 | | public string Twitter { get; set; } |
| | 19 | |
|
| | 20 | | [BsonElement("youtube")] |
| 5 | 21 | | public string YouTube { get; set; } |
| | 22 | |
|
| | 23 | | [BsonElement("twitch")] |
| 5 | 24 | | public string Twitch { get; set; } |
| | 25 | |
|
| | 26 | | [BsonElement("pinterest")] |
| 5 | 27 | | public string Pinterest { get; set; } |
| | 28 | |
|
| | 29 | | [BsonElement("type")] |
| 5 | 30 | | public int Type { get; set; } |
| | 31 | |
|
| 0 | 32 | | public string GetId() => Id; |
| | 33 | |
|
| | 34 | | public override async Task<ReplaceOneResult> SetDocumentAsync(IMongoDatabase database, string collection, string doc |
| | 35 | | { |
| 0 | 36 | | var mongoCollection = database.GetCollection<InspirationMongoDocument>(collection); |
| | 37 | |
|
| 0 | 38 | | var filter = Builders<InspirationMongoDocument>.Filter.Eq(MongoDbDatabase.ID_FIELD, documentId); |
| 0 | 39 | | var options = new ReplaceOptions { IsUpsert = true }; |
| | 40 | |
|
| 0 | 41 | | return await mongoCollection.ReplaceOneAsync(filter, this, options); |
| 0 | 42 | | } |
| | 43 | | } |