private void RemoveTeamClick(object sender, RoutedEventArgs e)
        {
            if (lbox.SelectedItem as Team != null)
            {
                RestService restService = new RestService(ApiAddress.Address(), "/Team", token);
                restService.Delete <string>((lbox.SelectedItem as Team).TID);

                GetLeagueListNames();
            }
        }
        public async Task GetLeagueListNames()
        {
            RestService restService = new RestService(ApiAddress.Address(), "/League", token);

            IEnumerable <League> leaguelistnames = await restService.Get <League>();

            cbox.ItemsSource   = null;
            cbox.ItemsSource   = leaguelistnames;
            cbox.SelectedIndex = 0;
        }
        private void RemoveDriverClick(object sender, RoutedEventArgs e)
        {
            if (lbox2.SelectedItem as Driver != null)
            {
                RestService restService = new RestService(ApiAddress.Address(), "/Driver", token);
                restService.Delete <string>((lbox2.SelectedItem as Driver).DID);

                //update the list
                GetLeagueListNames();
            }
        }
        private void RemoveLeagueClick(object sender, RoutedEventArgs e)
        {
            if (cbox.SelectedItem as League != null)
            {
                RestService restService = new RestService(ApiAddress.Address(), "/League", token);
                restService.Delete <string>((cbox.SelectedItem as League).LID);

                //update the list
                GetLeagueListNames();
            }
        }
Exemple #5
0
        private void AddLeague(object sender, RoutedEventArgs e)
        {
            League league = new League
            {
                Name     = Name.Text.ToString(),
                Rating   = rnd.Next(1, 10),
                Homology = true,
                //RaceTypes = RaceTypes.SelectedItem.ToString()
            };

            RestService restservice = new RestService(ApiAddress.Address(), "/League", token);

            restservice.Post <League>(league);

            MainWindow main = new MainWindow();

            main.GetLeagueListNames();
            this.Close();
        }
        public async Task Login()
        {
            PasswordWindow pw = new PasswordWindow();

            if (pw.ShowDialog() == true)
            {
                RestService    restService = new RestService(ApiAddress.Address(), "/Auth");
                TokenViewModel tvm         = await restService.Put <TokenViewModel, LoginViewModel>(new LoginViewModel()
                {
                    Username = pw.UserName,
                    Password = pw.PassWord
                });

                token = tvm.Token;
                GetLeagueListNames();
            }
            else
            {
                this.Close();
            }
        }
        private void AddDriver(object sender, RoutedEventArgs e)
        {
            Driver driver = new Driver()
            {
                DName      = DName.Text,
                TID        = team.TID,
                BornYear   = int.Parse(BornYear.Text),
                CountryB   = CountryB.Text,
                RaceNumber = int.Parse(RaceNumber.Text),
                OwnTeam    = team,
            };

            RestService restService = new RestService(ApiAddress.Address(), "/Driver", token);

            restService.Post <Driver>(driver);
            MainWindow mainWindow = new MainWindow();

            mainWindow.GetLeagueListNames();

            this.Close();
        }