// GET: AdminController/Edit/5 public ActionResult Edit(int id) { var book = BookStoreFunctions.GetFullBookById(id); ViewBag.GenreId = DropDownFormatter.FormatGenres(); ViewBag.AuthorId = DropDownFormatter.FormatAuthors(); return(View(book)); }
public IActionResult Books() { var bookList = BookStoreFunctions.GetAllBooksFull(); return(View(bookList)); }
public void getAllAuthorBooks() { var result = BookStoreFunctions.GetAllAuthorBooks("Polo"); Assert.True(result[0].BookTitle == "The Travels of Marco Polo"); }
public void getAllBooks() { var result = BookStoreFunctions.GetAllBooks(); Assert.True(result.Count == 2); }
public void getBookByTitleTest() { var result = BookStoreFunctions.GetBookByTitle("Canterbury Tales"); Assert.True(result.BookId == 2); }
// GET: AdminController/Delete/5 public ActionResult Delete(int id) { var book = BookStoreFunctions.GetFullBookById(id); return(View(book)); }
public static SelectList FormatGenres() { return(new SelectList(BookStoreFunctions.GetAllGenres() .OrderBy(g => g.GenreType) .ToDictionary(g => g.GenreId, g => g.GenreType), "Key", "Value")); }
public static SelectList FormatAuthors() { return(new SelectList(BookStoreFunctions.GetAllAuthors() .OrderBy(a => a.AuthorLast) .ToDictionary(a => a.AuthorId, a => a.AuthorLast + ", " + a.AuthorFirst), "Key", "Value")); }
public static void AreArguementsValid(string[] args) { var ohTypeTemp = args[1].ToLower(); var findByTemp = args[2].ToLower(); if (ohTypeTemp == "csv" || ohTypeTemp == "console") { ohType = ohTypeTemp; if (findByTemp == "title" || findByTemp == "author" || findByTemp == "all") { findBy = findByTemp; switch (findBy) { case "title": { var title = args.ToList(); title.RemoveRange(0, 3); var titleStr = string.Join(" ", title.ToArray()); Console.WriteLine(titleStr); if (titleStr == "The Travels of Marco Polo" || titleStr == "Canterbury Tales") { book = BookStoreFunctions.GetBookByTitle(titleStr); } else { Console.WriteLine("The Travels of Marco Polo or Canterbury Tales"); } break; } case "author": { var author = args[3].ToLower(); if (author == "polo" || author == "chaucer") { books = BookStoreFunctions.GetAllAuthorBooks(author); } else { Console.WriteLine("Polo or Chaucer"); } break; } case "all": { books = BookStoreFunctions.GetAllBooks(); break; } } } else { Console.WriteLine("Search by all, title, or author"); } } else { Console.WriteLine("Recieve books by Console or Csv"); } }