Пример #1
0
        public ActionResult Delete8x4(Match8x4ViewModel.MatchDetails vm)
        {
            var match = DocumentSession.Load<Match8x4>(vm.Id);
            if (match == null)
                throw new HttpException(404, "Match not found");

            DocumentSession.Delete(match);

            return RedirectToAction("Index");
        }
Пример #2
0
        public ActionResult EditDetails8x4(Match8x4ViewModel.MatchDetails model)
        {
            if (!ModelState.IsValid)
                return View(model);

            var match = DocumentSession.Load<Match8x4>(model.Id);
            if (match == null)
                throw new HttpException(404, "Match not found");

            match.Location = model.Location;
            match.Date = model.Date;
            match.BitsMatchId = model.BitsMatchId;

            return RedirectToAction("Details8x4", new { id = match.Id });
        }
Пример #3
0
        /// <summary>
        /// GET: /Match/Details8x4/5.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Details8x4(int id)
        {
            var match = DocumentSession.Load<Match8x4>(id);
            if (match == null)
                throw new HttpException(404, "Match not found");

            var matchId = DocumentSession.Advanced.GetDocumentId(match);
            var results = DocumentSession.Query<Player_ByMatch.Result, Player_ByMatch>()
                .Customize(x => x.WaitForNonStaleResultsAsOfNow())
                .Where(x => x.MatchId == matchId)
                .OrderByDescending(x => x.Pins);

            var vm = new Match8x4ViewModel
            {
                Match = match.MapTo<Match8x4ViewModel.MatchDetails>(),
                HomeTeam = match.HomeTeam.MapTo<Team8x4DetailsViewModel>(),
                HomeTeamResults = results.Where(g => g.Team == match.HomeTeam.Name).ToList(),
                AwayTeam = match.AwayTeam.MapTo<Team8x4DetailsViewModel>(),
                AwayTeamResults = results.Where(g => g.Team == match.AwayTeam.Name).ToList(),
            };

            return View(vm);
        }