PageRenderTime 17ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/Server/DeviceHive.API/Controllers/CronController.cs

https://github.com/oryol/devicehive-.net
C# | 30 lines | 29 code | 1 blank | 0 comment | 0 complexity | 94157df84ff3b6cfbc04fda6630e8f8f MD5 | raw file
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using System.Net;
 5using System.Net.Http;
 6using System.Web.Http;
 7using System.Web.Http.Description;
 8using DeviceHive.API.Filters;
 9using DeviceHive.API.Mapping;
10using DeviceHive.Data.Model;
11using Newtonsoft.Json.Linq;
12
13namespace DeviceHive.API.Controllers
14{
15    [ApiExplorerSettings(IgnoreApi = true)]
16    public class CronController : BaseController
17    {
18        [HttpGet]
19        [HttpNoContentResponse]
20        public void RefreshDeviceStatus()
21        {
22            var devices = DataContext.Device.GetOfflineDevices();
23            foreach (var device in devices)
24            {
25                device.Status = "Offline";
26                DataContext.Device.Save(device);
27            }
28        }
29    }
30}