public static ClassicBookViewModel ToClassicModel(this ClassicBook x) { return(new ClassicBookViewModel { Id = x.Id, Title = x.Title, Author = x.Author, Amount = x.Amount, NumberOfPages = x.NumberOfPages, Price = x.Price, Town = x.Town }); }
static void Main(string[] args) { Library library = new Library(); ClassicReaders classic = new ClassicReaders(); TechReaders tech = new TechReaders(); Book book1 = new TecnicalBook { Name = "Programming", Genre = "Technical" }; Book book2 = new ClassicBook { Name = "War and Peace", Genre = "Classica" }; library.NotifyReaders(book1); library.AddReader(classic); library.AddReader(tech); library.NotifyReaders(book2); }
public void Create(CreateBookViewModel model) { if (!string.IsNullOrEmpty(model.Planet)) { var newBook = new FantasyBook() { Title = model.Title, Author = model.Author, Amount = model.Amount, NumberOfPages = model.NumberOfPages, Price = model.Price, Planet = model.Planet }; bookRepo.AddFantasy(newBook); } else if (!string.IsNullOrEmpty(model.Town)) { var newBook = new ClassicBook() { Title = model.Title, Author = model.Author, Amount = model.Amount, NumberOfPages = model.NumberOfPages, Price = model.Price, Town = model.Town }; bookRepo.AddClassic(newBook); } else { var newBook = new HistoryBook() { Title = model.Title, Author = model.Author, Amount = model.Amount, NumberOfPages = model.NumberOfPages, Price = model.Price, //Year = model.Year }; bookRepo.AddHistory(newBook); } }
public void AddClassic(ClassicBook newBook) { context.ClassicBooks.Add(newBook); context.SaveChanges(); }
public void UpdateClassicBook(ClassicBook dbBook) { context.ClassicBooks.Update(dbBook); context.SaveChanges(); }