コード例 #1
0
        virtual public async Task AddBookReadingEntry(BookReading newBookReading)
        {
            var nextLastPriority = await LastPriority() + 1;

            newBookReading.priority = nextLastPriority;

            await Collection().InsertOneAsync(newBookReading);
        }
コード例 #2
0
        private async Task <int> LastPriority()
        {
            var options = new FindOptions <BookReading>
            {
                Limit = 1,
                Sort  = Builders <BookReading> .Sort.Descending(bookReadingEntry => bookReadingEntry.priority)
            };

            BookReading lastPriorityBookReading = (await Collection().FindAsync(FilterDefinition <BookReading> .Empty, options)).FirstOrDefault() ?? new BookReading();

            return(lastPriorityBookReading.priority);
        }