Exemple #1
0
        static void Main(string[] args)
        {
            // Please, run the website project before this project
            // that way, champion and item data will be already on the database
            var context = new AppDbContext();
            var mcontext = new MatchesDBContext();
            bool downloading = false;

            if (downloading)
            {
                string path = @"C:\RiotMatches\Current";
                DataUpload dataParsing = new DataUpload(path, context, mcontext);
                dataParsing.ParseJsonFiles();
                dataParsing.GetDataFromUrl();

                Console.WriteLine("Done.");
            }
            else
            {
                var matches = mcontext.Matches.ToList();

                Console.WriteLine("Proceeding to create the analysis of all the data uploaded.");
                DataAnalysis data = new DataAnalysis(context, mcontext, matches);
                data.CreateRecord();
                data.CreateCalculatedRecord();

                Console.WriteLine("Done. (Maybe, just check for errors(?)");
            }

            Console.ReadKey();
        }
        public ActionResult Create(Matches matches)
        {
            try
            {
                // To validate Winner is one of the selected player
                if (matches.WinnerID == matches.Player1ID || matches.WinnerID == matches.Player2ID)
                {
                    if (ModelState.IsValid)
                    {
                        MatchesDBContext matchesDBContext = new MatchesDBContext();
                        int MatchID = matchesDBContext.InsertMatchDetails(matches);
                        matches.MatchID = MatchID;
                        ScoresDBContext scoresDBContext = new ScoresDBContext();
                        int             result          = scoresDBContext.InsertScores(matches);
                        if (result == 1 || result == -1)
                        {
                            return(RedirectToAction("Save"));
                        }
                    }
                    return(RedirectToAction("Index"));
                }

                else
                {
                    matches.playerNames = getPlayersList();
                    return(View(matches));
                }
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Matches", "Create")));
            }
        }
 public ActionResult SearchResults(SearchViewModel searchViewModel)
 {
     try
     {
         string           searchString     = Convert.ToString(TempData["searchString"]);
         DateTime         searchDate       = Convert.ToDateTime(TempData["searchDate"]);
         MatchesDBContext matchesDBContext = new MatchesDBContext();
         DataSet          dsResult         = new DataSet();
         dsResult = matchesDBContext.GetMatchUsingSearchString(searchString, searchDate);
         Matches objMatches = new Matches();
         objMatches = getMatchResults(dsResult);
         if (objMatches != null)
         {
             return(View(objMatches));
         }
         else
         {
             return(RedirectToAction("Search", "Matches", "Please enter valid data"));
         }
     }
     catch (Exception ex)
     {
         return(View("Error", new HandleErrorInfo(ex, "Matches", "Search")));
     }
 }
 public ActionResult Edit(Matches matches)
 {
     try
     {
         if (ModelState.IsValid)
         {
             matches.MatchID = Convert.ToInt32(TempData["MatchID"]);
             ScoresDBContext scoresDBContext = new ScoresDBContext();
             scoresDBContext.UpdateScores(matches);
             MatchesDBContext matchesDBContext = new MatchesDBContext();
             int result = matchesDBContext.UpdateMatchDetails(matches);
             if (result == 1)
             {
                 return(RedirectToAction("Save"));
             }
             return(RedirectToAction("Index"));
         }
         Matches objMatches = new Matches();
         objMatches = getMatchData(Convert.ToInt32(TempData["MatchID"]));
         return(View(objMatches));
     }
     catch (Exception ex)
     {
         return(View("Error", new HandleErrorInfo(ex, "Matches", "Edit")));
     }
 }
        public DataUpload(string dataurl, AppDbContext context, MatchesDBContext mcontext)
        {
            DataUrl = dataurl;
            fileNames = Directory.GetFiles(DataUrl, "*.json")
                                    .Select(path => Path.GetFileName(path))
                                    .ToList();

            // first string for id, second for region
            IDMatches = new Queue<RegionId>();
            Matches = new List<InitialDataUpload.Models.Match>();
            Context = context;
            MatchesContext = mcontext;

            ServicePointManager.DefaultConnectionLimit = 10000;
        }
        public ActionResult Index()
        {
            try
            {
                MatchesDBContext matchesDBContext = new MatchesDBContext();
                DataSet          dsMatchesPlayers = new DataSet();
                dsMatchesPlayers = matchesDBContext.GetMatchesPlayers();

                Matches matches = new Matches();
                matches = getMatchResults(dsMatchesPlayers);
                return(View(matches));
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Matches", "Index")));
            }
        }
        public ActionResult AdminIndex()
        {
            try
            {
                if (Convert.ToString(Session["Role"]) == "Admin")
                {
                    MatchesDBContext matchesDBContext = new MatchesDBContext();
                    DataSet          dsMatchesPlayers = new DataSet();
                    dsMatchesPlayers = matchesDBContext.GetMatchesPlayers();

                    Matches matches = new Matches();
                    matches = getMatchResults(dsMatchesPlayers);
                    return(View(matches));
                }
                else
                {
                    return(View("~/Views/PageNotFound.cshtml"));
                }
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Matches", "Index")));
            }
        }
 public DataAnalysis(AppDbContext context, MatchesDBContext mcontext, List<Match> matches)
 {
     _context = context;
     _matchesContext = mcontext;
     _matches = matches;
 }