Ejemplo n.º 1
0
        private UIElement Add(string bookmakerPhoneNumber, IEnumerable <ClientDisplayModel> clients, IEnumerable <string> sports, IEnumerable <TournamentDisplayModel> tournaments, IEnumerable <EventDisplayModel> events, IEnumerable <CoefficientDisplayModel> coefficients)
        {
            BetCreateViewModel viewModel = new BetCreateViewModel(bookmakerPhoneNumber, clients, sports, tournaments, events, coefficients);
            BetCreateControl   control   = new BetCreateControl(viewModel);

            viewModel.BetCreated += (s, e) =>
            {
                BetCreateModel betCreateModel = e.Bet;
                BetCreateDTO   betCreateDTO   = Mapper.Map <BetCreateModel, BetCreateDTO>(betCreateModel);

                using (IBetService service = factory.CreateBetService())
                {
                    ServiceMessage serviceMessage = service.Create(betCreateDTO);
                    RaiseReceivedMessageEvent(serviceMessage);

                    if (serviceMessage.IsSuccessful)
                    {
                        viewModel.Sum = 0;
                        Notify();
                    }
                }
            };

            return(control);
        }
Ejemplo n.º 2
0
        private void RaiseBetCreatedEvent(BetCreateModel betCreateModel)
        {
            var handler = BetCreated;

            if (handler != null)
            {
                BetCreateEventArgs e = new BetCreateEventArgs(betCreateModel);
                handler(this, e);
            }
        }
Ejemplo n.º 3
0
        //TODO
        //this shit
        public BetCreateViewModel(string bookmakerPhoneNumber, IEnumerable <ClientDisplayModel> clients, IEnumerable <string> sports, IEnumerable <TournamentBaseModel> tournaments, IEnumerable <EventBaseModel> events, IEnumerable <CoefficientDisplayModel> coefficients)
        {
            this.betCreateModel = new BetCreateModel
            {
                BookmakerPhoneNumber = bookmakerPhoneNumber
            };

            this.CreateBetCommand = new DelegateCommand(CreateBet, CanCreateBet);

            this.Sports       = new ObservableCollection <string>(sports);
            this.Tournaments  = new ObservableCollection <TournamentBaseModel>(tournaments);
            this.Events       = new ObservableCollection <EventBaseModel>(events);
            this.Coefficients = new ObservableCollection <CoefficientDisplayModel>(coefficients);
            this.Clients      = new ObservableCollection <ClientDisplayModel>(clients);

            this.SortedTournaments.Filter = obj =>
            {
                TournamentBaseModel t = obj as TournamentBaseModel;

                return
                    (SelectedSport != null &&
                     t.SportName == SelectedSport);
            };
            this.SortedEvents.Filter = obj =>
            {
                EventBaseModel e = obj as EventBaseModel;

                return
                    (SelectedSport != null &&
                     SelectedTournament != null &&
                     e.SportName == SelectedSport &&
                     e.TournamentName == SelectedTournament.Name);
            };
            this.SortedCoefficients.Filter = obj =>
            {
                CoefficientBaseModel c = obj as CoefficientBaseModel;

                bool valid =
                    SelectedSport != null &&
                    SelectedTournament != null &&
                    SelectedEvent != null &&
                    c.SportName == SelectedSport &&
                    c.TournamentName == SelectedTournament.Name &&
                    c.DateOfEvent == SelectedEvent.DateOfEvent;

                if (valid)
                {
                    valid = c.Participants.Count == SelectedEvent.Participants.Count;

                    if (valid)
                    {
                        for (int i = 0; i < c.Participants.Count; i++)
                        {
                            var p1 = c.Participants
                                     .OrderBy(p => p.Name)
                                     .ThenBy(p => p.CountryName)
                                     .ThenBy(p => p.SportName)
                                     .ElementAt(i);
                            var p2 = SelectedEvent.Participants
                                     .OrderBy(p => p.Name)
                                     .ThenBy(p => p.CountryName)
                                     .ThenBy(p => p.SportName)
                                     .ElementAt(i);
                            valid =
                                p1.Name == p2.Name &&
                                p1.CountryName == p2.CountryName &&
                                p1.SportName == p2.SportName;

                            if (!valid)
                            {
                                break;
                            }
                        }
                    }
                }

                return(valid);
            };
        }
Ejemplo n.º 4
0
 public BetCreateEventArgs(BetCreateModel bet)
 {
     this.Bet = bet;
 }