public void DoImport(Stream inputStream, PlatformExportManifest manifest, Action <ExportImportProgressInfo> progressCallback) { var progressInfo = new ExportImportProgressInfo(); using (StreamReader streamReader = new StreamReader(inputStream)) { using (JsonTextReader jsonReader = new JsonTextReader(streamReader)) { while (jsonReader.Read()) { if (jsonReader.TokenType != JsonToken.PropertyName) { continue; } switch (jsonReader.Value.ToString()) { case "Options": jsonReader.Read(); var options = _serializer.Deserialize <ThumbnailOption[]>(jsonReader); progressInfo.Description = $"Importing {options.Length} options..."; progressCallback(progressInfo); _optionService.SaveOrUpdate(options); break; case "Tasks": jsonReader.Read(); var tasks = _serializer.Deserialize <ThumbnailTask[]>(jsonReader); progressInfo.Description = $"Importing {tasks.Length} tasks..."; progressCallback(progressInfo); _taskService.SaveOrUpdate(tasks); break; } } } } }
public IHttpActionResult Create(ThumbnailOption option) { _thumbnailOptionService.SaveOrUpdate(new[] { option }); return(Ok(option)); }