Commit 0a35c2ff authored by cann-alberto's avatar cann-alberto
Browse files

Deploy 05/03/2025

parent 82275fe1
......@@ -9,9 +9,9 @@ namespace MMM_Server.Controllers;
public class ActivityController: ControllerBase
{
private readonly UserService _usersService;
private readonly ActionService _actionsService;
private readonly ActionRequestService _actionsService;
public ActivityController(UserService usersService, ActionService actionService)
public ActivityController(UserService usersService, ActionRequestService actionService)
{
_usersService = usersService;
_actionsService = actionService;
......@@ -21,11 +21,11 @@ public class ActivityController: ControllerBase
public async Task<List<User>> Get() =>
await _usersService.GetAsync();
[HttpGet("actions")]
[HttpGet("logins")]
public async Task<List<ActionRequest>> GetActions() =>
await _actionsService.GetAsync();
[HttpPost("actions")]
[HttpPost("logins")]
public async Task<IActionResult> Post(ActionRequest newAction)
{
await _actionsService.CreateAsync(newAction);
......
using Microsoft.AspNetCore.Mvc;
using MMM_Server.Models;
using MMM_Server.Services;
namespace MMM_Server.Controllers;
[ApiController]
[Route("api/[controller]")]
public class CommunicationController : ControllerBase
{
private readonly MessageService _messageService;
public CommunicationController(MessageService messageService)
{
_messageService = messageService;
}
[HttpGet("messages")]
public async Task<List<Message>> Get() =>
await _messageService.GetAsync();
[HttpPost("messages")]
public async Task<IActionResult> Post(Message newMessage)
{
await _messageService.CreateAsync(newMessage);
return CreatedAtAction(nameof(Get), new { id = newMessage.MessageID }, newMessage);
}
}
using Microsoft.AspNetCore.Mvc;
using MMM_Server.Models;
using MMM_Server.Services;
namespace MMM_Server.Controllers;
[ApiController]
[Route("api/[controller]")]
public class LocationController : ControllerBase
{
private readonly ActionRequestService _actionRequestService;
public LocationController(ActionRequestService actionRequestService)
{
_actionRequestService = actionRequestService;
}
[HttpGet("action-requests")]
public async Task<List<ActionRequest>> Get() =>
await _actionRequestService.GetAsync();
[HttpPost("action-request")]
public async Task<IActionResult> Post(ActionRequest newActionRequest)
{
await _actionRequestService.CreateAsync(newActionRequest);
return CreatedAtAction(nameof(Get), new { id = newActionRequest.ActionRequestID }, newActionRequest);
}
}
\ No newline at end of file
using Microsoft.AspNetCore.Mvc;
using MMM_Server.Models;
using MMM_Server.Services;
namespace MMM_Server.Controllers;
[ApiController]
[Route("api/[controller]")]
public class TransactController : ControllerBase
{
private readonly TransactService _transactService;
public TransactController (TransactService transactService)
{
_transactService = transactService;
}
[HttpGet("transactions")]
public async Task<List<Transaction>> Get() =>
await _transactService.GetAsync();
[HttpPost("transaction")]
public async Task<IActionResult> Post(Transaction newTransaction)
{
await _transactService.CreateAsync(newTransaction);
return CreatedAtAction(nameof(Get), new { id = newTransaction.TransactionID }, newTransaction);
}
}
......@@ -2,5 +2,7 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>https</ActiveDebugProfile>
<Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID>
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
</PropertyGroup>
</Project>
\ No newline at end of file
......@@ -8,14 +8,12 @@ namespace MMM_Server.Models
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string? ActionRequestID { get; set; }
public string Time{ get; set; } = null!;
public string Source { get; set; } = null!;
public string Destination { get; set; } = null!;
public string Action { get; set; } = null!;
public string InItem { get; set; } = null!;
public string InLocation { get; set; } = null!;
public string OutLocation { get; set; } = null!;
public string RightsID { get; set; } = null!;
public string? Time{ get; set; } = null!;
public string? Action { get; set; } = null!;
public string? SProcess{ get; set; } = null!;
public string? SComplements { get; set; } = null!;
public string? DProcess { get; set; } = null!;
public string? DComplements { get; set; } = null!;
}
......
namespace MMM_Server.Models
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson;
namespace MMM_Server.Models
{
public class ActionResponse
{
public string Response { get; set; } = null!;
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string? ActionResponseID { get; set; }
public string Time { get; set; } = null!;
public string Action { get; set; } = null!;
public string SProcess { get; set; } = null!;
public string DProcess { get; set; } = null!;
}
......
......@@ -9,8 +9,9 @@
public string PersonaeCollectionName { get; set; } = null!;
public string DevicesCollectionName { get; set; } = null!;
public string AccountsCollectionName { get; set; } = null!;
public string ActionsCollectionName { get; set; } = null!;
public string ActionRequestsCollectionName { get; set; } = null!;
public string TransactionsCollectionName { get; set; } = null!;
public string MessagesCollectionName { get; set; } = null!;
}
}
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson;
namespace MMM_Server.Models;
public class Message
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string? MessageID { get; set; }
public string Body { get; set; } = null;
public string Source { get; set; } = null;
public string Destination { get; set; } = null;
public string? Time { get; set; } = null!;
}
\ No newline at end of file
namespace MMM_Server.Models;
public class SpatialAttitude
{
public Position? Position { get; set; } = null!;
public Orientation? Orientation { get; set; } = null!;
public Velocities? Velocities { get; set; } = null!;
public Accelerations? Accelerations { get; set; } = null!;
}
public class Position
{
public float X { get; set; }
public float Y { get; set; }
public float Z { get; set; }
}
public class Orientation
{
public float X { get; set; }
public float Y { get; set; }
public float Z { get; set; }
}
public class Velocities
{
public float X { get; set; }
public float Y { get; set; }
public float Z { get; set; }
}
public class Accelerations
{
public float X { get; set; }
public float Y { get; set; }
public float Z { get; set; }
}

using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson;
namespace MMM_Server.Models;
public class Transaction
{
public string Header { get; set; } = null!;
public string MInstanceID { get; set; } = null!;
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string? TransactionID { get; set; }
public TransactionData TransactionData { get; set; } = null!;
public string DescrMetadata { get; set; } = null!;
}
public class TransactionData
{
public string AssetID { get; set; } = null;
public string TransactionTime { get; set; } = null!;
public SenderData? SenderData { get; set; } = null!;
public ReceiverData? ReceiverData { get; set; } = null;
public ServiceProviderData? ServiceProviderData { get; set; } = null;
}
public class SenderData
{
public string SenderID { get; set; } = null;
public string RToSValue { get; set; } = null!;
public string SToSPValue { get; set; } = null!;
public string SenderRightsID { get; set; } = null!;
public string SenderWalletID { get; set; } = null!;
}
public class ReceiverData
{
public string ReceiverID { get; set; } = null;
public string RToSPValue { get; set; } = null!;
public string ReceiverRightsID { get; set; } = null!;
public string ReceiverWalletID { get; set; } = null!;
}
public class ServiceProviderData
{
public string ServiceProviderID { get; set; } = null!;
public string ServiceProviderWalletID { get; set; } = null!;
}
......@@ -10,7 +10,9 @@ builder.Services.AddSingleton<UserService>();
builder.Services.AddSingleton<DeviceService>();
builder.Services.AddSingleton<PersonaService>();
builder.Services.AddSingleton<AccountService>();
builder.Services.AddSingleton<ActionService>();
builder.Services.AddSingleton<ActionRequestService>();
builder.Services.AddSingleton<TransactService>();
builder.Services.AddSingleton<MessageService>();
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
......
......@@ -19,7 +19,6 @@ public class AccountService : MongoDbService<Account>
// Add custom logic if needed
return await _collection.Find(x => x.AccountID == id).FirstOrDefaultAsync();
}
public async Task UpdateAsync(string id, Persona updatedItem)
{
......@@ -82,7 +81,6 @@ public class AccountService : MongoDbService<Account>
}
}
public async Task<Account> GetByHumanIdAsync(string humanId)
{
// Build the filter to query the database for the HumanID
......
......@@ -3,10 +3,10 @@ using MMM_Server.Models;
namespace MMM_Server.Services
{
public class ActionService : MongoDbService<ActionRequest>
public class ActionRequestService : MongoDbService<ActionRequest>
{
public ActionService(IOptions<MMMDatabaseSettings> actionDatabaseSettings)
: base(actionDatabaseSettings, actionDatabaseSettings.Value.ActionsCollectionName)
public ActionRequestService(IOptions<MMMDatabaseSettings> actionDatabaseSettings)
: base(actionDatabaseSettings, actionDatabaseSettings.Value.ActionRequestsCollectionName)
{
}
......
using Microsoft.Extensions.Options;
using MMM_Server.Models;
using MongoDB.Driver;
namespace MMM_Server.Services;
public class MessageService: MongoDbService<Message>
{
public MessageService(IOptions<MMMDatabaseSettings> messageDatabaseSettings)
: base(messageDatabaseSettings, messageDatabaseSettings.Value.MessagesCollectionName)
{
}
public async Task<Message?> GetAsync(string id)
{
// Add custom logic if needed
return await _collection.Find(x => x.MessageID == id).FirstOrDefaultAsync();
}
}
......@@ -21,7 +21,5 @@ public class MongoDbService<T>
await _collection.Find(_ => true).ToListAsync();
public async Task CreateAsync(T newItem) =>
await _collection.InsertOneAsync(newItem);
await _collection.InsertOneAsync(newItem);
}
using Microsoft.Extensions.Options;
using MMM_Server.Models;
using MongoDB.Driver;
namespace MMM_Server.Services
{
public class TransactService : MongoDbService<Transaction>
{
public TransactService(IOptions<MMMDatabaseSettings> transactionDatabaseSettings)
: base(transactionDatabaseSettings, transactionDatabaseSettings.Value.TransactionsCollectionName)
{
}
public async Task<Transaction?> GetAsync(string id)
{
// Add custom logic if needed
return await _collection.Find(x => x.TransactionID == id).FirstOrDefaultAsync();
}
}
}
......@@ -7,8 +7,9 @@
"DevicesCollectionName": "Devices",
"PersonaeCollectionName": "Personae",
"AccountsCollectionName": "Accounts",
"ActionsCollectionName": "Actions"
"ActionRequestsCollectionName": "Actions",
"TransactionsCollectionName": "Transactions",
"MessagesCollectionName": "Messages"
},
"Logging": {
"LogLevel": {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment