Web API, changed loading of default to happen when no preset is received - to allow proper structure from previously-loaded preset to be overwritten

This commit is contained in:
Heath Volmer
2017-02-13 14:02:11 -07:00
parent 29346bae8f
commit 309d6df98e
15 changed files with 23 additions and 5 deletions

View File

@@ -125,12 +125,13 @@ namespace PepperDash.Core.WebApi.Presets
var client = new HttpsClient();
client.HostVerification = false;
client.PeerVerification = false;
// ask for the preset
var resp = client.Dispatch(req);
if (resp.Code == 200)
if (resp.Code == 200) // got it
{
Debug.Console(1, this, "Received: {0}", resp.ContentString);
var preset = JsonConvert.DeserializeObject<Preset>(resp.ContentString);
CurrentPreset = preset;
//if there's no preset data, load the template
@@ -145,6 +146,11 @@ namespace PepperDash.Core.WebApi.Presets
var handler = PresetReceived;
if (handler != null)
PresetReceived(this, new PresetReceivedEventArgs(preset));
}
else // no existing preset
{
CurrentPreset = new Preset();
LoadDefaultPresetData();
}
}
catch (HttpException e)