public BookInMemory(IAuthorInMemory authorInMemory) { Books = new List <Book>() { new Book { Id = 1, Title = "Romeo and Juliet", NumberOfPages = 480, ImgPath = "romeo.jpg", Author = authorInMemory.GetAuthor(1) }, new Book { Id = 2, Title = "Murder on the orient express", NumberOfPages = 256, ImgPath = "murder.jpg", Author = authorInMemory.GetAuthor(2) }, new Book { Id = 3, Title = "A stone for Danny Fisher", NumberOfPages = 317, ImgPath = "stone.jpg", Author = authorInMemory.GetAuthor(3) } }; this.authorInMemory = authorInMemory; }
public IActionResult OnGet(int Id) { Author = authorInMemory.GetAuthor(Id); if (Author == null) { return(RedirectToPage("/Authors/List")); } return(Page()); }
public void OnGet(int?id) { if (id.HasValue) { Author = authorInMemory.GetAuthor(id.Value); } else { Author = new Author(); } }
public IActionResult OnGet(int?Id) { if (Id.HasValue) { Book = bookInMemory.GetBook(Id.Value); Author = authorInMemory.GetAuthor(Id.Value); if (Book == null) { return(RedirectToPage("/Books/ListBooks")); } } else { Book = new Book(); } FullNames = authorInMemory.GetAuthors().Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.FullName }).ToList(); return(Page()); }