| | 1 | | using MongoDB.Bson.Serialization.Attributes; |
| | 2 | | using MongoDB.Driver; |
| | 3 | | using MRA.Infrastructure.Database.Documents.Interfaces; |
| | 4 | | using MRA.Infrastructure.Database.Providers; |
| | 5 | |
|
| | 6 | | namespace MRA.Infrastructure.Database.Documents.MongoDb; |
| | 7 | |
|
| | 8 | | public class DrawingMongoDocument : MongoDocumentBase, IDrawingDocument |
| | 9 | | { |
| | 10 | | [BsonElement("path")] |
| 37 | 11 | | public string path { get; set; } |
| | 12 | |
|
| | 13 | | [BsonElement("path_thumbnail")] |
| 37 | 14 | | public string path_thumbnail { get; set; } |
| | 15 | |
|
| | 16 | | [BsonElement("type")] |
| 37 | 17 | | public int type { get; set; } |
| | 18 | |
|
| | 19 | | [BsonElement("visible")] |
| 43 | 20 | | public bool? visible { get; set; } |
| | 21 | |
|
| | 22 | | [BsonElement("name")] |
| 49 | 23 | | public string name { get; set; } |
| | 24 | |
|
| | 25 | | [BsonElement("model_name")] |
| 49 | 26 | | public string model_name { get; set; } |
| | 27 | |
|
| | 28 | | [BsonElement("title")] |
| 37 | 29 | | public string title { get; set; } |
| | 30 | |
|
| | 31 | | [BsonElement("date")] |
| 0 | 32 | | public string date { get; set; } |
| | 33 | |
|
| | 34 | | [BsonElement("drawingAt")] |
| 37 | 35 | | public DateTime drawingAt { get; set; } |
| | 36 | |
|
| | 37 | | [BsonElement("time")] |
| 37 | 38 | | public int? time { get; set; } |
| | 39 | |
|
| | 40 | | [BsonElement("product_type")] |
| 49 | 41 | | public int product_type { get; set; } |
| | 42 | |
|
| | 43 | | [BsonElement("product_name")] |
| 49 | 44 | | public string product_name { get; set; } |
| | 45 | |
|
| | 46 | | [BsonElement("list_comments")] |
| 37 | 47 | | public IEnumerable<string> list_comments { get; set; } |
| | 48 | |
|
| | 49 | | [BsonElement("list_comments_style")] |
| 37 | 50 | | public IEnumerable<string> list_comments_style { get; set; } |
| | 51 | |
|
| | 52 | | [BsonElement("list_comments_pros")] |
| 37 | 53 | | public IEnumerable<string> list_comments_pros { get; set; } |
| | 54 | |
|
| | 55 | | [BsonElement("list_comments_cons")] |
| 37 | 56 | | public IEnumerable<string> list_comments_cons { get; set; } |
| | 57 | |
|
| | 58 | | [BsonElement("views")] |
| 39 | 59 | | public long views { get; set; } |
| | 60 | |
|
| | 61 | | [BsonElement("filter")] |
| 37 | 62 | | public int filter { get; set; } |
| | 63 | |
|
| | 64 | | [BsonElement("likes")] |
| 39 | 65 | | public long likes { get; set; } |
| | 66 | |
|
| | 67 | | [BsonElement("favorite")] |
| 37 | 68 | | public bool favorite { get; set; } |
| | 69 | |
|
| | 70 | | [BsonElement("reference_url")] |
| 37 | 71 | | public string reference_url { get; set; } |
| | 72 | |
|
| | 73 | | [BsonElement("spotify_url")] |
| 37 | 74 | | public string spotify_url { get; set; } |
| | 75 | |
|
| | 76 | | [BsonElement("twitter_url")] |
| 37 | 77 | | public string twitter_url { get; set; } |
| | 78 | |
|
| | 79 | | [BsonElement("instagram_url")] |
| 37 | 80 | | public string instagram_url { get; set; } |
| | 81 | |
|
| | 82 | | [BsonElement("software")] |
| 37 | 83 | | public int software { get; set; } |
| | 84 | |
|
| | 85 | | [BsonElement("paper")] |
| 37 | 86 | | public int paper { get; set; } |
| | 87 | |
|
| | 88 | | [BsonElement("tags")] |
| 37 | 89 | | public IEnumerable<string>? tags { get; set; } |
| | 90 | |
|
| | 91 | | [BsonElement("score_critic")] |
| 37 | 92 | | public int score_critic { get; set; } |
| | 93 | |
|
| | 94 | | [BsonElement("score_popular")] |
| 40 | 95 | | public double score_popular { get; set; } |
| | 96 | |
|
| | 97 | | [BsonElement("votes_popular")] |
| 41 | 98 | | public int votes_popular { get; set; } |
| | 99 | |
|
| 0 | 100 | | public string GetId() => Id; |
| | 101 | |
|
| | 102 | | public override async Task<ReplaceOneResult> SetDocumentAsync(IMongoDatabase database, string collection, string doc |
| | 103 | | { |
| 0 | 104 | | var mongoCollection = database.GetCollection<DrawingMongoDocument>(collection); |
| | 105 | |
|
| 0 | 106 | | var filter = Builders<DrawingMongoDocument>.Filter.Eq(MongoDbDatabase.ID_FIELD, documentId); |
| 0 | 107 | | var options = new ReplaceOptions { IsUpsert = true }; |
| | 108 | |
|
| 0 | 109 | | return await mongoCollection.ReplaceOneAsync(filter, this, options); |
| 0 | 110 | | } |
| | 111 | | } |