public void Update(BookEntity book) { var entity = _books.First(x => x.Id == book.Id); _books.Remove(entity); _books.Add(book); }
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(); }
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); }
public async Task DeleteById(string id) { await _bookTablestorage.DeleteAsync(BookEntity.GeneratePartitionKey(), id); }
public async Task <IEnumerable <IBook> > GetList() { return(await _bookTablestorage.GetDataAsync(BookEntity.GeneratePartitionKey())); }
public async Task InsertAsync(IBook book) { await _bookTablestorage.InsertOrMergeAsync(BookEntity.Create(book)); }
public async Task <Book> GetByIdAsync(string id) { var src = await _bookTablestorage.GetDataAsync(BookEntity.GeneratePartitionKey(), id); return(Book.Create(src)); }