public IHttpActionResult PutIot(int id, Iot iot) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != iot.Id) { return(BadRequest()); } db.Entry(iot).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!IotExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetIot(int id) { Iot iot = await new IotService(_db).GetIotsAsync(id); if (iot == null) { return(NotFound()); } return(Ok(iot)); }
public IHttpActionResult GetIot(int id) { Iot iot = db.Iots.Find(id); if (iot == null) { return(NotFound()); } return(Ok(iot)); }
public IHttpActionResult DeleteIot(int id) { Iot iot = db.Iots.Find(id); if (iot == null) { return(NotFound()); } db.Iots.Remove(iot); db.SaveChanges(); return(Ok(iot)); }
public IHttpActionResult PostIot(Iot iot) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Iots.Add(iot); IEnumerable <Constituent> Constituents = iot.Constituents; db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = iot.Id }, iot)); }