private void AddMedalToSportsmanCommandExecute(object obj) { var medalSportsman = new MedalSportsman(FillParticipantSportsman, GiveMedalSportsmanMedalType); db.Participants.First(p => p.Id == FillParticipantParticipant.Id).Medals.Add(medalSportsman); db.SaveChanges(); MedalSportsmen.Add(medalSportsman); MedalSportsmenCount++; systemClass.ShowMessageBox("Info", $"Medal has been added to {FillParticipantSportsman}"); FillParticipantSportsman = null; GiveMedalSportsmanMedalType = default; }
private void FillParticipantParticipantChanged() { FillParticipantSportsmen.Clear(); MedalSportsmen.Clear(); if (FillParticipantOlympiad != null && FillParticipantEvent != null && FillParticipantParticipant != null) { foreach (var item in db.Sportsmen.ToList().Where(s => s.Country == FillParticipantParticipant.Country && s.Sport == FillParticipantEvent.Sport)) { FillParticipantSportsmen.Add(item); } FillSportsmanCount = FillParticipantSportsmen.Count; foreach (var item in db.Participants.ToList().First(p => p.Id == FillParticipantParticipant.Id).Medals) { MedalSportsmen.Add(item); } MedalSportsmenCount = MedalSportsmen.Count; } }