示例#1
0
        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();
        }
示例#2
0
        private void RaiseBetEditedEvent(BetEditModel betEditModel)
        {
            var handler = BetEdited;

            if (handler != null)
            {
                BetEditEventArgs e = new BetEditEventArgs(betEditModel);
                handler(this, e);
            }
        }
示例#3
0
        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);
        }
示例#4
0
 public BetEditEventArgs(BetEditModel bet)
 {
     this.Bet = bet;
 }