示例#1
0
        public async Task <bool> AddPhoto(PhotoUser photo)
        {
            try
            {
                await _context.GetCollection <PhotoUser>(COLLECTION_NAME)
                .InsertOneAsync(photo);

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#2
0
        public async Task <bool> UpdatePhoto(string id, PhotoUser photo)
        {
            try
            {
                var filter = Builders <PhotoUser> .Filter
                             .Eq("Id", id);

                var update = Builders <PhotoUser> .Update
                             .Set(photo => photo.URI, photo.URI);

                UpdateResult updateResult = await _context.GetCollection <PhotoUser>(COLLECTION_NAME)
                                            .UpdateOneAsync(filter, update);

                return(updateResult.IsAcknowledged && updateResult.MatchedCount > 0);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }