private void Edit(BetDisplayModel betDisplayModel) { BetInfoViewModel viewModel = new BetInfoViewModel(betDisplayModel); BetInfoControl control = new BetInfoControl(viewModel); Window window = WindowFactory.CreateByContentsSize(control); viewModel.BetEdited += (s, e) => { BetEditModel betEditModel = e.Bet; BetEditDTO betEditDTO = Mapper.Map <BetEditModel, BetEditDTO>(betEditModel); using (IBetService service = factory.CreateBetService()) { ServiceMessage serviceMessage = service.Update(betEditDTO); RaiseReceivedMessageEvent(serviceMessage); if (serviceMessage.IsSuccessful) { window.Close(); Notify(); } } }; window.Show(); }
private void RaiseBetEditedEvent(BetEditModel betEditModel) { var handler = BetEdited; if (handler != null) { BetEditEventArgs e = new BetEditEventArgs(betEditModel); handler(this, e); } }
public BetInfoViewModel(BetDisplayModel betDisplayModel) { this.bet = new BetEditModel { ClientPhoneNumber = betDisplayModel.ClientPhoneNumber, CoefficientDescription = betDisplayModel.CoefficientDescription, DateOfEvent = betDisplayModel.DateOfEvent, EventParticipants = betDisplayModel.EventParticipants, SportName = betDisplayModel.SportName, TournamentName = betDisplayModel.TournamentName, NewSum = betDisplayModel.Sum, OldSum = betDisplayModel.Sum }; this.SaveChangesCommand = new DelegateCommand(() => RaiseBetEditedEvent(bet), obj => CanSaveChanges()); this.UndoCommand = new DelegateCommand(Undo, obj => IsDirty()); this.EventParticipants = new ObservableCollection <ParticipantBaseModel>(bet.EventParticipants); }
public BetEditEventArgs(BetEditModel bet) { this.Bet = bet; }