コード例 #1
0
        public void Update(BookEntity book)
        {
            var entity = _books.First(x => x.Id == book.Id);

            _books.Remove(entity);
            _books.Add(book);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var csharp1Book = new BookEntity("C# 1", "Writer")
            {
                Id = 1
            };
            var csharp2Book = new BookEntity("C# 2", "Blogger")
            {
                Id = 2
            };
            var csharp3Book = new BookEntity("C# 3", "Writer")
            {
                Id = 3
            };

            var repository = new BookMemoryRepository();

            repository.Insert(csharp1Book);
            repository.Insert(csharp2Book);
            repository.Insert(csharp3Book);


            var book = repository.FindById(1);

            Console.WriteLine($"{book.Title}");


            //You can having fun here

            //
            Console.ReadKey();
        }
コード例 #3
0
        public int Add(BookEntity book)
        {
            int nextId = 0;

            if (_books.Any())
            {
                nextId  = _books.Max(x => x.Id);
                book.Id = ++nextId;
            }

            _books.Add(book);

            return(book.Id);
        }
コード例 #4
0
ファイル: BookRepository.cs プロジェクト: olegtroff/kaspersky
 public async Task DeleteById(string id)
 {
     await _bookTablestorage.DeleteAsync(BookEntity.GeneratePartitionKey(), id);
 }
コード例 #5
0
ファイル: BookRepository.cs プロジェクト: olegtroff/kaspersky
 public async Task <IEnumerable <IBook> > GetList()
 {
     return(await _bookTablestorage.GetDataAsync(BookEntity.GeneratePartitionKey()));
 }
コード例 #6
0
ファイル: BookRepository.cs プロジェクト: olegtroff/kaspersky
 public async Task InsertAsync(IBook book)
 {
     await _bookTablestorage.InsertOrMergeAsync(BookEntity.Create(book));
 }
コード例 #7
0
ファイル: BookRepository.cs プロジェクト: olegtroff/kaspersky
        public async Task <Book> GetByIdAsync(string id)
        {
            var src = await _bookTablestorage.GetDataAsync(BookEntity.GeneratePartitionKey(), id);

            return(Book.Create(src));
        }