diff --git a/MyCore/Controllers/DeviceController.cs b/MyCore/Controllers/DeviceController.cs deleted file mode 100644 index b0ddbbf..0000000 --- a/MyCore/Controllers/DeviceController.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using MongoDB.Bson; -using MyCore.Models; -using MyCore.Services; - -namespace MyCore.Controllers -{ - [Authorize(Roles = "Admin")] - [Route("api/device")] - [ApiController] - public class DeviceController : ControllerBase - { - private readonly DeviceService _DeviceService; - - public DeviceController(DeviceService DeviceService) - { - _DeviceService = DeviceService; - } - - // GET: Devices - /// - /// - /// - [HttpGet] - public ActionResult> GetAllDevices() - { - return _DeviceService.GetAll(); - } - - // GET: Device - /// - /// - /// - /// Id of the device you want to get information - [HttpGet("{idDevice}")] - public ActionResult GetDeviceInfo(string idDevice) - { - return _DeviceService.GetDeviceInfo(idDevice); - } - - // POST: Device/Create - /// - /// - /// - [HttpPost] - public IActionResult CreateDevice(int idDevice, [FromBody] Device device) - { - if (idDevice == 0) - { - _DeviceService.CreateDevice(device); - - return StatusCode(201); - } - return StatusCode(500); - } - - // PUT: Device/Update - /// - /// - /// - [HttpPut("{idDevice}")] - public IActionResult UpdateDevice(int idDevice, [FromBody] Device device) - { - if (idDevice == 0) - { - _DeviceService.Update(device.Id, device); - - return StatusCode(201); - } - return StatusCode(500); - } - - // Delete: Device/Delete - /// - /// - /// - [HttpDelete("{idDevice}")] - public IActionResult DeleteDevice(int idDevice, [FromBody] string deviceId) - { - if (idDevice == 0) - { - _DeviceService.Remove(deviceId); - - return StatusCode(201); - } - return StatusCode(500); - } - } -} \ No newline at end of file diff --git a/MyCore/Controllers/Devices/IoThomas/EnergyController.cs b/MyCore/Controllers/Devices/IoThomas/EnergyController.cs new file mode 100644 index 0000000..f965c5f --- /dev/null +++ b/MyCore/Controllers/Devices/IoThomas/EnergyController.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using MQTTnet; +using MQTTnet.Client; +using MQTTnet.Server; +using MyCore.DTO.Energy; +using MyCore.Models; +using MyCore.Models.Energy; +using MyCore.Services; +using static MyCore.Services.OddService; + +namespace MyCore.Controllers +{ + [Authorize(Roles = "Admin")] + [Route("api/energy")] + [ApiController] + public class EnergyController : ControllerBase + { + + private readonly EnergyService _EnergyService; + + public EnergyController(EnergyService energyService) + { + _EnergyService = energyService; + } + + // GET api/energy/electricity/year + /// + /// Get summary production of Kwh/Year + /// + [HttpGet("electricity")] + public ActionResult> GetElectricityProduction(string userId, ViewBy viewBy) + { + try + { + switch (viewBy) + { + case ViewBy.Year: + return _EnergyService.GetElectricityProductionForSpecifiedYear(userId, DateTime.Now.Year); + break; + case ViewBy.Month: + return _EnergyService.GetElectricityProductionForSpecifiedMonth(userId, DateTime.Now.Month); + break; + case ViewBy.Day: + return _EnergyService.GetElectricityProductionForSpecifiedDay(userId, DateTime.Now.DayOfYear); + break; + default: + return new ObjectResult("Error - ViewBy incorrect") { StatusCode = 500 }; + break; + } + } + catch (Exception e) + { + Console.WriteLine(e); + + return new ObjectResult("Error - TODO") { StatusCode = 500 }; + } + } + + + + } +} diff --git a/MyCore/Controllers/IOTController.cs b/MyCore/Controllers/Devices/IoThomas/IOTController.cs similarity index 100% rename from MyCore/Controllers/IOTController.cs rename to MyCore/Controllers/Devices/IoThomas/IOTController.cs diff --git a/MyCore/Controllers/OddController.cs b/MyCore/Controllers/Devices/IoThomas/OddController.cs similarity index 100% rename from MyCore/Controllers/OddController.cs rename to MyCore/Controllers/Devices/IoThomas/OddController.cs diff --git a/MyCore/Controllers/Devices/ScreenDeviceController.cs b/MyCore/Controllers/Devices/ScreenDeviceController.cs new file mode 100644 index 0000000..9aa1ed5 --- /dev/null +++ b/MyCore/Controllers/Devices/ScreenDeviceController.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using MongoDB.Bson; +using MyCore.Models; +using MyCore.Services; + +namespace MyCore.Controllers +{ + [Authorize(Roles = "Admin")] + [Route("api/device/screen")] + [ApiController] + public class ScreenDeviceController : ControllerBase + { + private readonly ScreenDeviceService _ScreenDeviceService; + + public ScreenDeviceController(ScreenDeviceService ScreenDeviceService) + { + _ScreenDeviceService = ScreenDeviceService; + } + + // GET: Devices + /// + /// + /// + [ProducesResponseType(typeof(List), 200)] + [HttpGet] + public ObjectResult GetAllScreenDevices() + { + try + { + List screenDevices = _ScreenDeviceService.GetAll(); + + return new OkObjectResult(screenDevices); + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + } + + // GET: ScreenDevice + /// + /// + /// + /// Id of the screen device you want to get information + [ProducesResponseType(typeof(ScreenDevice), 200)] + [HttpGet("{idScreenDevice}")] + public ObjectResult GetDeviceInfo(string idScreenDevice) + { + try + { + ScreenDevice screenDevice = _ScreenDeviceService.GetInfo(idScreenDevice); + + return new OkObjectResult(screenDevice); + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + } + + // POST: Device/Create + /// + /// + /// + [HttpPost] + public ObjectResult CreateDevice([FromBody] ScreenDevice screenDevice) + { + try + { + _ScreenDeviceService.Create(screenDevice); + + return new OkObjectResult(201); + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + } + + // PUT: Device/Update + /// + /// + /// + [HttpPut("{idScreenDevice}")] + public ObjectResult UpdateDevice(int idScreenDevice, [FromBody] ScreenDevice screenDevice) + { + try + { + _ScreenDeviceService.Update(screenDevice.Id, screenDevice); + + return new OkObjectResult(201); + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + } + + // Delete: Device/Delete + /// + /// + /// + [HttpDelete("{idDevice}")] + public ObjectResult DeleteDevice(int idDevice, [FromBody] string deviceId) + { + try + { + _ScreenDeviceService.Remove(deviceId); + + return new OkObjectResult(201); + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + } + } +} \ No newline at end of file diff --git a/MyCore/Controllers/MQTTController.cs b/MyCore/Controllers/Helpers/MQTTController.cs similarity index 100% rename from MyCore/Controllers/MQTTController.cs rename to MyCore/Controllers/Helpers/MQTTController.cs diff --git a/MyCore/Controllers/LayoutController.cs b/MyCore/Controllers/MyControlPanel/LayoutController.cs similarity index 95% rename from MyCore/Controllers/LayoutController.cs rename to MyCore/Controllers/MyControlPanel/LayoutController.cs index ec946f0..480cca1 100644 --- a/MyCore/Controllers/LayoutController.cs +++ b/MyCore/Controllers/MyControlPanel/LayoutController.cs @@ -30,6 +30,13 @@ namespace MyCore.Controllers { List panelSectionList = new List(); + // Main view + /*PanelSection panelSectionMain = new PanelSection(); + panelSectionMain.Label = "Main"; + panelSectionMain.Icon = "fas fa-eye"; + panelSectionMain.DefaultRoute = "main"; + panelSectionMain.Color = "red";*/ + // Energy PanelSection panelSectionEnergy = new PanelSection(); panelSectionEnergy.Label = "Energy"; diff --git a/MyCore/Controllers/TokenController.cs b/MyCore/Controllers/MyControlPanel/TokenController.cs similarity index 100% rename from MyCore/Controllers/TokenController.cs rename to MyCore/Controllers/MyControlPanel/TokenController.cs diff --git a/MyCore/Controllers/UserController.cs b/MyCore/Controllers/MyControlPanel/UserController.cs similarity index 100% rename from MyCore/Controllers/UserController.cs rename to MyCore/Controllers/MyControlPanel/UserController.cs diff --git a/MyCore/DTO/Common/ConnectionStatus.cs b/MyCore/DTO/Common/ConnectionStatus.cs new file mode 100644 index 0000000..c7021f1 --- /dev/null +++ b/MyCore/DTO/Common/ConnectionStatus.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace MyCore.DTO.Common +{ + public enum ConnectionStatus + { + Connected = 1, + Disconnected, + Unknown + } +} diff --git a/MyCore/DTO/Common/MeansOfCommunication.cs b/MyCore/DTO/Common/MeansOfCommunication.cs new file mode 100644 index 0000000..6804a77 --- /dev/null +++ b/MyCore/DTO/Common/MeansOfCommunication.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace MyCore.DTO.Common +{ + public enum MeansOfCommunication + { + Wifi = 1, + Bluetooth, + Zigbee, + Zwave + } +} diff --git a/MyCore/DTO/RequestParam.cs b/MyCore/DTO/Common/RequestParam.cs similarity index 100% rename from MyCore/DTO/RequestParam.cs rename to MyCore/DTO/Common/RequestParam.cs diff --git a/MyCore/DTO/Common/ViewBy.cs b/MyCore/DTO/Common/ViewBy.cs new file mode 100644 index 0000000..485d442 --- /dev/null +++ b/MyCore/DTO/Common/ViewBy.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace MyCore.DTO.Energy +{ + public enum ViewBy + { + Year = 1, + Month, + Day + } +} diff --git a/MyCore/DTO/TokenDTO.cs b/MyCore/DTO/MyControlPanel/TokenDTO.cs similarity index 100% rename from MyCore/DTO/TokenDTO.cs rename to MyCore/DTO/MyControlPanel/TokenDTO.cs diff --git a/MyCore/Models/LightState.cs b/MyCore/Models/Common/LightState.cs similarity index 100% rename from MyCore/Models/LightState.cs rename to MyCore/Models/Common/LightState.cs diff --git a/MyCore/Models/Common/LogDatabase.cs b/MyCore/Models/Common/LogDatabase.cs new file mode 100644 index 0000000..26ee35f --- /dev/null +++ b/MyCore/Models/Common/LogDatabase.cs @@ -0,0 +1,33 @@ +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace MyCore.Models.Common +{ + public class LogDatabase // TODO + { + [BsonId] + [BsonRepresentation(BsonType.ObjectId)] + public int Id { get; set; } + + [BsonElement("Time")] + public DateTime Time { get; set; } + + [BsonElement("Level")] + public int Level { get; set; } + + [BsonElement("Message")] + public string Message { get; set; } + + [BsonElement("Sent")] + public bool Sent { get; set; } + } +} + + + + + diff --git a/MyCore/Models/Automation.cs b/MyCore/Models/MyControlPanel/Automation.cs similarity index 59% rename from MyCore/Models/Automation.cs rename to MyCore/Models/MyControlPanel/Automation.cs index bace742..ffbe908 100644 --- a/MyCore/Models/Automation.cs +++ b/MyCore/Models/MyControlPanel/Automation.cs @@ -1,20 +1,34 @@ -using System; +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; +using MyCore.DTO.Common; +using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace MyCore.Models { + /// + /// Automation + /// public class Automation { + [BsonId] + [BsonRepresentation(BsonType.ObjectId)] public string Id { get; set; } + + [BsonElement("Name")] public string Name { get; set; } - public List Declencheurs { get; set; } + + [BsonElement("Triggers")] + public List Triggers { get; set; } + + [BsonElement("Conditions")] public List Conditions { get; set; } + + [BsonElement("Actions")] public List Actions { get; set; } } - public class Declencheur + public class Trigger { public enum Type { diff --git a/MyCore/Models/MyControlPanel/Device.cs b/MyCore/Models/MyControlPanel/Device.cs new file mode 100644 index 0000000..a0d51cb --- /dev/null +++ b/MyCore/Models/MyControlPanel/Device.cs @@ -0,0 +1,57 @@ +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; +using MyCore.DTO.Common; +using System; +using System.Collections.Generic; + +namespace MyCore.Models.MyControlPanel +{ + /// + /// Group of devices + /// + public class Device + { + [BsonId] + [BsonRepresentation(BsonType.ObjectId)] + public string Id { get; set; } + + [BsonElement("Name")] + public string Name { get; set; } + + [BsonElement("ConnectionStatus")] + public ConnectionStatus ConnectionStatus { get; set; } + + [BsonElement("Location")] + public Location Location { get; set; } + + [BsonElement("MeansOfCommunications")] + public List MeansOfCommunications { get; set; } + + [BsonElement("CreatedDate")] + public DateTime CreatedDate { get; set; } + + [BsonElement("UpdatedDate")] + public DateTime UpdatedDate { get; set; } + + [BsonElement("LastMessage")] + public string LastMessage { get; set; } // TODO UNIFORMISATION ? + + [BsonElement("LastMessageDate")] + public DateTime LastMessageDate { get; set; } + + [BsonElement("Battery")] + public bool Battery { get; set; } + + [BsonElement("BatteryStatus")] + public int BatteryStatus { get; set; } + + [BsonElement("Provider")] + public Provider provider { get; set; } + + [BsonElement("Groups")] + public List Groups { get; set; } + + [BsonElement("Informations")] + public List Informations { get; set; } + } +} diff --git a/MyCore/Models/MyControlPanel/Group.cs b/MyCore/Models/MyControlPanel/Group.cs new file mode 100644 index 0000000..b4b598b --- /dev/null +++ b/MyCore/Models/MyControlPanel/Group.cs @@ -0,0 +1,23 @@ +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; +using MyCore.DTO.Common; +using System; +using System.Collections.Generic; +namespace MyCore.Models.MyControlPanel +{ + /// + /// Group of devices + /// + public class Group + { + [BsonId] + [BsonRepresentation(BsonType.ObjectId)] + public string Id { get; set; } + + [BsonElement("Name")] + public string Name { get; set; } + + [BsonElement("Devices")] + public List Devices { get; set; } + } +} diff --git a/MyCore/Models/MyControlPanel/Information.cs b/MyCore/Models/MyControlPanel/Information.cs new file mode 100644 index 0000000..c8a3522 --- /dev/null +++ b/MyCore/Models/MyControlPanel/Information.cs @@ -0,0 +1,24 @@ +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; +using MyCore.DTO.Common; +using System; +using System.Collections.Generic; + +namespace MyCore.Models.MyControlPanel +{ + /// + /// Information contains in device message + /// + public class Information + { + [BsonId] + [BsonRepresentation(BsonType.ObjectId)] + public string Id { get; set; } + + [BsonElement("Name")] + public string Name { get; set; } + + [BsonElement("Value")] + public object Value { get; set; } + } +} diff --git a/MyCore/Models/Layout/PanelSection.cs b/MyCore/Models/MyControlPanel/Layout/PanelSection.cs similarity index 100% rename from MyCore/Models/Layout/PanelSection.cs rename to MyCore/Models/MyControlPanel/Layout/PanelSection.cs diff --git a/MyCore/Models/MyControlPanel/Location.cs b/MyCore/Models/MyControlPanel/Location.cs new file mode 100644 index 0000000..6c32a4e --- /dev/null +++ b/MyCore/Models/MyControlPanel/Location.cs @@ -0,0 +1,18 @@ +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; + +namespace MyCore.Models.MyControlPanel +{ + /// + /// Location of a device (Room name, garden, ..) + /// + public class Location + { + [BsonId] + [BsonRepresentation(BsonType.ObjectId)] + public string Id { get; set; } + + [BsonElement("Name")] + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/MyCore/Models/MyControlPanel/Provider.cs b/MyCore/Models/MyControlPanel/Provider.cs new file mode 100644 index 0000000..aa04e08 --- /dev/null +++ b/MyCore/Models/MyControlPanel/Provider.cs @@ -0,0 +1,30 @@ +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; +using MyCore.DTO.Common; +using System; +using System.Collections.Generic; + +namespace MyCore.Models.MyControlPanel +{ + /// + /// Provider of a device (provider of informations) - e.g. : Meross, Arlo, IoThomas, ... + /// + public class Provider + { + [BsonId] + [BsonRepresentation(BsonType.ObjectId)] + public string Id { get; set; } + + [BsonElement("Name")] + public string Name { get; set; } + + [BsonElement("Username")] + public string Username { get; set; } + + [BsonElement("Password")] + public string Password { get; set; } // TODO ENCRYPTED + + [BsonElement("ApiKey")] + public string ApiKey { get; set; } // TODO ENCRYPTED + } +} diff --git a/MyCore/Models/UserInfo.cs b/MyCore/Models/MyControlPanel/UserInfo.cs similarity index 75% rename from MyCore/Models/UserInfo.cs rename to MyCore/Models/MyControlPanel/UserInfo.cs index 1aaf287..7de90c2 100644 --- a/MyCore/Models/UserInfo.cs +++ b/MyCore/Models/MyControlPanel/UserInfo.cs @@ -5,9 +5,13 @@ using System.Threading.Tasks; using AspNetCore.Security.Jwt; using MongoDB.Bson; using MongoDB.Bson.Serialization.Attributes; +using MyCore.Models.MyControlPanel; namespace MyCore.Models { + /// + /// User Information + /// public class UserInfo : IAuthenticationUser { [BsonId] @@ -59,11 +63,24 @@ namespace MyCore.Models [BsonElement("PostalCode")] public int PostalCode { get; set; } - [BsonElement("ScreenConfigurationIds")] + [BsonElement("Automations")] + public Automation[] Automations { get; set; } + + [BsonElement("Devices")] + public Device[] Devices { get; set; } + + [BsonElement("Providers")] + public Provider[] Providers { get; set; } + + [BsonElement("Groups")] + public Group[] Groups { get; set; } + + // TODO + /*[BsonElement("ScreenConfigurationIds")] public ScreenConfiguration[] ScreenConfigurationIds { get; set; } [BsonElement("DeviceIds")] - public Device[] DeviceIds { get; set; } + public ScreenDevice[] DeviceIds { get; set; }*/ } } diff --git a/MyCore/Models/Arlo/ArloDevice.cs b/MyCore/Models/Providers/Arlo/ArloDevice.cs similarity index 100% rename from MyCore/Models/Arlo/ArloDevice.cs rename to MyCore/Models/Providers/Arlo/ArloDevice.cs diff --git a/MyCore/Models/Arlo/UserLocation.cs b/MyCore/Models/Providers/Arlo/UserLocation.cs similarity index 100% rename from MyCore/Models/Arlo/UserLocation.cs rename to MyCore/Models/Providers/Arlo/UserLocation.cs diff --git a/MyCore/Models/Arlo/UserMedia.cs b/MyCore/Models/Providers/Arlo/UserMedia.cs similarity index 100% rename from MyCore/Models/Arlo/UserMedia.cs rename to MyCore/Models/Providers/Arlo/UserMedia.cs diff --git a/MyCore/Models/Providers/IoThomas/Energy/ElectricityProduction.cs b/MyCore/Models/Providers/IoThomas/Energy/ElectricityProduction.cs new file mode 100644 index 0000000..081ee49 --- /dev/null +++ b/MyCore/Models/Providers/IoThomas/Energy/ElectricityProduction.cs @@ -0,0 +1,32 @@ +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace MyCore.Models.Energy +{ + public class ElectricityProduction + { + [BsonId] + [BsonRepresentation(BsonType.ObjectId)] + public string Id { get; set; } + + [BsonElement("DeviceId")] + public string DeviceId { get; set; } + + [BsonElement("UserId")] + public string UserId { get; set; } + + [BsonElement("Watt")] + public double Watt { get; set; } + + [BsonElement("Ampere")] + public double Ampere { get; set; } + + [BsonElement("Timestamp")] + public DateTime Timestamp { get; set; } + + } +} diff --git a/MyCore/Models/SmartGardenMessage.cs b/MyCore/Models/Providers/IoThomas/SmartGardenMessage.cs similarity index 100% rename from MyCore/Models/SmartGardenMessage.cs rename to MyCore/Models/Providers/IoThomas/SmartGardenMessage.cs diff --git a/MyCore/Models/SmartPrinterMessage.cs b/MyCore/Models/Providers/IoThomas/SmartPrinterMessage.cs similarity index 100% rename from MyCore/Models/SmartPrinterMessage.cs rename to MyCore/Models/Providers/IoThomas/SmartPrinterMessage.cs diff --git a/MyCore/Models/Meross/DevicesAbilities.cs b/MyCore/Models/Providers/Meross/DevicesAbilities.cs similarity index 100% rename from MyCore/Models/Meross/DevicesAbilities.cs rename to MyCore/Models/Providers/Meross/DevicesAbilities.cs diff --git a/MyCore/Models/Meross/MerossDevice.cs b/MyCore/Models/Providers/Meross/MerossDevice.cs similarity index 100% rename from MyCore/Models/Meross/MerossDevice.cs rename to MyCore/Models/Providers/Meross/MerossDevice.cs diff --git a/MyCore/Models/Aqara/Cube.cs b/MyCore/Models/Providers/Zigbee/Aqara/Cube.cs similarity index 100% rename from MyCore/Models/Aqara/Cube.cs rename to MyCore/Models/Providers/Zigbee/Aqara/Cube.cs diff --git a/MyCore/Models/Ikea/LightBulb.cs b/MyCore/Models/Providers/Zigbee/Ikea/LightBulb.cs similarity index 100% rename from MyCore/Models/Ikea/LightBulb.cs rename to MyCore/Models/Providers/Zigbee/Ikea/LightBulb.cs diff --git a/MyCore/Models/ScreenConfiguration.cs b/MyCore/Models/Screen/ScreenConfiguration.cs similarity index 100% rename from MyCore/Models/ScreenConfiguration.cs rename to MyCore/Models/Screen/ScreenConfiguration.cs diff --git a/MyCore/Models/Device.cs b/MyCore/Models/Screen/ScreenDevice.cs similarity index 85% rename from MyCore/Models/Device.cs rename to MyCore/Models/Screen/ScreenDevice.cs index 7700812..1b32c39 100644 --- a/MyCore/Models/Device.cs +++ b/MyCore/Models/Screen/ScreenDevice.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace MyCore.Models { - public class Device + public class ScreenDevice { [BsonId] [BsonRepresentation(BsonType.ObjectId)] @@ -26,10 +26,10 @@ namespace MyCore.Models public string LocationExplanation { get; set; } [BsonElement("Height")] - public int Height { get; set; } + public int Height { get; set; } // ? [BsonElement("Width")] - public int Width { get; set; } + public int Width { get; set; } // ? } } diff --git a/MyCore/Models/Widget.cs b/MyCore/Models/Screen/Widgets/Widget.cs similarity index 100% rename from MyCore/Models/Widget.cs rename to MyCore/Models/Screen/Widgets/Widget.cs diff --git a/MyCore/Models/WidgetAgenda.cs b/MyCore/Models/Screen/Widgets/WidgetAgenda.cs similarity index 100% rename from MyCore/Models/WidgetAgenda.cs rename to MyCore/Models/Screen/Widgets/WidgetAgenda.cs diff --git a/MyCore/Models/WidgetHourAndDate.cs b/MyCore/Models/Screen/Widgets/WidgetHourAndDate.cs similarity index 100% rename from MyCore/Models/WidgetHourAndDate.cs rename to MyCore/Models/Screen/Widgets/WidgetHourAndDate.cs diff --git a/MyCore/Models/WidgetMessage.cs b/MyCore/Models/Screen/Widgets/WidgetMessage.cs similarity index 100% rename from MyCore/Models/WidgetMessage.cs rename to MyCore/Models/Screen/Widgets/WidgetMessage.cs diff --git a/MyCore/Models/WidgetNews.cs b/MyCore/Models/Screen/Widgets/WidgetNews.cs similarity index 100% rename from MyCore/Models/WidgetNews.cs rename to MyCore/Models/Screen/Widgets/WidgetNews.cs diff --git a/MyCore/Models/WidgetRadio.cs b/MyCore/Models/Screen/Widgets/WidgetRadio.cs similarity index 100% rename from MyCore/Models/WidgetRadio.cs rename to MyCore/Models/Screen/Widgets/WidgetRadio.cs diff --git a/MyCore/Models/WidgetTraffic.cs b/MyCore/Models/Screen/Widgets/WidgetTraffic.cs similarity index 100% rename from MyCore/Models/WidgetTraffic.cs rename to MyCore/Models/Screen/Widgets/WidgetTraffic.cs diff --git a/MyCore/Models/WidgetWeather.cs b/MyCore/Models/Screen/Widgets/WidgetWeather.cs similarity index 100% rename from MyCore/Models/WidgetWeather.cs rename to MyCore/Models/Screen/Widgets/WidgetWeather.cs diff --git a/MyCore/Services/DeviceService.cs b/MyCore/Services/DeviceService.cs deleted file mode 100644 index 88ad96f..0000000 --- a/MyCore/Services/DeviceService.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using MyCore.Models; -using Microsoft.Extensions.Configuration; -using MongoDB.Driver; - -namespace MyCore.Services -{ - public class DeviceService - { - private readonly IMongoCollection _devices; - - public DeviceService(IConfiguration config) - { - var client = new MongoClient(config.GetConnectionString("MyCoreDb")); - var database = client.GetDatabase("MyCoreDb"); - _devices = database.GetCollection("Devices"); - } - - public List GetAll() - { - return _devices.Find(m => true).ToList(); - } - - public Device GetDeviceInfo(string id) - { - return _devices.Find(m => m.Id == id).FirstOrDefault(); - } - - public Device CreateDevice(Device device) - { - _devices.InsertOne(device); - return device; - } - - public void Update(string id, Device deviceIn) - { - _devices.ReplaceOne(device => device.Id == id, deviceIn); - } - - public void Remove(Device deviceIn) - { - _devices.DeleteOne(device => device.Id == deviceIn.Id); - } - - public void Remove(string id) - { - _devices.DeleteOne(device => device.Id == id); - } - } -} diff --git a/MyCore/Services/ArloService.cs b/MyCore/Services/Devices/ArloService.cs similarity index 100% rename from MyCore/Services/ArloService.cs rename to MyCore/Services/Devices/ArloService.cs diff --git a/MyCore/Services/Devices/IoThomas/EnergyService.cs b/MyCore/Services/Devices/IoThomas/EnergyService.cs new file mode 100644 index 0000000..9a2430b --- /dev/null +++ b/MyCore/Services/Devices/IoThomas/EnergyService.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using MyCore.Models; +using Microsoft.Extensions.Configuration; +using MongoDB.Driver; +using MyCore.Models.Energy; + +namespace MyCore.Services +{ + public class EnergyService + { + private readonly IMongoCollection _electricityProductionData; + + public EnergyService(IConfiguration config) + { + var client = new MongoClient(config.GetConnectionString("MyCoreDb")); + var database = client.GetDatabase("MyCoreDb"); + _electricityProductionData = database.GetCollection("ElectricityProduction"); + } + + public List GetAll() + { + return _electricityProductionData.Find(m => true).ToList(); + } + + public List GetElectricityProductionForSpecifiedYear(string userId, int year) + { + return _electricityProductionData.Find(m => m.UserId == userId && m.Timestamp.Year == year).ToList(); + } + + public List GetElectricityProductionForSpecifiedMonth(string userId, int month) + { + return _electricityProductionData.Find(m => m.UserId == userId && m.Timestamp.Month == month).ToList(); + } + + public List GetElectricityProductionForSpecifiedDay(string userId, int dayOfYear) + { + return _electricityProductionData.Find(m => m.UserId == userId && m.Timestamp.DayOfYear == dayOfYear).ToList(); + } + + // Check if necessary + public ElectricityProduction GetElectricityProductionForUser(string userId) + { + return _electricityProductionData.Find(m => m.UserId == userId).FirstOrDefault(); + } + + public ElectricityProduction InsertData(ElectricityProduction data) + { + _electricityProductionData.InsertOne(data); + return data; + } + + // Check if necessary + public void Update(string id, ElectricityProduction dataIn) + { + _electricityProductionData.ReplaceOne(data => data.Id == id, dataIn); + } + + // Check if necessary + public void Remove(ElectricityProduction dataIn) + { + _electricityProductionData.DeleteOne(data => data.Id == dataIn.Id); + } + + // Check if necessary + public void Remove(string id) + { + _electricityProductionData.DeleteOne(data => data.Id == id); + } + + // Check if necessary + public void RemoveByDeviceId(string userId, string id) + { + _electricityProductionData.DeleteOne(data => data.UserId == userId && data.DeviceId == id); + } + + // Check if necessary + public void RemoveByDeviceIdBeforeDate(string userId, DateTime dateTime) + { + _electricityProductionData.DeleteOne(data => data.UserId == userId && data.Timestamp < dateTime); + } + } +} diff --git a/MyCore/Services/IoTDeviceService.cs b/MyCore/Services/Devices/IoThomas/IoTDeviceService.cs similarity index 100% rename from MyCore/Services/IoTDeviceService.cs rename to MyCore/Services/Devices/IoThomas/IoTDeviceService.cs diff --git a/MyCore/Services/OddService.cs b/MyCore/Services/Devices/IoThomas/OddService.cs similarity index 100% rename from MyCore/Services/OddService.cs rename to MyCore/Services/Devices/IoThomas/OddService.cs diff --git a/MyCore/Services/MQTTService.cs b/MyCore/Services/Devices/MQTTService.cs similarity index 100% rename from MyCore/Services/MQTTService.cs rename to MyCore/Services/Devices/MQTTService.cs diff --git a/MyCore/Services/MerossService.cs b/MyCore/Services/Devices/MerossService.cs similarity index 100% rename from MyCore/Services/MerossService.cs rename to MyCore/Services/Devices/MerossService.cs diff --git a/MyCore/Services/Devices/ScreenDeviceService.cs b/MyCore/Services/Devices/ScreenDeviceService.cs new file mode 100644 index 0000000..ae9d9be --- /dev/null +++ b/MyCore/Services/Devices/ScreenDeviceService.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using MyCore.Models; +using Microsoft.Extensions.Configuration; +using MongoDB.Driver; + +namespace MyCore.Services +{ + public class ScreenDeviceService + { + private readonly IMongoCollection _screenDevices; + + public ScreenDeviceService(IConfiguration config) + { + var client = new MongoClient(config.GetConnectionString("MyCoreDb")); + var database = client.GetDatabase("MyCoreDb"); + _screenDevices = database.GetCollection("ScreenDevices"); + } + + public List GetAll() + { + return _screenDevices.Find(m => true).ToList(); + } + + public ScreenDevice GetInfo(string id) + { + return _screenDevices.Find(m => m.Id == id).FirstOrDefault(); + } + + public ScreenDevice Create(ScreenDevice device) + { + _screenDevices.InsertOne(device); + return device; + } + + public void Update(string id, ScreenDevice screenDeviceIn) + { + _screenDevices.ReplaceOne(screenDevice => screenDevice.Id == id, screenDeviceIn); + } + + public void Remove(ScreenDevice screenDeviceIn) + { + _screenDevices.DeleteOne(screenDevice => screenDevice.Id == screenDeviceIn.Id); + } + + public void Remove(string id) + { + _screenDevices.DeleteOne(screenDevice => screenDevice.Id == id); + } + } +} diff --git a/MyCore/Services/YeelightService.cs b/MyCore/Services/Devices/YeelightService.cs similarity index 100% rename from MyCore/Services/YeelightService.cs rename to MyCore/Services/Devices/YeelightService.cs diff --git a/MyCore/Services/MyControlPanel/AutomationService.cs b/MyCore/Services/MyControlPanel/AutomationService.cs new file mode 100644 index 0000000..af951bf --- /dev/null +++ b/MyCore/Services/MyControlPanel/AutomationService.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using MyCore.Models; +using Microsoft.Extensions.Configuration; +using MongoDB.Driver; +using MyCore.Models.MyControlPanel; + +namespace MyCore.Services.MyControlPanel +{ + public class AutomationService + { + private readonly IMongoCollection _Automations; + + public AutomationService(IConfiguration config) + { + var client = new MongoClient(config.GetConnectionString("MyCoreDb")); + var database = client.GetDatabase("MyCoreDb"); + _Automations = database.GetCollection("Automations"); + } + public List GetAutomations() + { + return _Automations.Find(d => true).ToList(); + } + + public Automation GetAutomationById(string id) + { + return _Automations.Find(a => a.Id == id).FirstOrDefault(); + } + + public Automation CreateAutomation(Automation automation) + { + _Automations.InsertOne(automation); + return automation; + } + + public Automation Update(string id, Automation automationIn) + { + _Automations.ReplaceOne(automation => automation.Id == id, automationIn); + return automationIn; + } + + public void Remove(string id) + { + _Automations.DeleteOne(automation => automation.Id == id); + } + } +} diff --git a/MyCore/Services/MyControlPanel/DeviceService.cs b/MyCore/Services/MyControlPanel/DeviceService.cs new file mode 100644 index 0000000..78ec6ba --- /dev/null +++ b/MyCore/Services/MyControlPanel/DeviceService.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using MyCore.Models; +using Microsoft.Extensions.Configuration; +using MongoDB.Driver; +using MyCore.Models.MyControlPanel; + +namespace MyCore.Services.MyControlPanel +{ + public class DeviceService + { + private readonly IMongoCollection _Devices; + + public DeviceService(IConfiguration config) + { + var client = new MongoClient(config.GetConnectionString("MyCoreDb")); + var database = client.GetDatabase("MyCoreDb"); + _Devices = database.GetCollection("Devices"); + } + public List GetDevices() + { + return _Devices.Find(d => true).ToList(); + } + + public Device GetDeviceById(string id) + { + return _Devices.Find(d => d.Id == id).FirstOrDefault(); + } + + public Device CreateDevice(Device device) + { + _Devices.InsertOne(device); + return device; + } + + public Device Update(string id, Device deviceIn) + { + _Devices.ReplaceOne(device => device.Id == id, deviceIn); + return deviceIn; + } + + public void Remove(string id) + { + _Devices.DeleteOne(device => device.Id == id); + } + } +} diff --git a/MyCore/Services/MyControlPanel/GroupService.cs b/MyCore/Services/MyControlPanel/GroupService.cs new file mode 100644 index 0000000..8b02194 --- /dev/null +++ b/MyCore/Services/MyControlPanel/GroupService.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using MyCore.Models; +using Microsoft.Extensions.Configuration; +using MongoDB.Driver; +using MyCore.Models.MyControlPanel; + +namespace MyCore.Services.MyControlPanel +{ + public class GroupService + { + private readonly IMongoCollection _Groups; + + public GroupService(IConfiguration config) + { + var client = new MongoClient(config.GetConnectionString("MyCoreDb")); + var database = client.GetDatabase("MyCoreDb"); + _Groups = database.GetCollection("Groups"); + } + public List GetGroups() + { + return _Groups.Find(d => true).ToList(); + } + + public Group GetGroupById(string id) + { + return _Groups.Find(g => g.Id == id).FirstOrDefault(); + } + + public Group CreateGroup(Group group) + { + _Groups.InsertOne(group); + return group; + } + + public Group Update(string id, Group groupIn) + { + _Groups.ReplaceOne(group => group.Id == id, groupIn); + return groupIn; + } + + public void Remove(string id) + { + _Groups.DeleteOne(group => group.Id == id); + } + } +} diff --git a/MyCore/Services/MyControlPanel/LocationService.cs b/MyCore/Services/MyControlPanel/LocationService.cs new file mode 100644 index 0000000..fc6a81c --- /dev/null +++ b/MyCore/Services/MyControlPanel/LocationService.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace MyCore.Services.MyControlPanel +{ + public class LocationService + { + } +} diff --git a/MyCore/Services/MyControlPanel/ProviderService.cs b/MyCore/Services/MyControlPanel/ProviderService.cs new file mode 100644 index 0000000..e3df096 --- /dev/null +++ b/MyCore/Services/MyControlPanel/ProviderService.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using MyCore.Models; +using Microsoft.Extensions.Configuration; +using MongoDB.Driver; +using MyCore.Models.MyControlPanel; +namespace MyCore.Services.MyControlPanel +{ + public class ProviderService + { + private readonly IMongoCollection _Providers; + + public ProviderService(IConfiguration config) + { + var client = new MongoClient(config.GetConnectionString("MyCoreDb")); + var database = client.GetDatabase("MyCoreDb"); + _Providers = database.GetCollection("Providers"); + } + public List GetProviders() + { + return _Providers.Find(p => true).ToList(); + } + + public Provider GetProviderById(string id) + { + return _Providers.Find(p => p.Id == id).FirstOrDefault(); + } + + public Provider CreateProvider(Provider provider) + { + _Providers.InsertOne(provider); + return provider; + } + + public Provider Update(string id, Provider providerIn) + { + _Providers.ReplaceOne(provider => provider.Id == id, providerIn); + return providerIn; + } + + public void Remove(string id) + { + _Providers.DeleteOne(provider => provider.Id == id); + } + } +} diff --git a/MyCore/Services/TokenService.cs b/MyCore/Services/MyControlPanel/TokenService.cs similarity index 100% rename from MyCore/Services/TokenService.cs rename to MyCore/Services/MyControlPanel/TokenService.cs diff --git a/MyCore/Services/UserService.cs b/MyCore/Services/MyControlPanel/UserService.cs similarity index 100% rename from MyCore/Services/UserService.cs rename to MyCore/Services/MyControlPanel/UserService.cs diff --git a/swagger.json b/swagger.json index 2ad1456..f75c73e 100644 --- a/swagger.json +++ b/swagger.json @@ -1 +1 @@ -{"swagger":"2.0","info":{"version":"v1","title":"MyCoreApi"},"paths":{"/azure":{"post":{"tags":["Azure"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/AzureADAuthModel"}}],"responses":{"200":{"description":"Success"}}}},"/api/books":{"get":{"tags":["Books"],"operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/Book"}}}}},"post":{"tags":["Books"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"book","in":"body","required":false,"schema":{"$ref":"#/definitions/Book"}}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/Book"}}}}},"/api/books/{id}":{"get":{"tags":["Books"],"operationId":"GetBook","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"id","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/Book"}}}},"put":{"tags":["Books"],"operationId":"Update","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"string"},{"name":"bookIn","in":"body","required":false,"schema":{"$ref":"#/definitions/Book"}}],"responses":{"200":{"description":"Success"}}},"delete":{"tags":["Books"],"operationId":"Delete","consumes":[],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"Success"}}}},"/api/device":{"get":{"tags":["Device"],"summary":"","operationId":"GetAllDevices","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/Device"}}}}},"post":{"tags":["Device"],"summary":"","operationId":"CreateDevice","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"idDevice","in":"query","required":false,"type":"integer","format":"int32"},{"name":"device","in":"body","required":false,"schema":{"$ref":"#/definitions/Device"}}],"responses":{"200":{"description":"Success"}}}},"/api/device/{idDevice}":{"get":{"tags":["Device"],"summary":"","operationId":"GetDeviceInfo","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"idDevice","in":"path","description":"Id of the device you want to get information","required":true,"type":"string"}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/Device"}}}},"put":{"tags":["Device"],"summary":"","operationId":"UpdateDevice","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"idDevice","in":"path","required":true,"type":"integer","format":"int32"},{"name":"device","in":"body","required":false,"schema":{"$ref":"#/definitions/Device"}}],"responses":{"200":{"description":"Success"}}},"delete":{"tags":["Device"],"summary":"","operationId":"DeleteDevice","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"idDevice","in":"path","required":true,"type":"integer","format":"int32"},{"name":"deviceId","in":"body","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Success"}}}},"/facebook":{"post":{"tags":["Facebook"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/FacebookAuthModel"}}],"responses":{"200":{"description":"Success"}}}},"/google":{"post":{"tags":["Google"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/GoogleAuthModel"}}],"responses":{"200":{"description":"Success"}}}},"/api/iot/smartprinter/{idDevice}":{"get":{"tags":["IOT"],"summary":"Retrieve all SmartPrinterMessage","operationId":"GetSmartPrinterMessages","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"id","in":"query","description":"Id of the smart printer message","required":false,"type":"integer","format":"int32"},{"name":"idDevice","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/SmartPrinterMessage"}}}}},"post":{"tags":["IOT"],"summary":"It's the method to post data from mqtt broker to Database (Thanks Rpi!)","operationId":"PostToDBPrinter","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"idDevice","in":"path","description":"Id of the device to upload to DB","required":true,"type":"integer","format":"int32"},{"name":"content","in":"body","description":"Content that will be uploaded","required":false,"schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/SmartPrinterMessage"}}}],"responses":{"200":{"description":"Success"},"201":{"description":"Content successfully posted to DB"},"500":{"description":"Unexpected error"}}}},"/api/iot/smartgarden/{idDevice}":{"post":{"tags":["IOT"],"summary":"It's the method to post data from mqtt broker to Database (Thanks Rpi!)","operationId":"PostToDBSmartGarden","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"idDevice","in":"path","required":true,"type":"integer","format":"int32"},{"name":"content","in":"body","required":false,"schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/SmartGardenMessage"}}}],"responses":{"200":{"description":"Success"}}}},"/api/mqtt":{"get":{"tags":["MQTT"],"summary":"It's a mqtt publish test ! :)","operationId":"GetToPublishMqtt","consumes":[],"produces":[],"parameters":[],"responses":{"200":{"description":"Success"}}}},"/api/token":{"post":{"tags":["Token"],"operationId":"ConnectUser","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"tokenDTO","in":"body","required":false,"schema":{"$ref":"#/definitions/TokenDTO"}}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/UserInfo"}}}}},"/token":{"post":{"tags":["Token"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/User"}}],"responses":{"200":{"description":"Success"}}}},"/twitter":{"post":{"tags":["Twitter"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/TwitterAuthModel"}}],"responses":{"200":{"description":"Success"}}}},"/api/user":{"get":{"tags":["User"],"summary":"Get a list of user","operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/UserInfo"}}}}},"put":{"tags":["User"],"summary":"","operationId":"UpdateUser","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"updatedUser","in":"body","required":false,"schema":{"$ref":"#/definitions/UserInfo"}}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/UserInfo"}}}},"post":{"tags":["User"],"summary":"","operationId":"CreateUser","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"newUser","in":"body","required":false,"schema":{"$ref":"#/definitions/UserInfo"}}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/UserInfo"}}}}},"/api/user/{id}":{"get":{"tags":["User"],"summary":"Get a specific user","operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"id","in":"path","description":"id user","required":true,"type":"string"}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/UserInfo"}}}},"delete":{"tags":["User"],"operationId":"DeleteUser","consumes":[],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"Success"}}}},"/api/test":{"get":{"tags":["Values"],"summary":"It's a test ! :)","operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"type":"string"}}}}},"post":{"tags":["Values"],"operationId":"Post","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"value","in":"body","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Success"}}}},"/api/test/{id}":{"get":{"tags":["Values"],"operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"}],"responses":{"200":{"description":"Success","schema":{"type":"string"}}}},"put":{"tags":["Values"],"operationId":"Put","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"},{"name":"value","in":"body","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Success"}}},"delete":{"tags":["Values"],"operationId":"Delete","consumes":[],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"}],"responses":{"200":{"description":"Success"}}}}},"definitions":{"AzureADAuthModel":{"type":"object","properties":{"apiKey":{"type":"string"}}},"Book":{"type":"object","properties":{"id":{"type":"string"},"bookName":{"type":"string"},"price":{"format":"double","type":"number"},"category":{"type":"string"},"author":{"type":"string"}}},"Device":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"type":{"type":"string"},"location":{"type":"string"},"locationExplanation":{"type":"string"},"height":{"format":"int32","type":"integer"},"width":{"format":"int32","type":"integer"}}},"FacebookAuthModel":{"type":"object","properties":{"userAccessToken":{"type":"string"}}},"GoogleAuthModel":{"type":"object","properties":{"authorizationCode":{"type":"string"},"apiKey":{"type":"string"}}},"SmartPrinterMessage":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"time":{"type":"string"},"temperature":{"format":"double","type":"number"},"pressure":{"format":"double","type":"number"},"smoke":{"format":"int32","type":"integer"}}},"SmartGardenMessage":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"time":{"type":"string"},"temperature":{"format":"double","type":"number"},"pressure":{"format":"double","type":"number"},"humidity":{"format":"double","type":"number"},"water":{"format":"int32","type":"integer"},"light":{"format":"int32","type":"integer"}}},"TokenDTO":{"type":"object","properties":{"email":{"type":"string"},"password":{"type":"string"}}},"UserInfo":{"type":"object","properties":{"id":{"type":"string"},"role":{"type":"string"},"email":{"type":"string"},"password":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"token":{"type":"string"},"birthday":{"format":"date-time","type":"string"},"dateCreation":{"format":"date-time","type":"string"},"address":{"type":"string"},"city":{"type":"string"},"state":{"type":"string"},"country":{"type":"string"},"language":{"type":"string"},"timeZone":{"type":"string"},"postalCode":{"format":"int32","type":"integer"},"screenConfigurationIds":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/ScreenConfiguration"}},"deviceIds":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/Device"}}}},"ScreenConfiguration":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"type":{"type":"string"},"widgets":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/Widget"}},"height":{"format":"int32","type":"integer"},"width":{"format":"int32","type":"integer"}}},"Widget":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"displayName":{"type":"string"},"type":{"type":"string"},"activated":{"type":"boolean"},"form":{"type":"string"},"font":{"type":"string"},"color":{"type":"string"},"size":{"type":"string"},"width":{"format":"int32","type":"integer"},"height":{"format":"int32","type":"integer"},"positionX":{"format":"int32","type":"integer"},"positionY":{"format":"int32","type":"integer"}}},"User":{"type":"object","properties":{"id":{"type":"string"},"password":{"type":"string"}}},"TwitterAuthModel":{"type":"object","properties":{"apiKey":{"type":"string"}}}},"securityDefinitions":{"Bearer":{"name":"Authorization","in":"header","type":"apiKey","description":"Please enter JWT with Bearer into field"}},"security":[{"Bearer":[]}]} \ No newline at end of file +{"swagger":"2.0","info":{"version":"v1","title":"MyCoreApi"},"paths":{"/azure":{"post":{"tags":["Azure"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/AzureADAuthModel"}}],"responses":{"200":{"description":"Success"}}}},"/api/books":{"get":{"tags":["Books"],"operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/Book"}}}}},"post":{"tags":["Books"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"book","in":"body","required":false,"schema":{"$ref":"#/definitions/Book"}}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/Book"}}}}},"/api/books/{id}":{"get":{"tags":["Books"],"operationId":"GetBook","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"id","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/Book"}}}},"put":{"tags":["Books"],"operationId":"Update","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"string"},{"name":"bookIn","in":"body","required":false,"schema":{"$ref":"#/definitions/Book"}}],"responses":{"200":{"description":"Success"}}},"delete":{"tags":["Books"],"operationId":"Delete","consumes":[],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"Success"}}}},"/api/device":{"get":{"tags":["Device"],"summary":"","operationId":"GetAllDevices","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/Device"}}}}},"post":{"tags":["Device"],"summary":"","operationId":"CreateDevice","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"idDevice","in":"query","required":false,"type":"integer","format":"int32"},{"name":"device","in":"body","required":false,"schema":{"$ref":"#/definitions/Device"}}],"responses":{"200":{"description":"Success"}}}},"/api/device/{idDevice}":{"get":{"tags":["Device"],"summary":"","operationId":"GetDeviceInfo","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"idDevice","in":"path","description":"Id of the device you want to get information","required":true,"type":"string"}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/Device"}}}},"put":{"tags":["Device"],"summary":"","operationId":"UpdateDevice","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"idDevice","in":"path","required":true,"type":"integer","format":"int32"},{"name":"device","in":"body","required":false,"schema":{"$ref":"#/definitions/Device"}}],"responses":{"200":{"description":"Success"}}},"delete":{"tags":["Device"],"summary":"","operationId":"DeleteDevice","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"idDevice","in":"path","required":true,"type":"integer","format":"int32"},{"name":"deviceId","in":"body","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Success"}}}},"/api/energy/electricity":{"get":{"tags":["Energy"],"summary":"Get summary production of Kwh/Year","operationId":"GetElectricityProduction","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"userId","in":"query","required":false,"type":"string"},{"name":"viewBy","in":"query","required":false,"type":"integer","format":"int32","enum":[1,2,3]}],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/ElectricityProduction"}}}}}},"/facebook":{"post":{"tags":["Facebook"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/FacebookAuthModel"}}],"responses":{"200":{"description":"Success"}}}},"/google":{"post":{"tags":["Google"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/GoogleAuthModel"}}],"responses":{"200":{"description":"Success"}}}},"/api/iot/smartprinter/{idDevice}":{"get":{"tags":["IOT"],"summary":"Retrieve all SmartPrinterMessage","operationId":"GetSmartPrinterMessages","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"id","in":"query","description":"Id of the smart printer message","required":false,"type":"integer","format":"int32"},{"name":"idDevice","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/SmartPrinterMessage"}}}}},"post":{"tags":["IOT"],"summary":"It's the method to post data from mqtt broker to Database (Thanks Rpi!)","operationId":"PostToDBPrinter","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"idDevice","in":"path","description":"Id of the device to upload to DB","required":true,"type":"integer","format":"int32"},{"name":"content","in":"body","description":"Content that will be uploaded","required":false,"schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/SmartPrinterMessage"}}}],"responses":{"200":{"description":"Success"},"201":{"description":"Content successfully posted to DB"},"500":{"description":"Unexpected error"}}}},"/api/iot/smartgarden/{idDevice}":{"post":{"tags":["IOT"],"summary":"It's the method to post data from mqtt broker to Database (Thanks Rpi!)","operationId":"PostToDBSmartGarden","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"idDevice","in":"path","required":true,"type":"integer","format":"int32"},{"name":"content","in":"body","required":false,"schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/SmartGardenMessage"}}}],"responses":{"200":{"description":"Success"}}}},"/api/layout/panelSection":{"get":{"tags":["Layout"],"summary":"It's a test ! :)","operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/PanelSection"}}}}}},"/api/mqtt":{"get":{"tags":["MQTT"],"summary":"It's a mqtt publish test ! :)","operationId":"GetToPublishMqtt","consumes":[],"produces":[],"parameters":[],"responses":{"200":{"description":"Success"}}}},"/api/odd/country/{id}/{oddRequest}":{"get":{"tags":["Odd"],"summary":"Get odds for one country and one odd value maximum","operationId":"GetForCountry","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"id","in":"path","description":"id of country, e.g = BE for Belgium","required":true,"type":"string"},{"name":"oddRequest","in":"path","description":"Odd Maximum value","required":true,"type":"number","format":"double"}],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/OddNice"}}},"404":{"description":"Not Found","schema":{"type":"string"}},"500":{"description":"Server Error","schema":{"type":"string"}}}}},"/api/odd/{oddRequest}":{"get":{"tags":["Odd"],"summary":"Get odds for one country and one odd value maximum","operationId":"GetAll","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"oddRequest","in":"path","description":"Odd Maximum value","required":true,"type":"number","format":"double"}],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/OddNice"}}},"404":{"description":"Not Found","schema":{"type":"string"}},"500":{"description":"Server Error","schema":{"type":"string"}}}}},"/api/token":{"post":{"tags":["Token"],"operationId":"ConnectUser","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"tokenDTO","in":"body","required":false,"schema":{"$ref":"#/definitions/TokenDTO"}}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/UserInfo"}}}}},"/token":{"post":{"tags":["Token"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/User"}}],"responses":{"200":{"description":"Success"}}}},"/twitter":{"post":{"tags":["Twitter"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/TwitterAuthModel"}}],"responses":{"200":{"description":"Success"}}}},"/api/user":{"get":{"tags":["User"],"summary":"Get a list of user","operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/UserInfo"}}}}},"put":{"tags":["User"],"summary":"","operationId":"UpdateUser","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"updatedUser","in":"body","required":false,"schema":{"$ref":"#/definitions/UserInfo"}}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/UserInfo"}}}},"post":{"tags":["User"],"summary":"","operationId":"CreateUser","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"newUser","in":"body","required":false,"schema":{"$ref":"#/definitions/UserInfo"}}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/UserInfo"}}}}},"/api/user/{id}":{"get":{"tags":["User"],"summary":"Get a specific user","operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"id","in":"path","description":"id user","required":true,"type":"string"}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/UserInfo"}}}},"delete":{"tags":["User"],"operationId":"DeleteUser","consumes":[],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"Success"}}}},"/api/test":{"get":{"tags":["Values"],"summary":"It's a test ! :)","operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"type":"string"}}}}},"post":{"tags":["Values"],"operationId":"Post","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"value","in":"body","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Success"}}}},"/api/test/{id}":{"get":{"tags":["Values"],"operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"}],"responses":{"200":{"description":"Success","schema":{"type":"string"}}}},"put":{"tags":["Values"],"operationId":"Put","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"},{"name":"value","in":"body","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Success"}}},"delete":{"tags":["Values"],"operationId":"Delete","consumes":[],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"}],"responses":{"200":{"description":"Success"}}}}},"definitions":{"AzureADAuthModel":{"type":"object","properties":{"apiKey":{"type":"string"}}},"Book":{"type":"object","properties":{"id":{"type":"string"},"bookName":{"type":"string"},"price":{"format":"double","type":"number"},"category":{"type":"string"},"author":{"type":"string"}}},"Device":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"type":{"type":"string"},"location":{"type":"string"},"locationExplanation":{"type":"string"},"height":{"format":"int32","type":"integer"},"width":{"format":"int32","type":"integer"}}},"ElectricityProduction":{"type":"object","properties":{"id":{"type":"string"},"deviceId":{"type":"string"},"userId":{"type":"string"},"watt":{"format":"double","type":"number"},"ampere":{"format":"double","type":"number"},"timestamp":{"format":"date-time","type":"string"}}},"FacebookAuthModel":{"type":"object","properties":{"userAccessToken":{"type":"string"}}},"GoogleAuthModel":{"type":"object","properties":{"authorizationCode":{"type":"string"},"apiKey":{"type":"string"}}},"SmartPrinterMessage":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"time":{"type":"string"},"temperature":{"format":"double","type":"number"},"pressure":{"format":"double","type":"number"},"smoke":{"format":"int32","type":"integer"}}},"SmartGardenMessage":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"time":{"type":"string"},"temperature":{"format":"double","type":"number"},"pressure":{"format":"double","type":"number"},"humidity":{"format":"double","type":"number"},"water":{"format":"int32","type":"integer"},"light":{"format":"int32","type":"integer"}}},"PanelSection":{"type":"object","properties":{"label":{"type":"string"},"icon":{"type":"string"},"color":{"type":"string"},"defaultRoute":{"type":"string"},"children":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/PanelMenuItem"}}}},"PanelMenuItem":{"type":"object","properties":{"label":{"type":"string"},"route":{"type":"string"},"icon":{"type":"string"},"color":{"type":"string"},"badgeValue":{"format":"int32","type":"integer"},"badgeType":{"type":"string"},"children":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/PanelMenuItem"}}}},"OddNice":{"type":"object","properties":{"teams":{"uniqueItems":false,"type":"array","items":{"type":"string"}},"commence_time":{"format":"int32","type":"integer"},"home_team":{"type":"string"},"odds":{"$ref":"#/definitions/OddH2H"}}},"OddH2H":{"type":"object","properties":{"homeOdd":{"format":"double","type":"number"},"drawOdd":{"format":"double","type":"number"},"visitOdd":{"format":"double","type":"number"}}},"TokenDTO":{"type":"object","properties":{"email":{"type":"string"},"password":{"type":"string"}}},"UserInfo":{"type":"object","properties":{"id":{"type":"string"},"role":{"type":"string"},"email":{"type":"string"},"password":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"token":{"type":"string"},"birthday":{"format":"date-time","type":"string"},"dateCreation":{"format":"date-time","type":"string"},"address":{"type":"string"},"city":{"type":"string"},"state":{"type":"string"},"country":{"type":"string"},"language":{"type":"string"},"timeZone":{"type":"string"},"postalCode":{"format":"int32","type":"integer"},"screenConfigurationIds":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/ScreenConfiguration"}},"deviceIds":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/Device"}}}},"ScreenConfiguration":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"type":{"type":"string"},"widgets":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/Widget"}},"height":{"format":"int32","type":"integer"},"width":{"format":"int32","type":"integer"}}},"Widget":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"displayName":{"type":"string"},"type":{"type":"string"},"activated":{"type":"boolean"},"form":{"type":"string"},"font":{"type":"string"},"color":{"type":"string"},"size":{"type":"string"},"width":{"format":"int32","type":"integer"},"height":{"format":"int32","type":"integer"},"positionX":{"format":"int32","type":"integer"},"positionY":{"format":"int32","type":"integer"}}},"User":{"type":"object","properties":{"id":{"type":"string"},"password":{"type":"string"}}},"TwitterAuthModel":{"type":"object","properties":{"apiKey":{"type":"string"}}}},"securityDefinitions":{"Bearer":{"name":"Authorization","in":"header","type":"apiKey","description":"Please enter JWT with Bearer into field"}},"security":[{"Bearer":[]}]} \ No newline at end of file