private void buildCompetitions(S_User user) { List <S_Competition> competitions = CompetitionManager.GetCompetitionsByPlayer(user.id); _competitions = "<div class='col-lg-8 col-lg-offset-2'>"; _competitions += " <h2>Jouw Competities</h2>"; if (competitions.Count() > 0) { foreach (S_Competition competition in competitions) { S_Challenge challenge = ChallengeManager.GetChallenge(competition.challengeid); List <S_CompetitonBowlingcenter> competitonBowlingcenters = CompetitionManager.GetBowlingcentersByCompetition(competition.id); _competitions += " <h3>" + challenge.name + "</h3>"; _competitions += " <p> Van " + competition.startdate.ToString("dd-MM-yyyy") + " tot " + competition.enddate.ToString("dd-MM-yyyy") + " bij de volgende bowlingcentra: "; foreach (S_CompetitonBowlingcenter competitonBowlingcenter in competitonBowlingcenters) { S_BowlingCenter bowlingCenter = BowlingCenterManager.GetBowlingCenterById(competitonBowlingcenter.bowlingcenterid); _competitions += "<br/><br/>" + bowlingCenter.name; } _competitions += "</p>"; } } else { _competitions += " <p>Je doet nog niet mee aan een competitie</p>"; } _competitions += "</div>"; }
public ActionResult Edit(long id) { S_Competition competition = CompetitionManager.GetCompetition(id); CompetitionModel competitionModel = new CompetitionModel(); competitionModel.Id = competition.id; competitionModel.challengeId = competition.challengeid; competitionModel.challenge = ChallengeManager.GetChallenge(competition.challengeid).name; competitionModel.description = competition.description; competitionModel.StartDate = competition.startdate; competitionModel.EndDate = competition.enddate; competitionModel.price = competition.price; List <S_BowlingCenter> bcl = BowlingCenterManager.GetBowlingCenters(); List <S_CompetitonBowlingcenter> cbcl = CompetitionManager.GetBowlingcentersByCompetition(competition.id); competitionModel.AllBowlingCentersChecked = bcl.Count == cbcl.Count; //var selectedBowlingCenters = CheckboxManager.GetAll() // .Where(x => cbcl.Any(s => x.Id.ToString().Equals(s.bowlingcenterid))) // .ToList(); List <C_Checkbox> selectedBowlingCenters = new List <C_Checkbox>(); foreach (S_CompetitonBowlingcenter cbc in cbcl) { S_BowlingCenter bc = BowlingCenterManager.GetBowlingCenterById(cbc.bowlingcenterid); selectedBowlingCenters.Add(new C_Checkbox { Id = cbc.bowlingcenterid, Name = bc.name }); } //setup a view model competitionModel.AvailableBowlingCenters = CheckboxManager.GetAll().ToList(); competitionModel.SelectedBowlingCenters = selectedBowlingCenters; return(View(competitionModel)); }