Exemplo n.º 1
0
        public async Task <IActionResult> PlayMatch()
        {
            EntityHttpResponse entityResponse = await ApiCenter.GetAsync($"Season/CreateSeason");


            return(View());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Login(LoginViewModel loginViewModel)
        {
            loginViewModel.Password = PasswordCryptographyCombine(loginViewModel.Password);
            EntityHttpResponse entityHttpResponse = await ApiCenter.GetAsync($"User/Login/{loginViewModel.Email}/{loginViewModel.Password}");

            if (entityHttpResponse.IsTrue)
            {
                User user = ApiCenter.getData <User>(entityHttpResponse);
                LoginUserSave(user);
                return(RedirectToAction("UserDetail", "Home"));
            }
            else
            {
                TempData.Add("LoginErrorMasage", entityHttpResponse._Data);
                return(View());
            }
        }
Exemplo n.º 3
0
        private async void Create_Season_Click(object sender, RoutedEventArgs e)
        {
            Season season = new Season()
            {
                Date = dp.SelectedDate.Value
            };
            EntityHttpResponse SeasonCreate = await ApiCenter.CreateAsync <Season>(season, "Season/Create");

            if (SeasonCreate.IsTrue)
            {
                MessageBox.Show("Season Basari ile kayit edilmistir");
                NavigationService.Navigate(new LeagueCreate());
            }
            else
            {
                MessageBox.Show("Ekleme Basarisiz");
            }
        }
Exemplo n.º 4
0
        private async void LeagueCreate_Loaded(object sender, RoutedEventArgs e)
        {
            EntityHttpResponse Http_seasons = await ApiCenter.GetAsync("Season");

            EntityHttpResponse Http_team = await ApiCenter.GetAsync("Team");

            ICollection <Team>   Teams;
            ICollection <Season> Seasons;

            if (Http_seasons.IsTrue && Http_team.IsTrue)
            {
                Seasons = ApiCenter.getData <ICollection <Season> >(Http_seasons);
                Teams   = ApiCenter.getData <ICollection <Team> >(Http_team);
                LB_Teams.ItemsSource  = Teams;
                CB_Season.ItemsSource = Seasons;
            }
            else
            {
                MessageBox.Show("Sayfa yuklenirken sorun olustu lutfen daha sonra tekrar deneyiniz.");
            }
        }
Exemplo n.º 5
0
        public async Task <IActionResult> UserDetail()
        {
            ViewBag.IsLogin = IsLogin;
            if (IsLogin)
            {
                User user = LoginUser();

                EntityHttpResponse entityHttpResponseTeam = await ApiCenter.GetAsync($"Team/{user.Teamid}");

                if (entityHttpResponseTeam.IsTrue)
                {
                    Team team = ApiCenter.getData <Team>(entityHttpResponseTeam);
                    EntityHttpResponse entityHttpResponseStadium = await ApiCenter.GetAsync($"Stadium/{team.Stadiumid}");

                    if (entityHttpResponseStadium.IsTrue)
                    {
                        Stadium stadium = ApiCenter.getData <Stadium>(entityHttpResponseStadium);
                        ViewBag.LoadError = false;
                        TempData.Clear();
                        EntityHttpResponse entityHttpResponseTeams = await ApiCenter.GetAsync("Team");

                        if (entityHttpResponseTeams.IsTrue)
                        {
                            List <Team> teams;
                            teams = ApiCenter.getData <List <Team> >(entityHttpResponseTeams);
                            return(View(new AccountListViewModel(user, team, stadium, teams)));
                        }
                    }
                }
                ViewBag.LoadError = true;
                TempData.Add("UserDetailErrorMesage", "Kullaniciya ait bilgiler tamamen yuklenemedi");
                return(View(null));
            }

            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Register(RegisterViewModel registerViewModel)
        {
            if (registerViewModel.Password.Equals(registerViewModel.PasswordConfirmation))
            {
                registerViewModel.Password = PasswordCryptographyCombine(registerViewModel.Password);
                EntityHttpResponse entityHttpResponse = await ApiCenter.GetAsync($"User/Register/{registerViewModel.Email}/{registerViewModel.Password}/{registerViewModel.UserName}");

                if (entityHttpResponse.IsTrue)
                {
                    return(RedirectToAction("Login", 1));
                }
                else
                {
                    TempData.Add("RegisterErrorMasage", entityHttpResponse._Data);
                    return(View());
                }
            }
            else
            {
                TempData.Add("RegisterErrorMasage", "adgangskoder stemmer ikke overens");
                return(View());
            }
        }
Exemplo n.º 7
0
 public static T getData <T>(EntityHttpResponse httpResponse) where T : class
 {
     return(JsonConvert.DeserializeObject <T>(httpResponse.Jsondata));
 }
Exemplo n.º 8
0
        private async void submit_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(leagueName.Text) && CB_Season.SelectedIndex > -1 && LB_Teams.SelectedItems.Count > 1)
            {
                League league = new League()
                {
                    Name     = leagueName.Text,
                    Seasonid = (CB_Season.SelectedItem as Season).id,
                    Season   = (CB_Season.SelectedItem as Season)
                };
                EntityHttpResponse Httpleague = await ApiCenter.CreateAsync <League>(league, "League/Create");

                if (Httpleague.IsTrue)
                {
                    var            teams   = LB_Teams.SelectedItems.Cast <Team>().ToList();
                    List <Matches> Matches = new List <Matches>();
                    foreach (Team item in teams)
                    {
                        var lt = new LeagueTeam()
                        {
                            Team     = item,
                            Teamid   = item.id,
                            League   = league,
                            Leagueid = league.id,
                        };
                        EntityHttpResponse entityHttpResponse = await ApiCenter.CreateAsync <LeagueTeam>(lt, "LeagueTeam/Create");
                    }
                    int MatchCount = 0;
                    for (int i = 0; i < teams.Count; i++)
                    {
                        Team firstTeam = teams[i];
                        for (int j = i + 1; j < teams.Count; j++)
                        {
                            Team SecondTeam = teams[j];
                            Matches.Add(new Matches()
                            {
                                FirstTeam  = firstTeam,
                                SecondTeam = SecondTeam
                            });
                            MatchCount++;
                        }
                    }

                    foreach (var item in Matches)
                    {
                        int matchday = 365 / MatchCount;
                        if (matchday == 365)
                        {
                            matchday = 0;
                        }
                        item.Date = league.Season.Date.AddDays(matchday);
                        EntityHttpResponse entityHttpResponse = await ApiCenter.CreateAsync <Matches>(item, "Matches/Create");
                    }

                    MessageBox.Show("League Olusturuldu");
                    NavigationService.Navigate(null);
                }
                else
                {
                    MessageBox.Show("Sistemsel bir sikintidan dolayi ekleme gerceklesmedi lutfen tekrar deneyiniz.");
                }
            }
            else
            {
                MessageBox.Show("Lutfen, Gerekli Tum Alanlari Doldurunuz\nTakim Adini Giriniiz\nSezon Seciniz\nEn Az Iki Takim Seciniz");
            }
        }