private UIElement Create(IEnumerable <string> countries, IEnumerable <string> sports) { ParticipantCreateViewModel viewModel = new ParticipantCreateViewModel(countries, sports); ParticipantCreateControl control = new ParticipantCreateControl(viewModel); viewModel.ParticipantCreated += (s, e) => { ParticipantBaseModel participantModel = e.Participant; ParticipantBaseDTO participantDTO = Mapper.Map <ParticipantBaseModel, ParticipantBaseDTO>(participantModel); using (IParticipantService service = factory.CreateParticipantService()) { ServiceMessage serviceMessage = service.Create(participantDTO); RaiseReceivedMessageEvent(serviceMessage.IsSuccessful, serviceMessage.Message); if (serviceMessage.IsSuccessful) { Notify(); viewModel.ParticipantName = String.Empty; } } }; return(control); }
public ParticipantCreateViewModel(IEnumerable <string> countries, IEnumerable <string> sports) { this.participant = new ParticipantBaseModel(); this.Countries = new ObservableCollection <string>(countries); this.Sports = new ObservableCollection <string>(sports); this.CreateParticipantCommand = new DelegateCommand(() => RaiseParticipantCreatedEvent(participant), CanCreate); }
private void RaiseParticipantCreatedEvent(ParticipantBaseModel participant) { var handler = ParticipantCreated; if (handler != null) { ParticipantEventArgs e = new ParticipantEventArgs(participant); handler(this, e); } }
private void MoveAllToTournament() { foreach (var obj in SortedAllParticipants) { ParticipantBaseModel participant = obj as ParticipantBaseModel; TournamentParticipants.Add(participant); } SortedAllParticipants.Refresh(); }
void _repository_ParticipantAdded(object sender, ParticipantEventArgs e) { var newPos = _participantData.AddParticipant(e.Participant.Id, e.Participant.TrialArm, ParticipantBaseModel.DataRequiredFunc(e.Participant)); if (_participantData.ColHeaders.Count > ParticipantData.ColHeaders.Count) //1st patient randomised to new arm { int newColIndex = _participantData.ColHeaders.Count - 1; for (var i = 0; i < _participantData.Participants.Length; i++) { ParticipantData.Row[i].SummaryCells.Add(new ParticipantSummaryItemViewModel(_participantData.Participants[i][newColIndex])); } ParticipantData.ColHeaders.Add(ParticipantBaseModel.GetTrialArmDescription(_participantData.ColHeaders[newColIndex])); } ParticipantData.Row[newPos.x].SummaryCells[newPos.y].ParticipantIds = _participantData.Participants[newPos.x][newPos.y]; }
private void Delete(ParticipantBaseModel participantBaseModel) { ParticipantBaseDTO participantBaseDTO = Mapper.Map <ParticipantBaseModel, ParticipantBaseDTO>(participantBaseModel); using (IParticipantService service = factory.CreateParticipantService()) { ServiceMessage serviceMessage = service.Delete(participantBaseDTO); RaiseReceivedMessageEvent(serviceMessage); if (serviceMessage.IsSuccessful) { Notify(); } } }
public TournamentParticipantViewModel(TournamentEditModel tournament, IEnumerable <ParticipantBaseModel> sportParticipants) { this.tournament = tournament; this.SaveCommand = new DelegateCommand(() => Save(tournament), obj => true); this.MoveToTournamentCommand = new DelegateCommand(MoveToTournament, obj => SelectedParticipant != null); this.MoveAllToTournamentCommand = new DelegateCommand(MoveAllToTournament, obj => true); this.MoveFromTournamentCommand = new DelegateCommand(MoveFromTournament, obj => SelectedTournamentParticipant != null); this.SportParticipants = new ObservableCollection <ParticipantBaseModel>(sportParticipants); this.TournamentParticipants = new ObservableCollection <ParticipantBaseModel>(tournament.Participants); SortedAllParticipants.Filter = obj => { ParticipantBaseModel participant = obj as ParticipantBaseModel; return(TournamentParticipants .Count(part => part.CountryName == participant.CountryName && part.Name == participant.Name ) == 0); }; }
public EventParticipantViewModel(EventDisplayModel eventDisplayModel, IEnumerable <ParticipantBaseModel> allParticipants) { this.eventEditModel = new EventEditModel { DateOfTournamentStart = eventDisplayModel.DateOfTournamentStart, SportName = eventDisplayModel.SportName, TournamentName = eventDisplayModel.TournamentName, DateOfEvent = eventDisplayModel.DateOfEvent, OldNotes = eventDisplayModel.Notes, Participants = eventDisplayModel.Participants.ToList() }; this.MoveToEventCommand = new DelegateCommand( () => MoveToEvent(SelectedParticipant), obj => SelectedParticipant != null); this.MoveAllToEventCommand = new DelegateCommand( () => MoveAllToEvent(), obj => true); this.MoveFromEventCommand = new DelegateCommand( () => MoveFromEvent(SelectedEventsParticipant), obj => SelectedEventsParticipant != null); this.SaveChangesCommand = new DelegateCommand(() => SaveChanges(eventEditModel), obj => true); this.AllParticipants = new ObservableCollection <ParticipantBaseModel>(allParticipants); this.SelectedParticipants = new ObservableCollection <ParticipantBaseModel>(eventDisplayModel.Participants); NotSelectedParticipants.Filter = obj => { ParticipantBaseModel participant = obj as ParticipantBaseModel; return(SelectedParticipants.Count(p => p.Name == participant.Name && p.CountryName == participant.CountryName && p.SportName == participant.SportName) == 0); }; }
public ParticipantListItemViewModel(ParticipantBaseModel participant, IRepository repository = null) : base(repository) { ParticipantModel = participant; }
public ParticipantEventArgs(ParticipantBaseModel participant) { this.Participant = participant; }
private void MoveFromEvent(ParticipantBaseModel participant) { SelectedParticipants.Remove(participant); NotSelectedParticipants.Refresh(); }
private void MoveToEvent(ParticipantBaseModel participant) { SelectedParticipants.Add(participant); NotSelectedParticipants.Refresh(); }
void handleParrticipantUpdated(Participant participant) { var move = _participantData.AlterParticipant(participant.Id, participant.TrialArm, ParticipantBaseModel.DataRequiredFunc(participant)); if (move.OldRow != move.NewRow) { int col = _participantData.ColIndex(participant.TrialArm); ParticipantData.Row[move.OldRow].SummaryCells[col].ParticipantIds = _participantData.Participants[move.OldRow][col]; ParticipantData.Row[move.NewRow].SummaryCells[col].ParticipantIds = _participantData.Participants[move.NewRow][col]; } }
public ParticipantSummaryViewModel(ParticipantsSummary summary) { ColHeaders = new ObservableCollection <string>(summary.ColHeaders.Select(c => ParticipantBaseModel.GetTrialArmDescription(c))); Row = new ParticipantSummaryRowViewModel[summary.RowHeaders.Length]; for (var i = 0; i < Row.Length; i++) { Row[i] = new ParticipantSummaryRowViewModel { RowHeader = DataRequiredStrings.GetDetails(summary.RowHeaders[i]), SummaryCells = summary.Participants[i].Select(p => new ParticipantSummaryItemViewModel(p)).ToList() }; } }