コード例 #1
0
 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;
 }
コード例 #2
0
ファイル: Details.cshtml.cs プロジェクト: BelaMKD/Library1
 public IActionResult OnGet(int Id)
 {
     Author = authorInMemory.GetAuthor(Id);
     if (Author == null)
     {
         return(RedirectToPage("/Authors/List"));
     }
     return(Page());
 }
コード例 #3
0
ファイル: Edit.cshtml.cs プロジェクト: BelaMKD/Library1
 public void OnGet(int?id)
 {
     if (id.HasValue)
     {
         Author = authorInMemory.GetAuthor(id.Value);
     }
     else
     {
         Author = new Author();
     }
 }
コード例 #4
0
ファイル: Edit.cshtml.cs プロジェクト: BelaMKD/Library1
        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());
        }