//public ActionResult Create([ModelBinder(typeof(MatchBinder))]Match match) public ActionResult Create(int boardId, MatchViewModel match) { try { if (ModelState.IsValid) { _service.CreateMatch(boardId, HttpContext.User.Identity.Name, match.Loser, match.WinnerComment, match.Tie); } } catch (ServiceException ex) { ModelState.AddModelError("", ex.Message); return View(new MatchViewModel { Board = _repository.GetBoardByIdWithCompetitors(boardId), Loser = match.Loser, WinnerComment = match.WinnerComment, Tie = match.Tie }); } TempData["StatusMessage"] = "Your match has been successfully reported."; return RedirectToAction("List", new { boardId }); }
public ActionResult Validate(int boardId, MatchViewModel match) //public ActionResult Validate([ModelBinder(typeof(MatchBinder))]Match match) { var response = new JsonResponse<Match>(); try { response.Result = _service.GenerateMatch(boardId, HttpContext.User.Identity.Name, match.Loser, match.Tie); response.Result.WinnerComment = match.WinnerComment; } catch (ServiceException ex) { response.Message = ex.Message; response.Error = true; } return (Json(response)); }