public RestBoxState RemoveRestBoxStateFile(RestBoxStateFile restBoxStateFile)
        {
            if (!fileService.FileExists(stateFileLocation))
            {
                return null;
            }

            var restBoxState = fileService.Load<RestBoxState>(stateFileLocation);

            for (var i = restBoxState.RestBoxStateFiles.Count - 1; i >= 0; i--)
            {
                if (restBoxState.RestBoxStateFiles[i].FilePath == restBoxStateFile.FilePath)
                {
                    restBoxState.RestBoxStateFiles.RemoveAt(i);
                }
            }

            restBoxState.RestBoxStateFiles = restBoxState.RestBoxStateFiles.Take(10).ToList();

            fileService.SaveFile(stateFileLocation, jsonSerializer.ToJsonString(restBoxState));

            return restBoxState;
        }
        public void SaveState(RestBoxStateFile restBoxStateFile)
        {
            var restBoxState = new RestBoxState();

            if (fileService.FileExists(stateFileLocation))
            {
                restBoxState = fileService.Load<RestBoxState>(stateFileLocation);
            }

            for (var i = restBoxState.RestBoxStateFiles.Count - 1; i >= 0; i--)
            {
                if (restBoxState.RestBoxStateFiles[i].FilePath == restBoxStateFile.FilePath)
                {
                    restBoxState.RestBoxStateFiles.RemoveAt(i);
                }
            }

            restBoxState.RestBoxStateFiles.Insert(0, restBoxStateFile);

            restBoxState.RestBoxStateFiles = restBoxState.RestBoxStateFiles.Take(10).ToList();

            fileService.SaveFile(stateFileLocation, jsonSerializer.ToJsonString(restBoxState));
        }
Exemple #3
0
 private void SaveRestBoxState(RestBoxStateFile restBoxStateFile)
 {
     restBoxStateService.SaveState(restBoxStateFile);
 }