public object Get(LoadBackup load_backup) { AuthorizationInfo user_info = _ac.GetAuthorizationInfo(Request); UserPolicy policy = _userManager.GetUserPolicy(user_info.User); if (!policy.IsAdministrator) { return(new List <string>() { "Not Authorized" }); } FileInfo fi = new FileInfo(load_backup.backupfile); if (fi.Exists == false) { return(new List <string>() { "Backup file does not exist" }); } int count = 0; try { string load_data = ""; using (StreamReader sr = new StreamReader(new FileStream(fi.FullName, FileMode.Open))) { load_data = sr.ReadToEnd(); } count = repository.ImportRawData(load_data); } catch (Exception e) { return(new List <string>() { e.Message }); } return(new List <string>() { "Backup loaded " + count + " items" }); }
public object Get(LoadBackup load_backup) { FileInfo fi = new FileInfo(load_backup.backupfile); if (fi.Exists == false) { return(new List <string>() { "Backup file does not exist" }); } int count = 0; try { string load_data = ""; using (StreamReader sr = new StreamReader(new FileStream(fi.FullName, FileMode.Open))) { load_data = sr.ReadToEnd(); } count = Repository.ImportRawData(load_data); } catch (Exception e) { return(new List <string>() { e.Message }); } return(new List <string>() { "Backup loaded " + count + " items" }); }