//Pushing UUID to DB internal async Task <bool> PushDeviceIdentifierAsync(string uuid) { DevicePost deviceIdentifier = new DevicePost(uuid); var json = JsonConvert.SerializeObject(deviceIdentifier); HttpContent httpContent = new StringContent(json); httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var result = await _client.PostAsync(getPostUrl(), httpContent); return(result.IsSuccessStatusCode); }
public Response Post(DevicePost theModel) { List <BBDeviceProperties> UpdatedDevices = new List <BBDeviceProperties>(); List <BBDeviceEvent> Events = new List <BBDeviceEvent>(); if (theModel.EventId != null) { for (int i = 0; i < theModel.EventId.Length; i++) { int io = 0; if (Int32.TryParse(theModel.IONumber[i], out io)) { Events.Add(new BBDeviceEvent { IONumber = io, Id = theModel.EventId[i], Description = theModel.EventDescription[i], RisingEdgeValue = theModel.High[i], FallingEdgeValue = theModel.Low[i] }); } } } if (theModel != null && theModel.Guid != null && theModel.Name != null) { UpdatedDevices.Add(new BBDeviceProperties { Guid = theModel.Guid, IP = theModel.IPAddress, Name = theModel.Name, IOEvents = Events.ToArray() }); } Core.Instance.Update(UpdatedDevices.ToArray()); return(new Response { Location = Context.Request, StatusCode = System.Net.HttpStatusCode.Moved }); }