Beispiel #1
0
        public ActionResult Result(ViewTeam Team)
        {
            if (ModelState.IsValid)
            {
                this.matchService.AddResult(Team.Id, Team.homeGoals, Team.awayGoals);

                var result = this.matchService.UpdateAllForecasts(Team.Id, Team.homeGoals, Team.awayGoals);

                // fix this shi* :@
                var db = ApplicationDbContext.Create();
                foreach (var res in result)
                {
                    string currentId = res.Item1.ToString();
                    var    user      = db.Users.FirstOrDefault(x => x.Id == currentId);
                    user.Points += res.Item2 * res.Item3;
                    db.SaveChanges();
                }

                foreach (var res in result)
                {
                    string currentId = res.Item1.ToString();
                    this.userForecast.UpgradeUserPointsAfterMatch(res.Item1, res.Item2 * res.Item3);
                }

                var match = this.matchService.GetById(Team.Id);

                this.teamService.UpdateTeams(match.HomeTeam, match.AwayTeam, Team.homeGoals, Team.awayGoals);

                return(this.View("index"));
            }

            return(this.View("AddResult"));
        }
        public ViewTeam AddTeam(ViewTeam viewTeam)
        {
            TeamLogicController teamLogicController = new();
            LogicTeam           logicTeam           = new(viewTeam.NameTeam, viewTeam.Location, viewTeam.Sponsor, viewTeam.CreationYear, viewTeam.Director);

            teamLogicController.AddTeam(logicTeam);
            return(viewTeam);
        }
Beispiel #3
0
        public ActionResult Result(Guid id, string homeTeam, string awayTeam)
        {
            var team = new ViewTeam()
            {
                homeGoals = 0,
                awayGoals = 0,
                Id        = id,
                homeTeam  = homeTeam,
                awayTeam  = awayTeam
            };

            return(this.View(team));
        }
        // team toevoegen
        private void button3_Click(object sender, EventArgs e)
        {
            TeamViewController teamController = new();
            string             name           = textBox8.Text;
            string             location       = textBox9.Text;
            string             sponsor        = textBox10.Text;
            string             creationYear   = textBox11.Text;
            string             director       = textBox12.Text;
            ViewTeam           newTeam        = new(name, location, sponsor, creationYear, director);
            ViewTeam           team           = teamController.AddTeam(newTeam);

            listBoxTeams.Items.Add($"Team: {team.NameTeam}, Creation year: {team.CreationYear}, Director: {team.Director}");
            UpdateNumericUpDown();
        }
Beispiel #5
0
        private void ViewTeam_Click(object sender, RoutedEventArgs e)
        {
            ViewTeam viewTeam = new ViewTeam();

            NavigationService.Navigate(viewTeam);
        }