public IActionResult Edit(int id, Franchise franchise) { if (id != franchise.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _franchises.Update(franchise); } catch (DbUpdateConcurrencyException) { if (!FranchiseExists(franchise.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["LeagueId"] = new SelectList(_leagues.GetAll(), "Id", "Name", franchise.LeagueId); // ViewData["OwnerId"] = new SelectList(_franchises.Owners, "Id", "Email", franchise.OwnerId); return(View(franchise)); }
public IActionResult Index() { var leagues = _leagueService.GetAll() .OrderByDescending(league => league.LeagueName) .Select(c => new LeagueListingModel { LeagueName = c.LeagueName, LeagueImageUrl = c.LeagueImageUrl, CountryId = c.CountryId }); var model = new LeagueIndexModel { LeagueList = leagues }; return(View(model)); }