private bool VerifyEntry(SendEntry entry) { bool isGoodEntry = true; if (string.IsNullOrEmpty(entry.ObservatoryId)) { isGoodEntry = false; epEntry.SetError(cbObservatory, "Observatory not provided"); epEntry.BlinkRate = 0; } if (string.IsNullOrEmpty(entry.SecretKey)) { isGoodEntry = false; epEntry.SetError(tbSecretKey, "Secret Key not provided"); epEntry.BlinkRate = 0; } if (string.IsNullOrEmpty(entry.Tags)) { isGoodEntry = false; epEntry.SetError(tbTag, "Tag not provided"); epEntry.BlinkRate = 0; } if (string.IsNullOrEmpty(entry.Value)) { isGoodEntry = false; epEntry.SetError(tbValue, "Value not provided"); epEntry.BlinkRate = 0; } return(isGoodEntry); }
private SendEntry CreateEntry() { SendEntry entry = new SendEntry() { ObservatoryId = cbObservatory.SelectedItem.ToString(), SecretKey = tbSecretKey.Text, Tags = tbTag.Text, Value = tbValue.Text }; return(entry); }
private void ManageSendEntry() { SendEntry entry = CreateEntry(); if (VerifyEntry(entry)) { if (cowabooService.SendEntry(entry)) { RefreshView(entry.ObservatoryId); } else { epEntry.SetError(btnSubmit, "Invalid request"); } } }
internal bool SendEntry(SendEntry entry) { RestClient client = new RestClient(urlCowaboo); RestRequest request = new RestRequest("entry", Method.POST); request.AddParameter("secretKey", entry.SecretKey); request.AddParameter("observatoryId", entry.ObservatoryId); request.AddParameter("tags", entry.Tags); request.AddParameter("value", entry.Value); IRestResponse response = client.Execute(request); if (!response.IsSuccessful) { return(false); } return(true); }