//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()); }
public IActionResult Remove(int[] removedComics) { foreach (int comicId in removedComics) { ComicsData.RemoveById(comicId); } return(Redirect("/Comics")); }
//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(); }
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 }); } }
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)); }
public IActionResult Index() { ViewBag.comics = ComicsData.GetAll(); return(View()); }
public IActionResult Add(Comic comic) { ComicsData.Add(comic); return(Redirect("/Comics")); }