PageRenderTime 43ms CodeModel.GetById 19ms RepoModel.GetById 0ms 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
Possible License(s): MIT
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Net.Http;
  6. using System.Web.Http;
  7. using System.Web.Http.Description;
  8. using DeviceHive.API.Filters;
  9. using DeviceHive.API.Mapping;
  10. using DeviceHive.Data.Model;
  11. using Newtonsoft.Json.Linq;
  12. namespace DeviceHive.API.Controllers
  13. {
  14. [ApiExplorerSettings(IgnoreApi = true)]
  15. public class CronController : BaseController
  16. {
  17. [HttpGet]
  18. [HttpNoContentResponse]
  19. public void RefreshDeviceStatus()
  20. {
  21. var devices = DataContext.Device.GetOfflineDevices();
  22. foreach (var device in devices)
  23. {
  24. device.Status = "Offline";
  25. DataContext.Device.Save(device);
  26. }
  27. }
  28. }
  29. }