Example #1
0
        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));
        }
Example #2
0
        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));
        }
Example #3
0
        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));
        }