| | 1 | | using Google.Cloud.Firestore; |
| | 2 | | using MongoDB.Bson.Serialization.Attributes; |
| | 3 | | using MongoDB.Bson; |
| | 4 | | using MRA.Infrastructure.Database.Documents.Interfaces; |
| | 5 | | using MongoDB.Driver; |
| | 6 | | using MRA.Infrastructure.Database.Providers; |
| | 7 | |
|
| | 8 | | namespace MRA.Infrastructure.Database.Documents.MongoDb; |
| | 9 | |
|
| | 10 | | public class CollectionMongoDocument : MongoDocumentBase, ICollectionDocument |
| | 11 | | { |
| | 12 | | [BsonElement("name")] |
| 0 | 13 | | public string name { get; set; } |
| | 14 | |
|
| | 15 | | [BsonElement("description")] |
| 0 | 16 | | public string description { get; set; } |
| | 17 | |
|
| | 18 | | [BsonElement("order")] |
| 0 | 19 | | public int order { get; set; } |
| | 20 | |
|
| | 21 | | [BsonElement("drawingIds")] |
| 0 | 22 | | public IEnumerable<string> drawingIds { get; set; } |
| | 23 | |
|
| 0 | 24 | | public string GetId() => Id; |
| | 25 | |
|
| | 26 | | public override async Task<ReplaceOneResult> SetDocumentAsync(IMongoDatabase database, string collection, string doc |
| | 27 | | { |
| 0 | 28 | | var mongoCollection = database.GetCollection<CollectionMongoDocument>(collection); |
| | 29 | |
|
| 0 | 30 | | var filter = Builders<CollectionMongoDocument>.Filter.Eq(MongoDbDatabase.ID_FIELD, documentId); |
| 0 | 31 | | var options = new ReplaceOptions { IsUpsert = true }; |
| | 32 | |
|
| 0 | 33 | | return await mongoCollection.ReplaceOneAsync(filter, this, options); |
| 0 | 34 | | } |
| | 35 | | } |