private async void DT_Tick(object sender, object e) { DoorLock_Model DoorData = await this.APIConnection.GetDoorState(); if (DoorData != null) { if (DoorData._DoorState == true) { this.StateDisplay_TextBlock.Text = "Door Opened"; if (this.gpio != null) { pinAlteraValue = GpioPinValue.Low; pinDoorValue = GpioPinValue.Low; pinAltera.Write(pinAlteraValue); pinDoor.Write(pinDoorValue); } } else { this.StateDisplay_TextBlock.Text = "Door Closed"; if (this.gpio != null) { pinAlteraValue = GpioPinValue.High; pinDoorValue = GpioPinValue.High; pinAltera.Write(pinAlteraValue); pinDoor.Write(pinDoorValue); } } } }
public async Task <bool> UpdateDoorState(DoorLock_Model data) { try { string path = $"v1/public/updatedoorstate"; using (HttpResponseMessage response = await ApiHelper.ApiClient.PostAsync(path, data, new System.Net.Http.Formatting.JsonMediaTypeFormatter())) { if (response.IsSuccessStatusCode) { var results = await response.Content.ReadAsAsync <bool>(); return(results); } else { throw new Exception(response.ReasonPhrase); } } } catch (Exception ex) { Console.WriteLine(ex.Message); return(false); } }
public DataFormat <DoorLock_Model> GetDoor() { DoorLock_Model data = this.DataBase.GetDoorState(); var outPut = new DataStracture <DoorLock_Model>().GetDataFormat(data); return(outPut); }
private async void CloseDoor_Button_Click(object sender, EventArgs e) { DoorLock_Model tempoData = new DoorLock_Model(); tempoData._DoorState = false; bool resluts = await this.ApiConnection.UpdateDoorState(tempoData); if (resluts == false) { MessageBox.Show("Door Failed to open : Please check your internet connection"); } }
private async void DataFetcher_Timer_Tick(object sender, EventArgs e) { try { DoorLock_Model tempoData = await this.ApiConnection.GetDoorState(); if (tempoData != null) { if (tempoData._DoorState == true) { this.DoorStateDisplay_Label.Text = "Door is -->> Opened"; } else { this.DoorStateDisplay_Label.Text = "Door is -->> Closed"; } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public bool UpdateDoorState([FromBody] DoorLock_Model data) { bool outPut = this.DataBase.UpdateDoorState(data._DoorState); return(outPut); }