public HomeViewModel()
        {
            _existingTournaments = new BindableCollection <TournamentModel>(SqlDataHandler.GetAllData <TournamentModel>("dbo.SP_GetAllTournaments"));

            foreach (TournamentModel tournament in _existingTournaments)
            {
                tournament.Rounds = SqlDataHandler.GetRoundsByTournament(tournament.Id);
            }
        }
 //          CONSTRUCTOR
 public CreateNewTournamentViewModel()
 {
     _tournamentTeams  = new BindableCollection <TeamModel>();
     _tournamentPrizes = new BindableCollection <PrizeModel>();
     _availableTeams   = new BindableCollection <TeamModel>(SqlDataHandler.GetAllData <TeamModel>("dbo.SP_GetAllTeams"));
     TournamentTeams.CollectionChanged += TournamentTeams_CollectionChanged;
     _victoryPoints = 3;
     _drawPoints    = 1;
     _officialScore = 3;
 }
Пример #3
0
        public void ValidateAllData()
        {
            List <string>    errors        = new List <string>();
            List <TeamModel> existingTeams = SqlDataHandler.GetAllData <TeamModel>("dbo.SP_GetAllTeams");
            List <string>    usedNames     = new List <string>();
            string           nameLower     = "";

            if (TeamName != null)
            {
                nameLower = TeamName.ToLower();
            }

            foreach (TeamModel team in existingTeams)
            {
                usedNames.Add(team.TeamName);
            }

            if (usedNames.Contains(TeamName))
            {
                errors.Add($"Team name {TeamName} is already taken.");
            }

            if (String.IsNullOrWhiteSpace(TeamName))
            {
                errors.Add("Team must have a name.");
            }

            if (nameLower.Contains("dummy"))
            {
                errors.Add(@"Team name must not contain word ""dummy"".");
            }

            if (TeamMembers.Count == 0)
            {
                errors.Add("Team must have at least 1 member.");
            }

            bool somethingWrong = usedNames.Contains(TeamName) || String.IsNullOrWhiteSpace(TeamName) ||
                                  nameLower.Contains("dummy") || TeamMembers.Count == 0;

            if (somethingWrong)
            {
                CanCreateTeam = false;
                ErrorMessage  = $"* {string.Join(" ", errors)}";
            }
            else
            {
                CanCreateTeam = true;
                ErrorMessage  = null;
            }
        }
Пример #4
0
 public CreateTeamViewModel()
 {
     _availablePlayers = new BindableCollection <PlayerModel>(SqlDataHandler.GetAllData <PlayerModel>("dbo.SP_GetAllPlayers"));
     _teamMembers      = new BindableCollection <PlayerModel>();
 }
Пример #5
0
 //          CONSTRUCTORS
 public CreateTeamViewModel(ITournamentCreator previousView)
 {
     _tournamentCreationView = previousView;
     _availablePlayers       = new BindableCollection <PlayerModel>(SqlDataHandler.GetAllData <PlayerModel>("dbo.SP_GetAllPlayers"));
     _teamMembers            = new BindableCollection <PlayerModel>();
 }