예제 #1
0
        public ActionResult EditPlayers(string rosterId)
        {
            Roster roster = DocumentSession
                            .Include <Roster>(r => r.Players)
                            .Load <Roster>(rosterId);

            if (roster == null)
            {
                throw new HttpException(404, "Roster not found");
            }

            var availablePlayers = DocumentSession.Query <Player, PlayerSearch>()
                                   .OrderBy(x => x.Name)
                                   .Where(p => p.PlayerStatus == Player.Status.Active)
                                   .ToList();

            var vm = new EditRosterPlayersViewModel
            {
                RosterViewModel  = DocumentSession.LoadRosterViewModel(roster),
                AvailablePlayers = availablePlayers.Select(x => new PlayerViewModel(x, WebsiteRoles.UserGroup().ToDict())).ToArray()
            };

            return(View(vm));
        }