private VMBooks GetClone(VMBooks book) { return(new VMBooks() { Author = book.Author, Book = book.Book }); }
/// <summary> /// Initializes a new instance of the MainViewModel class. Initializes DataFields /// </summary> public MainViewModel(IDataService dataService) { _book = new VMBooks(); Books = dataService.GetBooks(); _index = 0; _dataService = dataService; Add = new RelayCommand(() => { var add = GetClone(_book); Books.Add(add); _dataService.AddBook(add); }); Remove = new RelayCommand(() => { if (_index < Books.Count && _index >= 0) { _dataService.RemoveBook(Books[Index]); Books.RemoveAt(Index); } }); Modify = new RelayCommand(() => { GetClone(Book, Books[Index]); _dataService.ModifyBook(Books[Index]); }); }
public void AddBook(VMBooks book) { var b = Mapper.Map <TEntity>(book); Entities.Add(b); _dataBase.SaveChanges(); book.ID = b.ID; }
public void ModifyBook(VMBooks book) { var b = Entities.Find(book.ID); b.Author = book.Author; b.Book = book.Book; _dataBase.SaveChanges(); book.ID = b.ID; }
public void RemoveBook(VMBooks book) { Entities.Remove(Entities.Find(book.ID)); _dataBase.SaveChanges(); }
public void ModifyBook(VMBooks book) { throw new NotImplementedException(); }
public void RemoveBook(VMBooks book) { throw new NotImplementedException(); }
private void GetClone(VMBooks from, VMBooks to) { to.Book = from.Book; to.Author = from.Author; }