예제 #1
0
        public async Task <IActionResult> Putiot_weatherforecast(long id, iot_weatherforecast iot_weatherforecast)
        {
            if (id != iot_weatherforecast.id)
            {
                return(BadRequest());
            }

            _context.Entry(iot_weatherforecast).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!iot_weatherforecastExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            var lMsg  = new ServerUpdateHubMsg(_entity, ServerUpdateHubMsg.TOperation.UPDATE, id);
            var lJson = JsonConvert.SerializeObject(lMsg);
            await _hubContext.Clients.All.SendAsync(lMsg.entity, lJson);

            return(NoContent());
        }
예제 #2
0
        public async Task <ActionResult <iot_weatherforecast> > Postiot_weatherforecast(iot_weatherforecast iot_weatherforecast)
        {
            _context.iot_weatherforecast.Add(iot_weatherforecast);
            await _context.SaveChangesAsync();

            var lMsg  = new ServerUpdateHubMsg(_entity, ServerUpdateHubMsg.TOperation.INSERT, iot_weatherforecast.id);
            var lJson = JsonConvert.SerializeObject(lMsg);
            await _hubContext.Clients.All.SendAsync(lMsg.entity, lJson);

            return(CreatedAtAction("Getiot_weatherforecast", new { id = iot_weatherforecast.id }, iot_weatherforecast));
        }