public async Task <ActionResult> Create(MatchViewModel model) { try { if (!ModelState.IsValid) { ModelState.AddModelError("", "Create Match: Model state is invalid"); return(View()); } var match = _mapper.Map <Match>(model); var isSuccess = await _matchRepo.Create(match); if (!isSuccess) { ModelState.AddModelError("", "Create Match: Unable to Create a new match"); return(View(model)); } return(RedirectToAction(nameof(Index))); } catch { ModelState.AddModelError("", "Create Match: Something went wrong in the match creation"); return(View(model)); } }
public IActionResult GenerateMatch() { var result = _repositoryMatch.Create(); TempData.Put("resultMatch", result); return(RedirectToAction("LoadLastGroupWitchResult", "Group")); }
private async Task <Guid> CreateMatch(int warId, Contestant contestant1, Contestant contestant2, UserIdentifier userId) { var matchRequest = new MatchRequest { Contestant1 = contestant1.Id, Contestant2 = contestant2.Id, UserIdentifier = userId }; var matchId = await _matchRepository.Create(warId, matchRequest); return(matchId); }