コード例 #1
0
ファイル: BookDataService.cs プロジェクト: MDauy/SuggeBook
        public async Task <bool> Update(ObjectId id, Dao.Book book)
        {
            var result = await BooksCollection.ReplaceOneAsync <Book>(b => b.Id == id, book);

            if (result.IsModifiedCountAvailable && result.ModifiedCount == 1)
            {
                return(true);
            }
            else
            {
                throw new Exception(string.Format("Update with book {0} went wrong : maybe not found or two many suggestions with same id", id));
            }
        }
コード例 #2
0
ファイル: BookDataService.cs プロジェクト: MDauy/SuggeBook
        public async Task <Dao.Book> Create(Dao.Book book)
        {
            await BooksCollection.InsertOneAsync(book);

            return(book);
        }