private void Edit(CoefficientDisplayModel coefficientDisplayModel) { CoefficientInfoViewModel viewModel = new CoefficientInfoViewModel(coefficientDisplayModel); CoefficientInfoControl control = new CoefficientInfoControl(viewModel); Window window = WindowFactory.CreateByContentsSize(control); viewModel.CoefficientEdited += (s, e) => { CoefficientEditModel coefficientEditModel = e.Coefficient; CoefficientEditDTO coefficientEditDTO = Mapper.Map <CoefficientEditModel, CoefficientEditDTO>(coefficientEditModel); using (ICoefficientService service = factory.CreateCoefficientService()) { ServiceMessage serviceMessage = service.Update(coefficientEditDTO); RaiseReceivedMessageEvent(serviceMessage); if (serviceMessage.IsSuccessful) { window.Close(); Notify(); } } }; window.Show(); }
public CoefficientInfoViewModel(CoefficientDisplayModel coefficient) { this.coefficientEditModel = new CoefficientEditModel { SportName = coefficient.SportName, TournamentName = coefficient.TournamentName, DateOfEvent = coefficient.DateOfEvent, Participants = coefficient.Participants, Win = coefficient.Win, NewWin = coefficient.Win, Value = coefficient.Value, NewValue = coefficient.Value, Description = coefficient.Description, NewDescription = coefficient.Description }; this.SaveChangesCommand = new DelegateCommand(() => RaiseCoefficientEditedEvent(coefficientEditModel), CanSaveChanges); this.UndoCommand = new DelegateCommand(Undo, IsDirty); this.Participants = new ObservableCollection <ParticipantBaseModel>(coefficientEditModel.Participants); }
private void RaiseCoefficientDeleteRequestEvent(CoefficientDisplayModel coefficient) { var handler = CoefficientDeleteRequest; if (handler != null) { CoefficientDisplayEventArgs e = new CoefficientDisplayEventArgs(coefficient); handler(this, e); } }
public CoefficientDisplayEventArgs(CoefficientDisplayModel coefficient) { this.Coefficient = coefficient; }