예제 #1
0
        public async Task<ShareThing> VoteShare(string userId, string shareId)
        {
            var sId = new ObjectId(shareId);
            var shareThingCollection = Client.GetDatabase("Sharelink").GetCollection<ShareThing>("ShareThing");
            var newVote = new Vote()
            {
                UserId = new ObjectId(userId),
                VoteTime = DateTime.UtcNow
            };
            var update = new UpdateDefinitionBuilder<ShareThing>().Push(ts => ts.Votes, newVote);
            var result = await shareThingCollection.FindOneAndUpdateAsync(s => s.Id == sId, update);

            return result;
        }
예제 #2
0
 public ShareThing()
 {
     Votes = new Vote[0];
     Tags = new string[0];
 }