public ActionResult EditResult(int id, RegisterResult registerResult) { if (registerResult == null) throw new ArgumentNullException("registerResult"); if (!ModelState.IsValid) return EditResult(id); var matchResult = EventStoreSession.Load<MatchResult>(registerResult.AggregateId); if (matchResult == null) throw new HttpException(404, "Match result not found"); matchResult.Update( DocumentSession.Load<Roster>(registerResult.RosterId), registerResult.TeamScore.GetValueOrDefault(), registerResult.OpponentScore.GetValueOrDefault(), registerResult.BitsMatchId.GetValueOrDefault()); return RedirectToAction("Index", "MatchResult"); }
public ActionResult RegisterConfirmed(int? season, RegisterResult vm) { if (ModelState.IsValid == false) return Register(season); var roster = DocumentSession.Load<Roster>(vm.RosterId); if (roster == null) throw new HttpException(404, "Roster not found"); var matchResult = new MatchResult( roster, vm.TeamScore.GetValueOrDefault(), vm.OpponentScore.GetValueOrDefault(), vm.BitsMatchId.GetValueOrDefault()); EventStoreSession.Store(matchResult); return RedirectToAction( "RegisterSerie", new { aggregateId = matchResult.Id, vm.RosterId, vm.BitsMatchId }); }