Ejemplo n.º 1
0
        public ActionResult Index()
        {
            var modelList = new List <TableIndexViewModel>();
            var tables    = _db.Tables.ToList();

            foreach (var table in tables)
            {
                var model = new TableIndexViewModel
                {
                    Id           = table.Id,
                    Location     = table.Location,
                    Name         = table.Name,
                    MatchOngoing = MatchService.HasOngoingMatch(_db, table),
                    SideOneColor = table.SideOneColor,
                    SideTwoColor = table.SideTwoColor
                };
                var ongoingMatch = model.MatchOngoing ? MatchService.GetOngoingMatch(_db, table) : null;

                if (ongoingMatch != null)
                {
                    model.SideOneScore    = ongoingMatch.Goals.Count(g => g.Side == TableSide.Red);
                    model.SideTwoScore    = ongoingMatch.Goals.Count(g => g.Side == TableSide.Blue);
                    model.OngoingMatchId  = ongoingMatch.Id;
                    model.SideOneTeamName = ongoingMatch.RedTeam.GetNameOrDefault();
                    model.SideTwoTeamName = ongoingMatch.BlueTeam.GetNameOrDefault();
                }

                modelList.Add(model);
            }
            return(View(modelList));
        }
Ejemplo n.º 2
0
        // GET: Table
        public ActionResult Index()
        {
            FindAllTableQueryResult result = Query.For <FindAllTableQueryResult>().With(new EmptyCriterion());

            TableIndexViewModel vm = new TableIndexViewModel
            {
                ActiveTables  = result.ActiveTables.Select(ToViewModel),
                DeletedTables = result.DeletedTables.Select(ToViewModel)
            };

            return(View(vm));
        }
        public IActionResult Index(int?businessID)
        {
            if (businessID == null || !businessID.HasValue)
            {
                return(NotFound());
            }
            _tableManager.UpdateTablesAvailability(businessID.Value);
            var indexVM = new TableIndexViewModel
            {
                Business = _businessManager.GetBusiness(businessID.Value),
                Tables   = _tableManager.GetTables(businessID.Value)
            };

            return(View(indexVM));
        }