public IActionResult Details(UserRosterViewModel model) { var rosters = this.rostersService .GetAllUserRosters(User.Identity.Name); if (!rosters.Any()) { return(RedirectToAction( ActionConstants.Index, PagesConstants.Rosters)); } var rostersWeeks = rosters.Where(x => x.Matchday.Status < MatchdayStatus.Upcoming) .Select(x => x.Matchday.Week) .OrderBy(x => x).ToArray(); var roster = rosters.FirstOrDefault(x => x.Matchday.Week == model.MarchdayWeek); var user = this.usersService .GetUserByUsername <UserViewModel>(User.Identity.Name); var indexRosterViewModel = new UserRosterViewModel { MarchdayWeek = model.MarchdayWeek, RostersWeeks = rostersWeeks, ClubName = user.ClubName, Roster = roster }; return(View(indexRosterViewModel)); }
public async Task <IActionResult> Edit(UserRosterViewModel model) { var formation = model.Roster.Formation; var matchday = this.matchdaysService .GetCurrentMatchday <Matchday>(); var roster = this.rostersService .GetCurrentUserRoster(User.Identity.Name); var result = await this.rostersService .SetNewFormationAsync(formation, roster.Id); if (!result.Succeeded) { return(RedirectToAction( ActionConstants.Error, PagesConstants.Home, new { area = "", errorMessage = result.Error })); } var editRosterModel = new EditRosterViewModel { Formation = formation, Matchday = roster.Matchday, Goalkeepers = roster.Players.Where(x => x.Position == PlayerPosition.Goalkeeper).ToList(), Attackers = roster.Players.Where(x => x.Position == PlayerPosition.Attacker).ToList(), Midfielders = roster.Players.Where(x => x.Position == PlayerPosition.Midfielder).ToList(), Defenders = roster.Players.Where(x => x.Position == PlayerPosition.Defender).ToList() }; return(View(editRosterModel)); }
public IActionResult Index() { var currentMatchday = this.matchdaysService .GetCurrentMatchday <MatchdayViewModel>(); var currentRoster = this.rostersService .GetCurrentUserRoster(User.Identity.Name); var rosters = this.rostersService .GetAllUserRosters(User.Identity.Name); var rostersWeeks = rosters.Where(x => x.Matchday.Status < MatchdayStatus.Upcoming) .Select(x => x.Matchday.Week) .OrderBy(x => x).ToArray(); var user = this.usersService .GetUserByUsername <User>(User.Identity.Name); var indexRosterViewModel = new UserRosterViewModel { MarchdayWeek = currentMatchday.Week, RostersWeeks = rostersWeeks, TransferWindowStatus = currentMatchday.TransferWindowStatus, ClubName = user.ClubName, Roster = currentRoster }; return(View(indexRosterViewModel)); }