renamed model folder
This commit is contained in:
parent
82efeff40b
commit
9529d2cdc8
@ -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
|
||||
/// <param name="device">The new device</param>
|
||||
/// <param name="userId">The user that owns the device</param>
|
||||
/// <returns>returns true in a OkObjectResult and if there is some error it returns a ConflictObjectResult and a message that explain the reason</returns>
|
||||
public async Task<IActionResult> AddDevice(Device device, int userId)
|
||||
public async Task<IActionResult> 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<TemperatureLogs>(),
|
||||
};
|
||||
|
||||
|
||||
return await _dbAccess.CreateDevice(device, userId);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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<IActionResult> AddDevice([FromBody] Device device)
|
||||
public async Task<IActionResult> 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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -1,6 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Api.Models;
|
||||
using Api.Models.User;
|
||||
using Api.Models.Users;
|
||||
using Api.Models.Devices;
|
||||
|
||||
namespace Api
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace Api.Models
|
||||
namespace Api.Models.Devices
|
||||
{
|
||||
public class Device
|
||||
{
|
6
backend/Api/Models/Devices/EditDeviceRequest.cs
Normal file
6
backend/Api/Models/Devices/EditDeviceRequest.cs
Normal file
@ -0,0 +1,6 @@
|
||||
namespace Api.Models.Devices
|
||||
{
|
||||
public class EditDeviceRequest
|
||||
{
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
namespace Api.Models.User
|
||||
namespace Api.Models.Users
|
||||
{
|
||||
public class ChangePasswordRequest
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
namespace Api.Models.User
|
||||
namespace Api.Models.Users
|
||||
{
|
||||
public class EditUserRequest
|
||||
{
|
@ -1,4 +1,6 @@
|
||||
namespace Api.Models.User
|
||||
using Api.Models.Devices;
|
||||
|
||||
namespace Api.Models.Users
|
||||
{
|
||||
public class User
|
||||
{
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user