Esempio n. 1
0
        // GET: Home
        public ActionResult Index()
        {
            ViewBag.Title = "Upcoming Races";

            using (var context = new Context())
            {
                var raceList = new RaceListViewModel
                {
                    Races = context.Races.Select(p => new RaceViewModel
                    {
                        Id           = p.Id,
                        Name         = p.Name,
                        Profit       = p.Profit,
                        Address      = p.Address,
                        City         = p.City,
                        Date         = p.Date,
                        StateId      = p.StateId,
                        StateName    = p.State.Name,
                        StateAcronym = p.State.Acronym,
                        RaceTypeName = p.RaceType.Name,
                        RaceTypeId   = p.RaceTypeId
                    }).ToList()
                };
                raceList.TotalRaces = raceList.Races.Count;

                return(View("Index", raceList));
            }
        }
Esempio n. 2
0
        public ViewResult List()
        {
            IEnumerable <Race> races = _allRaces.Races.OrderBy(x => x.Id);

            var raceObj = new RaceListViewModel
            {
                AllRaces = races
            };

            ViewData["Title"] = "Расы";

            return(View(raceObj));
        }