Exemplo n.º 1
0
        public bool IsReadFromFilePossible(int competitionId)
        {
            bool   res      = false;
            string fileName = ExternalDataTools.MapIdToFileName(competitionId);

            if (!string.IsNullOrEmpty(fileName))
            {
                string path = $@"{env.ContentRootPath}/AppData/{fileName}.json";
                res = File.Exists(path) && !competitionsService.IsCompetitionExist(competitionId);
            }
            return(res);
        }
Exemplo n.º 2
0
        public void ReadFullCompetitionFromFile(int competitionId)
        {
            string       fileName = ExternalDataTools.MapIdToFileName(competitionId);
            string       path     = $@"{env.ContentRootPath}/AppData/{fileName}.json";
            ExternalData data     = new ExternalData();

            using (StreamReader sr = new StreamReader(path))
            {
                JsonSerializer serializer = new JsonSerializer();
                data = (ExternalData)serializer.Deserialize(sr, typeof(ExternalData));
            }
            externalDataSaver.Create(data);
        }