public ActionResult Delete4x4(Match4x4ViewModel.MatchDetails vm) { var match = DocumentSession.Load<Match4x4>(vm.Id); if (match == null) throw new HttpException(404, "Match not found"); DocumentSession.Delete(match); return RedirectToAction("Index"); }
/// <summary> /// GET: /Match/Details4x4/5. /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Details4x4(int id) { var match = DocumentSession.Load<Match4x4>(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 Match4x4ViewModel { Match = match.MapTo<Match4x4ViewModel.MatchDetails>(), HomeTeam = match.HomeTeam.MapTo<Team4x4DetailsViewModel>(), HomeTeamResults = results.Where(r => r.Team == match.HomeTeam.Name).ToList(), AwayTeam = match.AwayTeam.MapTo<Team4x4DetailsViewModel>(), AwayTeamResults = results.Where(r => r.Team == match.AwayTeam.Name).ToList(), }; return View(vm); }
public ActionResult EditDetails4x4(Match4x4ViewModel.MatchDetails model) { if (!ModelState.IsValid) return View(model); var match = DocumentSession.Load<Match4x4>(model.Id); if (match == null) throw new HttpException(404, "Match not found"); match.Location = model.Location; match.Date = model.Date; return RedirectToAction("Details4x4", new { id = match.Id }); }