public HttpResponseMessage Save([FromBody] Secrets secrets) { PersonaBarResponse response = new PersonaBarResponse(); if (!ModelState.IsValid || secrets == null) { response.Success = false; return(response.ToHttpResponseMessage()); } try { var isValid = SecretsProvider.ValidateSecrets(secrets); if (!isValid) { response.Success = false; return(response.ToHttpResponseMessage()); } File.WriteAllText(SecretsProvider.SecretsFile, JsonConvert.SerializeObject(secrets)); response.Success = true; return(response.ToHttpResponseMessage()); } catch (Exception ex) { ex.Handle(); return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }
public HttpResponseMessage Status() { PersonaBarResponse response = new PersonaBarResponse(); if (!File.Exists(SecretsProvider.SecretsFile)) { response.Success = false; return(response.ToHttpResponseMessage()); } var json = File.ReadAllText(SecretsProvider.SecretsFile); var secrets = JsonConvert.DeserializeObject <Secrets>(json); if (!SecretsProvider.ValidateSecrets(secrets)) { response.Success = false; return(response.ToHttpResponseMessage()); } var xml = XDocument.Load(SecretsProvider.WebconfigFile); var doc = xml.Element("configuration"); var connectionString = doc.Element("connectionStrings"); response.Success = connectionString == null; return(response.ToHttpResponseMessage()); }
public HttpResponseMessage Test([FromBody] Secrets secrets) { PersonaBarResponse response = new PersonaBarResponse(); if (!ModelState.IsValid || secrets == null) { response.Success = false; return(response.ToHttpResponseMessage()); } try { response.Success = SecretsProvider.ValidateSecrets(secrets); return(response.ToHttpResponseMessage()); } catch (Exception ex) { ex.Handle(); return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }