Exemple #1
0
 public JsonBookRepository(string connectionString)
 {
     _connectionString = connectionString;
     if (File.Exists(connectionString))
     {
         var jsonDb = File.ReadAllText(connectionString);
         _db = JsonConvert.DeserializeObject <JsonDb>(jsonDb);
     }
     else
     {
         _db = new JsonDb();
     }
 }
        /// <summary>
        /// Initialized JSON Repository, if the file not exists then create the necessary file
        /// </summary>
        /// <param name="connectionString"></param>
        public JsonJobRepository(string connectionString)
        {
            if (File.Exists(connectionString))
            {
                var jsonDb = File.ReadAllText(connectionString);
                _db = Newtonsoft.Json.JsonConvert.DeserializeObject <JsonDb>(jsonDb);
            }
            else
            {
                _db = new JsonDb();
            }

            _connectionString = connectionString;
        }