diff --git a/MyCore/Controllers/Devices/DeviceController.cs b/MyCore/Controllers/Devices/DeviceController.cs
index 5b3db81..5c86518 100644
--- a/MyCore/Controllers/Devices/DeviceController.cs
+++ b/MyCore/Controllers/Devices/DeviceController.cs
@@ -10,6 +10,7 @@ using MyCore.DTO.Common;
using MyCore.DTO.MyControlPanel;
using MyCore.Models;
using MyCore.Models.MyControlPanel;
+using MyCore.Models.MyControlPanel.Database;
using MyCore.Services;
using MyCore.Services.Devices;
using MyCore.Services.MyControlPanel;
@@ -95,6 +96,10 @@ namespace MyCore.Controllers.Devices
return new OkObjectResult(deviceCreated);
}
+ catch (DuplicateWaitObjectException ex)
+ {
+ return new BadRequestObjectResult(ex.Message) { StatusCode = 400 };
+ }
catch (KeyNotFoundException ex)
{
return new BadRequestObjectResult(ex.Message) { StatusCode = 404 };
@@ -112,7 +117,7 @@ namespace MyCore.Controllers.Devices
/// Id of Provider
[ProducesResponseType(typeof(List), 200)]
[HttpPost("fromProvider/{userId}")]
- public ObjectResult CreateDevicesFromProvider(string userId, [FromBody] string providerId)
+ public async Task CreateDevicesFromProvider(string userId, string providerId)
{
try
{
@@ -123,13 +128,12 @@ namespace MyCore.Controllers.Devices
throw new KeyNotFoundException("User not found");
Provider provider = ProviderService.GetProviderById(this._ProviderDatabaseService, userId, providerId);
- if (provider != null)
+ if (provider == null)
throw new KeyNotFoundException("Provider id is null");
- List devicesCreated = DeviceService.CreateFromProvider(provider);
+ List devicesCreated = await DeviceService.CreateFromProvider(this._DeviceDatabaseService, this._ProviderDatabaseService, this._LocationDatabaseService, provider);
return new OkObjectResult(devicesCreated);
-
}
catch (InvalidOperationException ex)
{
diff --git a/MyCore/Controllers/Devices/ProviderController.cs b/MyCore/Controllers/Devices/ProviderController.cs
index 2a5d5ac..240d927 100644
--- a/MyCore/Controllers/Devices/ProviderController.cs
+++ b/MyCore/Controllers/Devices/ProviderController.cs
@@ -10,6 +10,7 @@ using MyCore.DTO.Common;
using MyCore.DTO.MyControlPanel;
using MyCore.Models;
using MyCore.Models.MyControlPanel;
+using MyCore.Models.MyControlPanel.Database;
using MyCore.Services;
using MyCore.Services.Devices;
using MyCore.Services.MyControlPanel;
diff --git a/MyCore/Controllers/MyControlPanel/TokenController.cs b/MyCore/Controllers/MyControlPanel/TokenController.cs
index 3e93f80..ed1f059 100644
--- a/MyCore/Controllers/MyControlPanel/TokenController.cs
+++ b/MyCore/Controllers/MyControlPanel/TokenController.cs
@@ -12,6 +12,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Tokens;
using MyCore.DTO;
using MyCore.Models;
+using MyCore.Models.MyControlPanel.Database;
using MyCore.Services;
namespace MyCore.Controllers
diff --git a/MyCore/Controllers/MyControlPanel/UserController.cs b/MyCore/Controllers/MyControlPanel/UserController.cs
index 641d986..d513300 100644
--- a/MyCore/Controllers/MyControlPanel/UserController.cs
+++ b/MyCore/Controllers/MyControlPanel/UserController.cs
@@ -8,6 +8,7 @@ using MQTTnet;
using MQTTnet.Client;
using MQTTnet.Server;
using MyCore.Models;
+using MyCore.Models.MyControlPanel.Database;
using MyCore.Services;
namespace MyCore.Controllers
diff --git a/MyCore/DTO/MyControlPanel/DeviceDTO.cs b/MyCore/DTO/MyControlPanel/DeviceDTO.cs
index 1009395..146cec4 100644
--- a/MyCore/DTO/MyControlPanel/DeviceDTO.cs
+++ b/MyCore/DTO/MyControlPanel/DeviceDTO.cs
@@ -13,8 +13,14 @@ namespace MyCore.DTO.MyControlPanel
public string Name { get; set; }
+ public string Model { get; set; }
+
+ public bool Status { get; set; }
+
public ConnectionStatus ConnectionStatus { get; set; }
+ public string LocationId { get; set; }
+
public LocationDTO Location { get; set; }
public bool Battery { get; set; }
@@ -28,8 +34,16 @@ namespace MyCore.DTO.MyControlPanel
public string Name { get; set; }
+ public string Model { get; set; }
+
+ public string FirmwareVersion { get; set; }
+
+ public int Port { get; set; }
+
public ConnectionStatus ConnectionStatus { get; set; }
+ public bool Status { get; set; }
+
public string LocationId { get; set; }
public LocationDTO Location { get; set; }
@@ -54,6 +68,8 @@ namespace MyCore.DTO.MyControlPanel
public List Groups { get; set; }
- public List Informations { get; set; }
+ public Dictionary Properties { get; set; }
+
+ public List SupportedOperations { get; set; }
}
}
diff --git a/MyCore/DTO/MyControlPanel/InformationDTO.cs b/MyCore/DTO/MyControlPanel/InformationDTO.cs
deleted file mode 100644
index 6b87914..0000000
--- a/MyCore/DTO/MyControlPanel/InformationDTO.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace MyCore.DTO.MyControlPanel
-{
- public class InformationDTO
- {
- public string Id { get; set; }
- public string Name { get; set; }
- public object Value { get; set; }
- }
-}
diff --git a/MyCore/DTO/MyControlPanel/ProviderDTO.cs b/MyCore/DTO/MyControlPanel/ProviderDTO.cs
index 522ef4e..a3d917c 100644
--- a/MyCore/DTO/MyControlPanel/ProviderDTO.cs
+++ b/MyCore/DTO/MyControlPanel/ProviderDTO.cs
@@ -13,5 +13,6 @@ namespace MyCore.DTO.MyControlPanel
public string Username { get; set; }
public string Password { get; set; } // TODO ENCRYPTED
public string ApiKey { get; set; } // TODO ENCRYPTED
+ public bool Active { get; set; }
}
}
diff --git a/MyCore/Models/MyControlPanel/Database/Automation.cs b/MyCore/Models/MyControlPanel/Database/Automation.cs
index 1754216..69f2d73 100644
--- a/MyCore/Models/MyControlPanel/Database/Automation.cs
+++ b/MyCore/Models/MyControlPanel/Database/Automation.cs
@@ -5,7 +5,7 @@ using MyCore.DTO.MyControlPanel;
using System;
using System.Collections.Generic;
-namespace MyCore.Models
+namespace MyCore.Models.MyControlPanel.Database
{
///
/// Automation
diff --git a/MyCore/Models/MyControlPanel/Database/Device.cs b/MyCore/Models/MyControlPanel/Database/Device.cs
index ab6438e..bbc38ee 100644
--- a/MyCore/Models/MyControlPanel/Database/Device.cs
+++ b/MyCore/Models/MyControlPanel/Database/Device.cs
@@ -2,12 +2,13 @@
using MongoDB.Bson.Serialization.Attributes;
using MyCore.DTO.Common;
using MyCore.DTO.MyControlPanel;
+using MyCore.Models.MyControlPanel.Database;
using MyCore.Services.MyControlPanel;
using System;
using System.Collections.Generic;
using System.Linq;
-namespace MyCore.Models.MyControlPanel
+namespace MyCore.Models.MyControlPanel.Database
{
///
/// Group of devices
@@ -22,11 +23,25 @@ namespace MyCore.Models.MyControlPanel
[BsonRequired]
public string Name { get; set; }
+ [BsonElement("Model")]
+ [BsonRequired]
+ public string Model { get; set; }
+
+ [BsonElement("Port")]
+ [BsonRequired]
+ public int Port { get; set; }
+
+ [BsonElement("FirmwareVersion")]
+ [BsonRequired]
+ public string FirmwareVersion { get; set; }
+
+ [BsonElement("Status")]
+ public bool Status { get; set; }
+
[BsonElement("ConnectionStatus")]
public ConnectionStatus ConnectionStatus { get; set; }
[BsonElement("LocationId")]
- [BsonRequired]
public string LocationId { get; set; }
[BsonElement("MeansOfCommunications")]
@@ -60,8 +75,11 @@ namespace MyCore.Models.MyControlPanel
[BsonElement("GroupIds")]
public List GroupIds { get; set; }
- [BsonElement("Informations")]
- public List Information { get; set; }
+ [BsonElement("Properties")]
+ public Dictionary Properties { get; set; }
+
+ [BsonElement("SupportedOperations")]
+ public List SupportedOperations { get; set; }
public DeviceSummaryDTO ToSummaryDTO()
{
@@ -69,8 +87,11 @@ namespace MyCore.Models.MyControlPanel
{
Id = Id,
Name = Name,
+ Model = Model,
+ Status = Status,
ConnectionStatus = ConnectionStatus,
- //Location = _LocationDatabaseService.GetById(LocationId).ToDTO(), // Check if correct way
+ LocationId = LocationId, // Check if correct way
+ // Location =
Battery = Battery,
BatteryStatus = BatteryStatus
};
@@ -82,17 +103,23 @@ namespace MyCore.Models.MyControlPanel
{
Id = Id,
Name = Name,
+ Model = Model,
+ Status = Status,
+ Port = Port,
+ FirmwareVersion = FirmwareVersion,
ConnectionStatus = ConnectionStatus,
- //Location = _LocationDatabaseService.GetById(LocationId).ToDTO(), // Check if correct way
+ LocationId = LocationId, // Check if correct way
+ // Location =
MeansOfCommunications = MeansOfCommunications,
CreatedDate = CreatedDate,
UpdatedDate = UpdatedDate,
LastMessage = LastMessage,
LastMessageDate = LastMessageDate,
IpAddress = IpAddress,
- //Provider = Provider.ToDTO(device.Provider),
- //Groups = device.Groups.Select(i => i.ToDTO(i)).ToList(),
- //Informations = device.Informations.Select(i => i.ToDTO(i)).ToList(),
+ ProviderId = ProviderId,
+ Groups = GroupIds,
+ Properties = Properties,
+ SupportedOperations = SupportedOperations,
Battery = Battery,
BatteryStatus = BatteryStatus
};
diff --git a/MyCore/Models/MyControlPanel/Database/Group.cs b/MyCore/Models/MyControlPanel/Database/Group.cs
index fab9285..6b04f14 100644
--- a/MyCore/Models/MyControlPanel/Database/Group.cs
+++ b/MyCore/Models/MyControlPanel/Database/Group.cs
@@ -4,7 +4,7 @@ using MyCore.DTO.Common;
using MyCore.DTO.MyControlPanel;
using System;
using System.Collections.Generic;
-namespace MyCore.Models.MyControlPanel
+namespace MyCore.Models.MyControlPanel.Database
{
///
/// Group of devices
diff --git a/MyCore/Models/MyControlPanel/Database/Information.cs b/MyCore/Models/MyControlPanel/Database/Information.cs
deleted file mode 100644
index 5b73d58..0000000
--- a/MyCore/Models/MyControlPanel/Database/Information.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using MongoDB.Bson;
-using MongoDB.Bson.Serialization.Attributes;
-using MyCore.DTO.Common;
-using MyCore.DTO.MyControlPanel;
-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")]
- [BsonRequired]
- public string Name { get; set; }
-
- [BsonElement("Value")]
- [BsonRequired]
- public object Value { get; set; }
-
- public InformationDTO ToDTO()
- {
- return new InformationDTO()
- {
- Id = Id,
- Name = Name,
- Value = Value
- };
- }
- }
-}
diff --git a/MyCore/Models/MyControlPanel/Database/Location.cs b/MyCore/Models/MyControlPanel/Database/Location.cs
index 0069ec9..f50cdd2 100644
--- a/MyCore/Models/MyControlPanel/Database/Location.cs
+++ b/MyCore/Models/MyControlPanel/Database/Location.cs
@@ -2,7 +2,7 @@
using MongoDB.Bson.Serialization.Attributes;
using MyCore.DTO.MyControlPanel;
-namespace MyCore.Models.MyControlPanel
+namespace MyCore.Models.MyControlPanel.Database
{
///
/// Location of a device (Room name, garden, ..)
diff --git a/MyCore/Models/MyControlPanel/Database/Provider.cs b/MyCore/Models/MyControlPanel/Database/Provider.cs
index 0aa7482..67f9fc6 100644
--- a/MyCore/Models/MyControlPanel/Database/Provider.cs
+++ b/MyCore/Models/MyControlPanel/Database/Provider.cs
@@ -5,7 +5,7 @@ using MyCore.DTO.MyControlPanel;
using System;
using System.Collections.Generic;
-namespace MyCore.Models.MyControlPanel
+namespace MyCore.Models.MyControlPanel.Database
{
///
/// Provider of a device (provider of informations) - e.g. : Meross, Arlo, IoThomas, ...
@@ -35,12 +35,17 @@ namespace MyCore.Models.MyControlPanel
[BsonElement("ApiKey")]
public string ApiKey { get; set; } // TODO ENCRYPTED
+ [BsonElement("Active")]
+ [BsonRequired]
+ public bool Active { get; set; }
+
public ProviderDTO ToDTO()
{
return new ProviderDTO()
{
Id = Id,
- Name = Name
+ Name = Name,
+ Active = Active
};
}
}
diff --git a/MyCore/Models/MyControlPanel/Database/UserInfo.cs b/MyCore/Models/MyControlPanel/Database/UserInfo.cs
index 12374ba..4293bd7 100644
--- a/MyCore/Models/MyControlPanel/Database/UserInfo.cs
+++ b/MyCore/Models/MyControlPanel/Database/UserInfo.cs
@@ -7,7 +7,7 @@ using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MyCore.Models.MyControlPanel;
-namespace MyCore.Models
+namespace MyCore.Models.MyControlPanel.Database
{
///
/// User Information
diff --git a/MyCore/Services/Devices/DeviceService.cs b/MyCore/Services/Devices/DeviceService.cs
index c29c6e5..f452ade 100644
--- a/MyCore/Services/Devices/DeviceService.cs
+++ b/MyCore/Services/Devices/DeviceService.cs
@@ -2,6 +2,7 @@
using MyCore.DTO.Common;
using MyCore.DTO.MyControlPanel;
using MyCore.Models.MyControlPanel;
+using MyCore.Models.MyControlPanel.Database;
using MyCore.Services.MyControlPanel;
using System;
using System.Collections.Generic;
@@ -22,19 +23,33 @@ namespace MyCore.Services.Devices
{
device = _DeviceDatabaseService.GetById(deviceDetailDTO.Id);
}
-
- device.Name = deviceDetailDTO.Name;
+
+ if (_DeviceDatabaseService.IsAlreadyHere(deviceDetailDTO.IpAddress, deviceDetailDTO.Port) && create)
+ {
+ return null;
+ }
+
+ device.Name = deviceDetailDTO.Name;
if (_ProviderDatabaseService.IsExist(deviceDetailDTO.ProviderId))
device.ProviderId = deviceDetailDTO.ProviderId;
else
throw new KeyNotFoundException("Provider does not exist");
- if (_LocationDatabaseService.IsExist(deviceDetailDTO.LocationId))
+ if (device.LocationId == null || _LocationDatabaseService.IsExist(deviceDetailDTO.LocationId))
device.LocationId = deviceDetailDTO.LocationId;
else
throw new KeyNotFoundException("Location does not exist");
- device.ConnectionStatus = ConnectionStatus.Unknown;
+ device.Port = deviceDetailDTO.Port;
+ device.Model = deviceDetailDTO.Model;
+ device.FirmwareVersion = deviceDetailDTO.FirmwareVersion;
+ device.Status = deviceDetailDTO.Status;
+ if (create)
+ device.ConnectionStatus = ConnectionStatus.Unknown;
+ else
+ device.ConnectionStatus = deviceDetailDTO.ConnectionStatus;
+ device.Status = device.Status;
+ device.LocationId = device.LocationId;
device.CreatedDate = DateTime.Now;
device.UpdatedDate = DateTime.Now;
@@ -43,8 +58,10 @@ namespace MyCore.Services.Devices
device.Battery = deviceDetailDTO.Battery;
device.BatteryStatus = deviceDetailDTO.BatteryStatus;
device.GroupIds = device.GroupIds;
- // Todo structure informations
- device.Information = device.Information;
+ // Todo structure Properties
+ device.Properties = device.Properties;
+ // Todo structure SupportedOperations
+ device.SupportedOperations = device.SupportedOperations;
if (create)
return _DeviceDatabaseService.Create(device).ToDTO();
@@ -52,13 +69,13 @@ namespace MyCore.Services.Devices
return _DeviceDatabaseService.Update(device.Id, device).ToDTO();
}
- public static List CreateFromProvider(Provider provider)
+ public async static Task> CreateFromProvider(DeviceDatabaseService _DeviceDatabaseService, ProviderDatabaseService _ProviderDatabaseService, LocationDatabaseService _LocationDatabaseService, Provider provider)
{
- Device device = new Device();
-
if (!ProviderService.IsProviderSupported(provider.Name))
throw new KeyNotFoundException("Provider is not yet supported");
+ List createdDevice = new List();
+
switch (provider.Name)
{
case "Arlo":
@@ -68,14 +85,50 @@ namespace MyCore.Services.Devices
break;
case "Yeelight":
-
+ List yeelightDevices = await new YeelightService().GetDevices();
+ createdDevice = CreateYeelightDevices(_DeviceDatabaseService, _ProviderDatabaseService, _LocationDatabaseService, yeelightDevices, provider);
break;
}
- List createdDevice = new List();
-
return createdDevice;
}
+
+ public static List CreateYeelightDevices(DeviceDatabaseService _DeviceDatabaseService, ProviderDatabaseService _ProviderDatabaseService, LocationDatabaseService _LocationDatabaseService, List yeelightDevices, Provider provider)
+ {
+ List createdYeelightDevices = new List();
+
+ foreach (var light in yeelightDevices)
+ {
+ DeviceDetailDTO deviceDetailDTO = new DeviceDetailDTO();
+ deviceDetailDTO.Name = light.Name;
+ deviceDetailDTO.IpAddress = light.Hostname;
+ deviceDetailDTO.ProviderId = provider.Id;
+ deviceDetailDTO.ConnectionStatus = ConnectionStatus.Connected;
+ deviceDetailDTO.Status = false;
+ deviceDetailDTO.Model = light.Model.ToString();
+ deviceDetailDTO.Port = light.Port;
+ deviceDetailDTO.FirmwareVersion = light.FirmwareVersion;
+ Dictionary properties = new Dictionary();
+ foreach (var property in light.Properties)
+ {
+ properties.Add(property.Key, property.Value);
+ }
+ deviceDetailDTO.Properties = properties;
+ List supportedOperationsDTO = new List();
+ foreach (var supportedOperation in light.SupportedOperations)
+ {
+ supportedOperationsDTO.Add(supportedOperation.ToString());
+ }
+ deviceDetailDTO.SupportedOperations = supportedOperationsDTO;
+ deviceDetailDTO.MeansOfCommunications = new List();
+ deviceDetailDTO.MeansOfCommunications.Add(MeansOfCommunication.Wifi);
+ deviceDetailDTO.CreatedDate = DateTime.Now;
+ deviceDetailDTO.UpdatedDate = DateTime.Now;
+ createdYeelightDevices.Add(CreateOrUpdate(_DeviceDatabaseService, _ProviderDatabaseService, _LocationDatabaseService, deviceDetailDTO, true));
+ }
+
+ return createdYeelightDevices;
+ }
}
}
diff --git a/MyCore/Services/Devices/MQTTService.cs b/MyCore/Services/Devices/MQTTService.cs
index 573a261..e8a870b 100644
--- a/MyCore/Services/Devices/MQTTService.cs
+++ b/MyCore/Services/Devices/MQTTService.cs
@@ -33,16 +33,6 @@ namespace MyCore.Services
public MQTTService()
{
- try
- {
- yeelightService.GetDevices();
- }
- catch (Exception ex)
- {
-
- }
-
-
try
{
// Create a new MQTT client.
diff --git a/MyCore/Services/Devices/SupportedDevices/YeelightService.cs b/MyCore/Services/Devices/SupportedDevices/YeelightService.cs
index da2743d..ff5b8e9 100644
--- a/MyCore/Services/Devices/SupportedDevices/YeelightService.cs
+++ b/MyCore/Services/Devices/SupportedDevices/YeelightService.cs
@@ -10,7 +10,7 @@ namespace MyCore.Services
{
public List devices = new List();
- public async Task> GetDevices()
+ public async Task> GetDevices()
{
devices = await DeviceLocator.Discover();
diff --git a/MyCore/Services/MyControlPanel/Database/AutomationDatabaseService.cs b/MyCore/Services/MyControlPanel/Database/AutomationDatabaseService.cs
index d3020ee..44ae513 100644
--- a/MyCore/Services/MyControlPanel/Database/AutomationDatabaseService.cs
+++ b/MyCore/Services/MyControlPanel/Database/AutomationDatabaseService.cs
@@ -6,6 +6,7 @@ using MyCore.Models;
using Microsoft.Extensions.Configuration;
using MongoDB.Driver;
using MyCore.Models.MyControlPanel;
+using MyCore.Models.MyControlPanel.Database;
namespace MyCore.Services.MyControlPanel
{
diff --git a/MyCore/Services/MyControlPanel/Database/DeviceDatabaseService.cs b/MyCore/Services/MyControlPanel/Database/DeviceDatabaseService.cs
index 9c585f1..3228184 100644
--- a/MyCore/Services/MyControlPanel/Database/DeviceDatabaseService.cs
+++ b/MyCore/Services/MyControlPanel/Database/DeviceDatabaseService.cs
@@ -6,6 +6,7 @@ using MyCore.Models;
using Microsoft.Extensions.Configuration;
using MongoDB.Driver;
using MyCore.Models.MyControlPanel;
+using MyCore.Models.MyControlPanel.Database;
namespace MyCore.Services.MyControlPanel
{
@@ -34,6 +35,11 @@ namespace MyCore.Services.MyControlPanel
return _Devices.Find(d => d.Id == id).FirstOrDefault() != null ? true : false;
}
+ public bool IsAlreadyHere(string ipAddress, int port)
+ {
+ return _Devices.Find(d => d.IpAddress == ipAddress && d.Port == port).FirstOrDefault() != null ? true : false;
+ }
+
public Device Create(Device device)
{
_Devices.InsertOne(device);
diff --git a/MyCore/Services/MyControlPanel/Database/GroupDatabaseService.cs b/MyCore/Services/MyControlPanel/Database/GroupDatabaseService.cs
index 3f48fbe..06d7c35 100644
--- a/MyCore/Services/MyControlPanel/Database/GroupDatabaseService.cs
+++ b/MyCore/Services/MyControlPanel/Database/GroupDatabaseService.cs
@@ -6,6 +6,7 @@ using MyCore.Models;
using Microsoft.Extensions.Configuration;
using MongoDB.Driver;
using MyCore.Models.MyControlPanel;
+using MyCore.Models.MyControlPanel.Database;
namespace MyCore.Services.MyControlPanel
{
diff --git a/MyCore/Services/MyControlPanel/Database/LocationDatabaseService.cs b/MyCore/Services/MyControlPanel/Database/LocationDatabaseService.cs
index d4be9e3..5ed70f6 100644
--- a/MyCore/Services/MyControlPanel/Database/LocationDatabaseService.cs
+++ b/MyCore/Services/MyControlPanel/Database/LocationDatabaseService.cs
@@ -6,6 +6,7 @@ using MyCore.Models;
using Microsoft.Extensions.Configuration;
using MongoDB.Driver;
using MyCore.Models.MyControlPanel;
+using MyCore.Models.MyControlPanel.Database;
namespace MyCore.Services.MyControlPanel
{
diff --git a/MyCore/Services/MyControlPanel/Database/ProviderDatabaseService.cs b/MyCore/Services/MyControlPanel/Database/ProviderDatabaseService.cs
index 856ce67..4b4a843 100644
--- a/MyCore/Services/MyControlPanel/Database/ProviderDatabaseService.cs
+++ b/MyCore/Services/MyControlPanel/Database/ProviderDatabaseService.cs
@@ -5,7 +5,8 @@ using System.Threading.Tasks;
using MyCore.Models;
using Microsoft.Extensions.Configuration;
using MongoDB.Driver;
-using MyCore.Models.MyControlPanel;
+using MyCore.Models.MyControlPanel.Database;
+
namespace MyCore.Services.MyControlPanel
{
public class ProviderDatabaseService
diff --git a/MyCore/Services/MyControlPanel/Database/UserDatabaseService.cs b/MyCore/Services/MyControlPanel/Database/UserDatabaseService.cs
index 0f7046a..9b7c366 100644
--- a/MyCore/Services/MyControlPanel/Database/UserDatabaseService.cs
+++ b/MyCore/Services/MyControlPanel/Database/UserDatabaseService.cs
@@ -5,6 +5,7 @@ using System.Threading.Tasks;
using MyCore.Models;
using Microsoft.Extensions.Configuration;
using MongoDB.Driver;
+using MyCore.Models.MyControlPanel.Database;
namespace MyCore.Services
{
diff --git a/MyCore/Services/MyControlPanel/ProviderService.cs b/MyCore/Services/MyControlPanel/ProviderService.cs
index a3d79fc..fde7906 100644
--- a/MyCore/Services/MyControlPanel/ProviderService.cs
+++ b/MyCore/Services/MyControlPanel/ProviderService.cs
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Configuration;
using MyCore.DTO.MyControlPanel;
-using MyCore.Models.MyControlPanel;
+using MyCore.Models.MyControlPanel.Database;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -45,6 +45,7 @@ namespace MyCore.Services.MyControlPanel
provider.Username = providerDTO.Username;
provider.Password = providerDTO.Password;
provider.ApiKey = providerDTO.ApiKey;
+ provider.Active = true;
if (create)
return _ProviderDatabaseService.Create(provider).ToDTO();