Пример #1
0
 //private static List<Comic> comics = new List<Comic>();
 //make ComicsData.cs file and then past "private static List<Comic> comics = new List<Comic>();"
 public IActionResult Index()
 {
     // ViewBag.comics = comics;
     ViewBag.comics = ComicsData.GetAll();
     //something reall example
     return(View());
 }
Пример #2
0
 public IActionResult Remove(int[] removedComics)
 {
     foreach (int comicId in removedComics)
     {
         ComicsData.RemoveById(comicId);
     }
     return(Redirect("/Comics"));
 }
Пример #3
0
 //public IActionResult Add(string title, int issueNumber)
 //Action handler more property
 public IActionResult Add(Comic comic)
 {
     // var comic = new Comic(title, issueNumber);
     //comics.Add(comic); after making ComicData block this
     ComicsData.Add(comic);//Action handler
     return(Redirect("/Comics"));
     //redirecct is easy to handle route more than View() -oj
     //ViewBag.comics = comics;
     //retrun View();
 }
Пример #4
0
 public AddComicViewModel()
 {
     // Use the Grade objects to create the SelectListItem objects
     foreach (Grade grade in ComicsData.GetAllGrades())
     {
         string idString = grade.GradeId.ToString();
         this.SelectItems.Add(new SelectListItem()
         {
             Value = idString, Text = grade.Name
         });
     }
 }
Пример #5
0
 public IActionResult Add(AddComicViewModel comicViewModel)
 {
     if (ModelState.IsValid)
     {
         Comic comic = new Comic(comicViewModel.Title, comicViewModel.IssueNumber);
         comic.Grade = ComicsData.GetGradeById(comicViewModel.GradeId.Value);
         ComicsData.Add(comic);
         //return RedirectToAction("Index", new { name = "blake" });
         return(Redirect("/Comics"));
     }
     // Bad news, stuff is not right
     // Stay, so the user can finish form
     return(View(comicViewModel));
 }
Пример #6
0
 public IActionResult Index()
 {
     ViewBag.comics = ComicsData.GetAll();
     return(View());
 }
Пример #7
0
 public IActionResult Add(Comic comic)
 {
     ComicsData.Add(comic);
     return(Redirect("/Comics"));
 }