//This method creates new BoardsViewModel which contains all boards public BoardsViewModel GetBoardsViewModel() { var boards = this.boardsRepository.GetBoards(); var viewModel = new BoardsViewModel(boards); return(viewModel); }
public override void OnActionExecuting(ActionExecutingContext context) { ViewData["SenderName"] = "Анонимус"; ViewData["BoardsViewModel"] = new BoardsViewModel(); base.OnActionExecuting(context); }
public async Task <IActionResult> Index() { var boards = await _boardsRepository.GetBoardsAsync(); var viewModel = new BoardsViewModel { Boards = boards }; return(View(viewModel)); }
public ActionResult Index() { ViewBag.BoardName = "PlanningBoard.Net"; var user = _userRerpository.GetUser(Username); var boards = _boardRepository.List(user.Id); var boardUsers = _boardRepository.BoardUsers(user.Id); var userboards = boards.Select(board => new UserBoardsViewModel() { BoardId = board.Id, BoardName = board.Name, IsAdmin = boardUsers.Any(b => b.BoardId == board.Id && b.IsAdmin) }).ToList(); var model = new BoardsViewModel { Boards = userboards }; return(View(model)); }
// GET: Brackets/Results/5 public async Task <IActionResult> Results(int?id) { if (id == null) { return(NotFound()); } var bracket = await _context.Brackets .Include(b => b.BingoBoards) .ThenInclude(b => b.Bingos) .ThenInclude(b => b.Round) .Include(b => b.BingoBoards) .ThenInclude(b => b.BoardPieces) .ThenInclude(b => b.Contender) .ThenInclude(b => b.Entrant) .Include(b => b.Rounds) .ThenInclude(r => r.RoundContenders) .ThenInclude(r => r.Contender) .ThenInclude(r => r.Entrant) .AsNoTracking() .SingleOrDefaultAsync(m => m.BracketID == id); if (bracket == null) { return(NotFound()); } int firstBingoRound = int.MaxValue; int lastBingoRound = 0; bool noBingo = false; foreach (var board in bracket.BingoBoards) { board.Bingos = board.Bingos.OrderBy(b => b.Round.RoundNumber).ToList(); if (board.Bingos.Count == 0) { noBingo = true; } else { var bingoRound = board.Bingos.First().Round.RoundNumber; if (bingoRound < firstBingoRound) { firstBingoRound = bingoRound; } if (bingoRound > lastBingoRound) { lastBingoRound = bingoRound; } } } var boardsViewModel = new BoardsViewModel(); boardsViewModel.Bracket = bracket; boardsViewModel.FirstBingos = await GetBingosByRound(bracket.BracketID, firstBingoRound); if (noBingo == false) { boardsViewModel.LastBingos = await GetBingosByRound(bracket.BracketID, lastBingoRound); } if (boardsViewModel.LastBingos != null) { for (int i = 0; i < boardsViewModel.FirstBingos.Count; i++) { var boardId = boardsViewModel.FirstBingos[i].BingoBoardId; for (int j = boardsViewModel.LastBingos.Count - 1; j >= 0; j--) { if (boardsViewModel.LastBingos[j].BingoBoardId == boardId) { boardsViewModel.LastBingos.RemoveAt(j); } } } } var firstRoundElimination = int.MaxValue; foreach (var board in bracket.BingoBoards) { board.BoardPieces = board.BoardPieces.OrderBy(b => b.BoardPosition).ToList(); if (board.RoundEliminated != -1 && board.RoundEliminated < firstRoundElimination) { firstRoundElimination = board.RoundEliminated; } } var firstElims = from b in bracket.BingoBoards where b.RoundEliminated == firstRoundElimination select b.Title; boardsViewModel.FirstElimination = new FirstEliminationViewModel { BracketTitles = firstElims.ToList(), RoundNumber = firstRoundElimination }; boardsViewModel.CurrentRound = bracket.Rounds.Count == 0 ? -1 : bracket.Rounds.Max(r => r.RoundNumber); for (var i = boardsViewModel.CurrentRound; i >= 0; i--) { var round = bracket.Rounds.Single(r => r.RoundNumber == i); if (round.RoundContenders.Count > 0) { List <Entrant> entrants = new List <Entrant>(); foreach (var roundContender in round.RoundContenders) { entrants.Add(roundContender.Contender.Entrant); } boardsViewModel.LastContenders = entrants; break; } } return(View(boardsViewModel)); }