Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- routes.MapRoute(
- name: "Fantasy League Matchups",
- url: "Fantasy/{leagueID}/{leagueSlug}/Matchups/{round}",
- defaults: new { controller = "Fantasy", action = "Matchups", leagueSlug = UrlParameter.Optional, round = UrlParameter.Optional },
- constraints: new { leagueID = @"d+" }
- );
- routes.MapRoute(
- name: "Fantasy League Settings",
- url: "Fantasy/{leagueID}/{leagueSlug}/Settings",
- defaults: new { controller = "Fantasy", action = "Settings", leagueSlug = UrlParameter.Optional },
- constraints: new { leagueID = @"d+" }
- );
- // GET: /Fantasy/{leagueID}/{leagueSlug}/Matchups/{round}
- public ActionResult Matchups(int leagueID, string leagueSlug = null, int round = -1) {
- var fantasyLeague = DataContext.FantasyLeagues.Where(l => l.ID == leagueID).FirstOrDefault();
- if (fantasyLeague != null) {
- if (string.IsNullOrEmpty(leagueSlug) || round == -1) {
- return RedirectToActionPermanent("Matchups", "Fantasy", new { leagueID = leagueID, leagueSlug = fantasyLeague.Slug, round = fantasyLeague.CurrentRound });
- }
- var userInLeague = User != null && User.Identity != null && fantasyLeague.FantasyTeams.Any(t => t.Owner.UserName == User.Identity.Name);
- var fantasyMatches = fantasyLeague.FantasyMatches.Where(fm => fm.Round == round).ToList();
- return View("Matchups", new FantasyMatchupsViewModel {
- FantasyLeague = fantasyLeague,
- FantasyMatches = fantasyMatches,
- Round = round,
- UserInLeague = userInLeague
- });
- }
- return RedirectToAction("Index");
- }
- // GET: /Fantasy/{leagueID}/{leagueSlug}/Settings
- public ActionResult Settings(int leagueID, string leagueSlug = null) {
- var fantasyLeague = DataContext.FantasyLeagues.Where(l => l.ID == leagueID).FirstOrDefault();
- if (fantasyLeague != null) {
- if (string.IsNullOrEmpty(leagueSlug)) {
- return RedirectToActionPermanent("Settings", "Fantasy", new { leagueID = leagueID, leagueSlug = fantasyLeague.Slug });
- }
- var userOwnsLeague = User != null && User.Identity != null && fantasyLeague.Commissioner.UserName == User.Identity.Name;
- return View("Settings", new FantasySettingsViewModel {
- FantasyLeague = fantasyLeague,
- UserOwnsLeague = userOwnsLeague,
- Name = fantasyLeague.Name,
- MaxPlayers = fantasyLeague.MaxPlayers,
- LockoutPeriod = fantasyLeague.LockoutPeriod,
- PasswordProtected = fantasyLeague.PasswordProtected,
- Password = fantasyLeague.Password
- });
- }
- return RedirectToAction("Index");
- }
Add Comment
Please, Sign In to add comment