public ActionResult AddMatch(AddMatchViewModel addMatchViewModel) { if (ModelState.IsValid) { var match = new Match() { Id = Guid.NewGuid(), AwayCoefficient = addMatchViewModel.AwayCoefficient, AwayGoals = 0, AwayTeam = addMatchViewModel.AwayTeam, Date = addMatchViewModel.Date, DrawCoefficient = addMatchViewModel.DrawCoefficient, HomeCoefficient = addMatchViewModel.HomeCoefficient, HomeGoals = 0, HomeTeam = addMatchViewModel.HomeTeam, IsOpen = true, PlayedFrom = 0, SuccessMatch = 0, SuccessResult = 0, ChampionshipId = addMatchViewModel.ChampionshipId, PlayedFor1 = 0, PlayedFor2 = 0, PlayedForX = 0 }; this.matchService.Add(match); return(this.View("index")); } return(this.View(addMatchViewModel)); }
public async Task <Match> Create(AddMatchViewModel model) { var tournament = await _dbContext.Tournaments.Include(t => t.Gamblers).FirstOrDefaultAsync(t => t.Rounds.Any(r => r.Id == model.RoundId)); var match = await _dbContext.Matches.FirstOrDefaultAsync(t => t.TeamAName.Equals(model.TeamAName, StringComparison.InvariantCultureIgnoreCase) && t.TeamBName.Equals(model.TeamBName, StringComparison.InvariantCultureIgnoreCase) && t.RoundId == model.RoundId); if (match == null) { match = new Match { TeamAName = model.TeamAName, TeamBName = model.TeamBName, TeamAScore = model.TeamAScore, TeamBScore = model.TeamBScore, RoundId = model.RoundId }; await _dbContext.Matches.AddAsync(match); await _dbContext.SaveChangesAsync(); var activeGamblers = tournament.Gamblers.Where(g => g.IsActive); foreach (var gambler in activeGamblers) { await _matchBetService.AddOrUpdateGamblerMatchBets(tournament.Id, gambler.GamblerId); } } return(match); }
public ActionResult AddMatch(int stadiumId, DateTime date) { var model = new AddMatchViewModel() { AvailableTimes = _scheduleService.GetAvailableTimesForNewMatch(stadiumId, date), Date = date, StadiumId = stadiumId }; return(View(model)); }
public ActionResult AddMatch() { var teams = this.teamService.GetAll().ToList(); var championships = this.championshipService.GetAll(); List <SelectListItem> teamsResult = new List <SelectListItem>(); List <SelectListItem> championshipsResult = new List <SelectListItem>(); var dictionary = new Dictionary <string, SelectListGroup>(); foreach (var championship in championships) { championshipsResult.Add(new SelectListItem() { Text = championship.Name, Value = championship.Id.ToString() }); dictionary.Add(championship.Name, new SelectListGroup() { Name = championship.Name }); } foreach (var team in teams) { var name = this.championshipService.GetNameById(team.ChampionshipId); teamsResult.Add(new SelectListItem() { Text = team.Name, Value = team.Id.ToString(), Group = dictionary[name] }); } var viewModel = new AddMatchViewModel() { Teams = teamsResult, Championships = championshipsResult }; return(this.View(viewModel)); }
public IHttpActionResult Add(AddMatchViewModel model) { var match = this.data.Matches.All().Where(x => !x.IsDeleted) .FirstOrDefault( x => x.JobSeekerProfileId == model.JobSeekerProfileId && x.RecruiterProfileId == model.RecruiterProfileId); if (match == null) { match = new Match() { JobSeekerProfileId = model.JobSeekerProfileId, RecruiterProfileId = model.RecruiterProfileId }; } this.data.Matches.Add(match); this.data.SaveChanges(); return this.Ok(match); }
public AddMatchPage(ObservableRangeCollection <LeaderboardViewEntry> viewModelAddedPlayers) { InitializeComponent(); BindingContext = _viewModel = new AddMatchViewModel(viewModelAddedPlayers); }
public async Task <IActionResult> Post([FromBody] AddMatchViewModel model) { var round = await _matchService.Create(model); return(Json(round.Id)); }