public IActionResult Put(string id, [FromBody] string value) { if (id == null) { return(StatusCode(400, "Provide ID for data")); } var updateddata = _context.UpdatedData.SingleOrDefault(u => u.DataID.Equals(id)); if (updateddata == null) { return(StatusCode(400, "Data ID not found in database")); } if (!updateddata.Active) { return(StatusCode(200, UpdatedData.GetPointers(updateddata))); } HttpClient client = new HttpClient(); client.BaseAddress = new Uri(@"http://localhost:5000/api/updates"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); HttpContent content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(updateddata)); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage rm = client.PostAsync("", content).Result; return(StatusCode(400, rm.StatusCode.ToString() + rm.Content.ToString())); // //return StatusCode(400, "Request type not supported"); }
/// <inheritdoc/> public override int GetHashCode() { unchecked { return(((UpdatedData != null ? UpdatedData.GetHashCode() : 0) * 397) ^ SendBack.GetHashCode()); } }
public IActionResult Post([FromBody] dynamic value) { string s = value.ToString(); UpdatedData d = JsonConvert.DeserializeObject <UpdatedData>(s); d.DataID = Guid.NewGuid().ToString(); d.Active = true; d.UpdateDateTimeTicks = DateTime.Now.Ticks.ToString(); try { UpdatedData lastUpdatedDataInDomain = _context.UpdatedData.Where(u => u.UpdatedDomain.Equals(d.UpdatedDomain)).OrderByDescending(t => t.UpdateDateTimeTicks).FirstOrDefault(); lastUpdatedDataInDomain.NextDataID = d.DataID; _context.Update(lastUpdatedDataInDomain); } catch (System.NullReferenceException) { return(StatusCode(401, "Domain does not exist")); } _context.Add(d); _context.SaveChanges(); HttpClient client = new HttpClient(); client.BaseAddress = new Uri(@"http://localhost:5000/api/updates"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); HttpContent content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(d)); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage rm = client.PostAsync("", content).Result; return(StatusCode(201, d.DataID)); }
public MainModel() { Device.StartTimer(TimeSpan.FromSeconds(1), () => { UpdatedData?.Invoke(this, new DataEventArgs() { Count = _count }); _count++; return(true); }); }
public void StartCounter() { Device.StartTimer(TimeSpan.FromSeconds(1), () => { UpdatedData?.Invoke(this, new DataEventArgs() { Count = count }); count++; return(true); }); }
/// <inheritdoc/> public bool Equals(Gossip other) { if (ReferenceEquals(other, null)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(other.SendBack.Equals(SendBack) && UpdatedData.SequenceEqual(other.UpdatedData)); }
public IActionResult Get(string id) { if (id == null) { return(StatusCode(400, "Provide ID for data")); } var updateddata = _context.UpdatedData.SingleOrDefault(u => u.DataID.Equals(id)); if (updateddata == null) { return(StatusCode(400, "Data ID not found in database")); } if (!updateddata.Active) { return(StatusCode(200, UpdatedData.GetPointers(updateddata))); } return(StatusCode(200, updateddata)); }
// POST api/values public List <UpdatedData> Post([FromBody] List <ReceivedData> DataStream) { var violatedData = new List <UpdatedData>(); foreach (var data in DataStream) { //To process the incoming Stream UpdatedData datareceived = new UpdatedData(data); datareceived.Process(data); //To save the incoming Stream in a Database _context.UpdatedDatas.Add(datareceived); _context.SaveChanges(); //If signal has violated a rule then show that signal to User if (datareceived.CorrectSignal == false) { violatedData.Add(datareceived); } } return(violatedData); }