public async Task <IHttpActionResult> Get(Guid id) { Location location = await db.Locations.FindAsync(id); if (location == null) { return(NotFound()); } //signalr LocationHub hub = new LocationHub(); await hub.SendNotifications(string.Empty); return(Ok(location)); }
public async Task <IHttpActionResult> Post(Location location) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Locations.Add(location); await db.SaveChangesAsync(); //signalr LocationHub hub = new LocationHub(); await hub.SendNotifications(string.Empty); return(CreatedAtRoute("DefaultApi", new { id = location.Id }, location)); }
public async Task <IHttpActionResult> Put(Guid id, Location location) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != location.Id) { return(BadRequest()); } db.Entry(location).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LocationExists(id)) { return(NotFound()); } else { throw; } } //signalr LocationHub hub = new LocationHub(); await hub.SendNotifications(string.Empty); return(StatusCode(HttpStatusCode.NoContent)); }