Compare commits

..

No commits in common. "d711134e7f10cf79a5eac22e914c953ebb1cbded" and "1d3f929986d947058e79a466f35ccd84730c0442" have entirely different histories.

5 changed files with 5 additions and 45 deletions

View File

@ -28,21 +28,21 @@ namespace Api.Controllers
return await _deviceLogic.GetDevices(userId);
}
//[Authorize]
[Authorize]
[HttpPost("adddevice/{userId}")]
public async Task<IActionResult> AddDevice([FromBody] Device device, int userId)
{
return await _deviceLogic.AddDevice(device, userId);
}
//[Authorize]
[Authorize]
[HttpGet("logs/{deviceId}")]
public async Task<IActionResult> GetLogs(int deviceId)
{
return await _deviceLogic.GetLogs(deviceId);
}
//[Authorize]
[Authorize]
[HttpPut("Edit/{deviceId}")]
public async Task<IActionResult> EditDevice([FromBody] Device device, int deviceId)
{

View File

@ -33,14 +33,14 @@ namespace Api.Controllers
return await _userLogic.RegisterUser(user);
}
//[Authorize]
[Authorize]
[HttpPut("Edit/{userId}")]
public async Task<IActionResult> EditUser([FromBody] User user, int userId)
{
return await _userLogic.EditProfile(user, userId);
}
//[Authorize]
[Authorize]
[HttpDelete("Delete/{userId}")]
public async Task<IActionResult> DeleteUser(int userId)
{

View File

@ -150,10 +150,6 @@ namespace Api.DBAccess
return await _context.Devices.FirstOrDefaultAsync(d => d.Id == deviceId);
}
public Device ReadDevice(string refenreId)
{
return _context.Devices.FirstOrDefault(d => d.ReferenceId == refenreId);
}
public async Task<IActionResult> UpdateDevice(Device device, int deviceId)
{
@ -187,18 +183,6 @@ namespace Api.DBAccess
return logs;
}
public async void CreateLog(TemperatureLogs temperatureLogs, string referenceId)
{
var device = await _context.Devices.Include(d => d.Logs).FirstOrDefaultAsync(d => d.ReferenceId == referenceId);
if (device == null) { return; }
if (device.Logs == null) { device.Logs = new List<TemperatureLogs>(); }
device.Logs.Add(temperatureLogs);
await _context.SaveChangesAsync();
}
public async Task<bool> Test()
{
return _context.Database.CanConnect();

View File

@ -1,11 +0,0 @@
namespace Api.Models
{
public class MQTTMessageReceive
{
public double temperature { get; set; }
public string device_id { get; set; }
public int timestamp { get; set; }
}
}

View File

@ -1,6 +1,4 @@
using Api;
using Api.DBAccess;
using Api.MQTTReciever;
using Microsoft.AspNetCore;
using Microsoft.EntityFrameworkCore;
@ -10,17 +8,6 @@ class Program
{
var app = CreateWebHostBuilder(args).Build();
using (var scope = app.Services.CreateScope())
{
var services = scope.ServiceProvider;
var configuration = services.GetRequiredService<IConfiguration>();
var dbAccess = services.GetRequiredService<DbAccess>();
MQTTReciever mqtt = new MQTTReciever(configuration, dbAccess);
mqtt.Handle_Received_Application_Message();
}
RunMigrations(app);
app.Run();