diff --git a/backend/Api/BusinessLogic/DeviceLogic.cs b/backend/Api/BusinessLogic/DeviceLogic.cs
index ae4be2c..2bbdf32 100644
--- a/backend/Api/BusinessLogic/DeviceLogic.cs
+++ b/backend/Api/BusinessLogic/DeviceLogic.cs
@@ -1,5 +1,6 @@
using Api.DBAccess;
using Api.Models;
+using Api.Models.Devices;
using Microsoft.AspNetCore.Mvc;
namespace Api.BusinessLogic
@@ -41,12 +42,22 @@ namespace Api.BusinessLogic
/// The new device
/// The user that owns the device
/// returns true in a OkObjectResult and if there is some error it returns a ConflictObjectResult and a message that explain the reason
- public async Task AddDevice(Device device, int userId)
+ public async Task AddDevice(string referenceId, int userId)
{
var profile = await _dbAccess.ReadUser(userId);
if (profile == null) { return new ConflictObjectResult(new { message = "Could not find user" }); }
+ Device device = new Device
+ {
+ Name = "Undefined",
+ TempHigh = 0,
+ TempLow = 0,
+ ReferenceId = referenceId,
+ Logs = new List(),
+ };
+
+
return await _dbAccess.CreateDevice(device, userId);
}
diff --git a/backend/Api/BusinessLogic/UserLogic.cs b/backend/Api/BusinessLogic/UserLogic.cs
index cddf2bf..1a005cf 100644
--- a/backend/Api/BusinessLogic/UserLogic.cs
+++ b/backend/Api/BusinessLogic/UserLogic.cs
@@ -1,6 +1,7 @@
using Api.DBAccess;
using Api.Models;
-using Api.Models.User;
+using Api.Models.Devices;
+using Api.Models.Users;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Tokens;
diff --git a/backend/Api/Controllers/DeviceController.cs b/backend/Api/Controllers/DeviceController.cs
index 67727b3..bd03cb2 100644
--- a/backend/Api/Controllers/DeviceController.cs
+++ b/backend/Api/Controllers/DeviceController.cs
@@ -4,6 +4,7 @@ using Api.DBAccess;
using Microsoft.AspNetCore.Authorization;
using Api.BusinessLogic;
using System.Security.Claims;
+using Api.Models.Devices;
namespace Api.Controllers
{
@@ -34,12 +35,12 @@ namespace Api.Controllers
// Sends the device and userId to deviceLogic
[Authorize]
[HttpPost("adddevice")]
- public async Task AddDevice([FromBody] Device device)
+ public async Task AddDevice([FromBody] string referenceId)
{
var claims = HttpContext.User.Claims;
string userIdString = claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;
int userId = Convert.ToInt32(userIdString);
- return await _deviceLogic.AddDevice(device, userId);
+ return await _deviceLogic.AddDevice(referenceId, userId);
}
// Sends the deviceId to deviceLogic
diff --git a/backend/Api/Controllers/UserController.cs b/backend/Api/Controllers/UserController.cs
index 42c940d..de1267f 100644
--- a/backend/Api/Controllers/UserController.cs
+++ b/backend/Api/Controllers/UserController.cs
@@ -3,7 +3,7 @@ using Api.Models;
using System.Security.Claims;
using Microsoft.AspNetCore.Authorization;
using Api.BusinessLogic;
-using Api.Models.User;
+using Api.Models.Users;
namespace Api.Controllers
{
diff --git a/backend/Api/DBAccess/DBAccess.cs b/backend/Api/DBAccess/DBAccess.cs
index c98e194..b688642 100644
--- a/backend/Api/DBAccess/DBAccess.cs
+++ b/backend/Api/DBAccess/DBAccess.cs
@@ -2,7 +2,8 @@
using Api.Models;
using Microsoft.AspNetCore.Mvc;
using static System.Runtime.InteropServices.JavaScript.JSType;
-using Api.Models.User;
+using Api.Models.Devices;
+using Api.Models.Users;
namespace Api.DBAccess
diff --git a/backend/Api/DBAccess/DBContext.cs b/backend/Api/DBAccess/DBContext.cs
index ae2427a..7f66cdb 100644
--- a/backend/Api/DBAccess/DBContext.cs
+++ b/backend/Api/DBAccess/DBContext.cs
@@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore;
-using Api.Models;
-using Api.Models.User;
+using Api.Models.Users;
+using Api.Models.Devices;
namespace Api
{
diff --git a/backend/Api/Models/Device.cs b/backend/Api/Models/Devices/Device.cs
similarity index 90%
rename from backend/Api/Models/Device.cs
rename to backend/Api/Models/Devices/Device.cs
index aa629ed..ee95a16 100644
--- a/backend/Api/Models/Device.cs
+++ b/backend/Api/Models/Devices/Device.cs
@@ -1,4 +1,4 @@
-namespace Api.Models
+namespace Api.Models.Devices
{
public class Device
{
diff --git a/backend/Api/Models/Devices/EditDeviceRequest.cs b/backend/Api/Models/Devices/EditDeviceRequest.cs
new file mode 100644
index 0000000..b48f038
--- /dev/null
+++ b/backend/Api/Models/Devices/EditDeviceRequest.cs
@@ -0,0 +1,6 @@
+namespace Api.Models.Devices
+{
+ public class EditDeviceRequest
+ {
+ }
+}
diff --git a/backend/Api/Models/User/ChangePasswordRequest.cs b/backend/Api/Models/Users/ChangePasswordRequest.cs
similarity index 83%
rename from backend/Api/Models/User/ChangePasswordRequest.cs
rename to backend/Api/Models/Users/ChangePasswordRequest.cs
index 6dff72d..deb190d 100644
--- a/backend/Api/Models/User/ChangePasswordRequest.cs
+++ b/backend/Api/Models/Users/ChangePasswordRequest.cs
@@ -1,4 +1,4 @@
-namespace Api.Models.User
+namespace Api.Models.Users
{
public class ChangePasswordRequest
{
diff --git a/backend/Api/Models/User/EditUserRequest.cs b/backend/Api/Models/Users/EditUserRequest.cs
similarity index 81%
rename from backend/Api/Models/User/EditUserRequest.cs
rename to backend/Api/Models/Users/EditUserRequest.cs
index 6b3f6f8..d4e9c43 100644
--- a/backend/Api/Models/User/EditUserRequest.cs
+++ b/backend/Api/Models/Users/EditUserRequest.cs
@@ -1,4 +1,4 @@
-namespace Api.Models.User
+namespace Api.Models.Users
{
public class EditUserRequest
{
diff --git a/backend/Api/Models/User/User.cs b/backend/Api/Models/Users/User.cs
similarity index 87%
rename from backend/Api/Models/User/User.cs
rename to backend/Api/Models/Users/User.cs
index 8125311..e9729fa 100644
--- a/backend/Api/Models/User/User.cs
+++ b/backend/Api/Models/Users/User.cs
@@ -1,4 +1,6 @@
-namespace Api.Models.User
+using Api.Models.Devices;
+
+namespace Api.Models.Users
{
public class User
{
diff --git a/frontend/scripts/devices.js b/frontend/scripts/devices.js
index 31cf506..bdfd35b 100644
--- a/frontend/scripts/devices.js
+++ b/frontend/scripts/devices.js
@@ -1,10 +1,9 @@
-import { getDevices, deleteDevice, update, add } from "./services/devices.service.js";
import { devices } from "../mockdata/devices.mockdata.js";
import { logout } from "../shared/utils.js";
-getDevices().then(res => {
- buildTable(res)
-})
+// getDevices().then(res => {
+// buildTable(res)
+// })
buildTable(devices);