Esempio n. 1
0
        public static Game FromDTO(CategoryDTO gameDTO)
        {
            Game game = new Game();
            int c;
            int.TryParse(gameDTO.Classification, out c);
            game.Classification = c;
            string[] oppAndDate = gameDTO.Name.Split('-'); //in the call we're using to return this information, opponent and date are concatenated.
            game.gameId = gameDTO.CategoryId;

            //get the game's name
            if (gameDTO.Classification == "1")
            {
                game.opponent = "";

                for (int i = 0; i < oppAndDate.Length - 1; i++)
                {
                    game.opponent += oppAndDate[i];
                }

                string[] date = oppAndDate.Last().Split('/');
                int year;
                int month;
                int day;
                try
                {
                    int.TryParse(date[2], out year);
                    int.TryParse(date[1], out day);
                    int.TryParse(date[0], out month);
                    game.date = new DateTime(year, month, day);
                }
                catch (Exception e)
                {
                    game.date = new DateTime();
                }

            }
            else
            {
                game.opponent = gameDTO.Name;
            }
            foreach(CategoryDTO cat in gameDTO.SubCategories)
            {
                game.categories.Add(Category.FromDTO(cat));
            }
            return game;
        }
Esempio n. 2
0
        public Season(CategoryDTO cat, Team team)
        {
            seasonId = cat.CategoryId;
            owningTeam = team;

            //this method of making a season doesn't have a year, so we just choose the first year listed in the name
            int yearInt;
            int.TryParse(cat.Name.Substring(0, 4), out yearInt);
            year = yearInt;

            name = cat.Name;
            games = new BindableCollection<Game>();
            foreach (CategoryDTO subCat in cat.SubCategories)
            {
                games.Add(Game.FromDTO(subCat));
            }
        }
Esempio n. 3
0
 public static Category FromDTO(CategoryDTO categoryDTO)
 {
     Category category = new Category();
     category.categoryId = categoryDTO.CategoryId;
     category.name = categoryDTO.Name;
     return category;
 }