-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e14910
commit 2b6e5d7
Showing
11 changed files
with
416 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,33 @@ | ||
WebApplicationBuilder builder = WebApplication.CreateBuilder(args); | ||
|
||
// Add services to the container. | ||
|
||
builder.Services.AddControllers(); | ||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle | ||
builder.Services.AddEndpointsApiExplorer(); | ||
builder.Services.AddSwaggerGen(); | ||
|
||
WebApplication app = builder.Build(); | ||
|
||
// Configure the HTTP request pipeline. | ||
if (app.Environment.IsDevelopment()) | ||
{ | ||
app.UseSwagger(); | ||
app.UseSwaggerUI(); | ||
} | ||
|
||
app.UseHttpsRedirection(); | ||
|
||
app.UseAuthorization(); | ||
|
||
app.MapControllers(); | ||
|
||
app.Run(); | ||
using Matroos.Backend.Services; | ||
using Matroos.Backend.Services.Interfaces; | ||
|
||
WebApplicationBuilder builder = WebApplication.CreateBuilder(args); | ||
|
||
// Add services to the container. | ||
|
||
builder.Services.AddControllers(); | ||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle | ||
builder.Services.AddEndpointsApiExplorer(); | ||
builder.Services.AddSwaggerGen(); | ||
|
||
// Services | ||
builder.Services.AddSingleton<IBotsService, BotsService>(); | ||
builder.Services.AddSingleton<IUserCommandsService, UserCommandsService>(); | ||
builder.Services.AddSingleton<IWorkersService, WorkersService>(); | ||
|
||
WebApplication app = builder.Build(); | ||
|
||
// Configure the HTTP request pipeline. | ||
if (app.Environment.IsDevelopment()) | ||
{ | ||
app.UseSwagger(); | ||
app.UseSwaggerUI(); | ||
} | ||
|
||
app.UseHttpsRedirection(); | ||
|
||
app.UseAuthorization(); | ||
|
||
app.MapControllers(); | ||
|
||
app.Run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Matroos.Resources.Classes.Bots; | ||
|
||
namespace Matroos.Backend.Services.Interfaces; | ||
|
||
public class BotsService : IBotsService | ||
{ | ||
/// <summary> | ||
/// The bots. | ||
/// </summary> | ||
public List<Bot> Bots { get; } | ||
|
||
/// <summary> | ||
/// Default constructor. | ||
/// </summary> | ||
public BotsService() | ||
{ | ||
Bots = new List<Bot>(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public bool AddBot(Bot bot) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public bool DeleteBot(Guid botId) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public bool UpdateBot(Bot bot) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
backend/src/Matroos.Backend/Services/Interfaces/IBotsService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Matroos.Resources.Classes.Bots; | ||
|
||
namespace Matroos.Backend.Services; | ||
|
||
public interface IBotsService | ||
{ | ||
/// <summary> | ||
/// Add a new bot. | ||
/// </summary> | ||
/// <param name="bot">The bot.</param> | ||
/// <returns>Whether the operation was successful or not.</returns> | ||
public bool AddBot(Bot bot); | ||
|
||
/// <summary> | ||
/// Update the data of a bot. | ||
/// </summary> | ||
/// <param name="bot">The bot with the updated data.</param> | ||
/// <returns>Whether the operation was successful or not.</returns> | ||
public bool UpdateBot(Bot bot); | ||
|
||
/// <summary> | ||
/// Delete a bot. | ||
/// </summary> | ||
/// <param name="botId">The identifier of the bot to be removed.</param> | ||
/// <returns>Whether the operation was successful or not.</returns> | ||
public bool DeleteBot(Guid botId); | ||
} |
27 changes: 27 additions & 0 deletions
27
backend/src/Matroos.Backend/Services/Interfaces/IUserCommandsService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Matroos.Resources.Classes.Commands; | ||
|
||
namespace Matroos.Backend.Services; | ||
|
||
public interface IUserCommandsService | ||
{ | ||
/// <summary> | ||
/// Add a new user command. | ||
/// </summary> | ||
/// <param name="userCommand">The user command to be added.</param> | ||
/// <returns>Whether the operation was successful or not.</returns> | ||
public bool AddUserCommand(UserCommand userCommand); | ||
|
||
/// <summary> | ||
/// Update the data of a command. | ||
/// </summary> | ||
/// <param name="userCommand">The user command with the updated data.</param> | ||
/// <returns>Whether the operation was successful or not.</returns> | ||
public bool UpdateUserCommand(UserCommand userCommand); | ||
|
||
/// <summary> | ||
/// Delete a command. | ||
/// </summary> | ||
/// <param name="userCommandId">The identifier of the user command to be removed.</param> | ||
/// <returns>Whether the operation was successful or not.</returns> | ||
public bool DeleteUserCommand(Guid userCommandId); | ||
} |
53 changes: 53 additions & 0 deletions
53
backend/src/Matroos.Backend/Services/Interfaces/IWorkersService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using Matroos.Resources.Classes.Bots; | ||
|
||
namespace Matroos.Backend.Services; | ||
|
||
public interface IWorkersService | ||
{ | ||
/// <summary> | ||
/// Starts a bot in a worker. | ||
/// </summary> | ||
/// <param name="workerId">The identifier of the worker where to start the bot.</param> | ||
/// <param name="botId">The identifier of the bot to be started.</param> | ||
/// <returns>Whether the operation was successful or not.</returns> | ||
public bool StartBotInWorker(Guid workerId, Guid botId); | ||
|
||
/// <summary> | ||
/// Stops a bot in a worker. | ||
/// </summary> | ||
/// <param name="workerId">The identifier of the worker where to stop the bot.</param> | ||
/// <param name="botId">The identifier of the bot to be stop.</param> | ||
/// <returns>Whether the operation was successful or not.</returns> | ||
public bool StopBotInWorker(Guid workerId, Guid botId); | ||
|
||
/// <summary> | ||
/// Gets all the bots from a worker. | ||
/// </summary> | ||
/// <param name="workerId">The identifier of the worker where to get the bots.</param> | ||
/// <returns>Whether the operation was successful or not.</returns> | ||
public Task<List<Bot>> GetBotsFromWorker(Guid workerId); | ||
|
||
/// <summary> | ||
/// Adds bots to a worker. | ||
/// </summary> | ||
/// <param name="workerId">The identifier of the worker where to add the bots.</param> | ||
/// <param name="botIds">A list containing the identifiers of the bots to be added.</param> | ||
/// <returns>Whether the operation was successful or not.</returns> | ||
public bool AddBotsToWorker(Guid workerId, List<Guid> botIds); | ||
|
||
/// <summary> | ||
/// Updates the data of the given bots in a worker. | ||
/// </summary> | ||
/// <param name="workerId">The identifier of the worker where to update the data.</param> | ||
/// <param name="botIds">A list containing the identifiers of the bots to be updated.</param> | ||
/// <returns>Whether the operation was successful or not.</returns> | ||
public bool UpdateBotsInWorker(Guid workerId, List<Guid> botIds); | ||
|
||
/// <summary> | ||
/// Deletes bots from a worker. | ||
/// </summary> | ||
/// <param name="workerId">The identifier of the worker where to delete the bots.</param> | ||
/// <param name="botIds">A list containing the identifiers of the bots to be removed.</param> | ||
/// <returns>Whether the operation was successful or not.</returns> | ||
public bool DeleteBotsFromWorker(Guid workerId, List<Guid> botIds); | ||
} |
37 changes: 37 additions & 0 deletions
37
backend/src/Matroos.Backend/Services/UserCommandsService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Matroos.Resources.Classes.Commands; | ||
|
||
namespace Matroos.Backend.Services.Interfaces; | ||
|
||
public class UserCommandsService : IUserCommandsService | ||
{ | ||
/// <summary> | ||
/// The user commands. | ||
/// </summary> | ||
public List<UserCommand> UserCommands { get; } | ||
|
||
/// <summary> | ||
/// Default constructor. | ||
/// </summary> | ||
public UserCommandsService() | ||
{ | ||
UserCommands = new(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public bool AddUserCommand(UserCommand userCommand) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public bool DeleteUserCommand(Guid userCommandId) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public bool UpdateUserCommand(UserCommand userCommand) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using Matroos.Resources.Classes.Bots; | ||
using Matroos.Resources.Classes.Workers; | ||
|
||
namespace Matroos.Backend.Services.Interfaces; | ||
|
||
public class WorkersService : IWorkersService | ||
{ | ||
/// <summary> | ||
/// The workers. | ||
/// </summary> | ||
public List<Worker> Workers { get; } | ||
|
||
public WorkersService() | ||
{ | ||
Workers = new(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public bool StartBotInWorker(Guid workerId, Guid botId) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public bool StopBotInWorker(Guid workerId, Guid botId) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public Task<List<Bot>> GetBotsFromWorker(Guid workerId) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public bool AddBotsToWorker(Guid workerId, List<Guid> botIds) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public bool UpdateBotsInWorker(Guid workerId, List<Guid> botIds) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public bool DeleteBotsFromWorker(Guid workerId, List<Guid> botIds) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Controllers\" /> | ||
</ItemGroup> | ||
|
||
</Project> | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Controllers\" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\resources\src\Matroos.Resources\Matroos.Resources.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,31 @@ | ||
WebApplicationBuilder builder = WebApplication.CreateBuilder(args); | ||
|
||
// Add services to the container. | ||
|
||
builder.Services.AddControllers(); | ||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle | ||
builder.Services.AddEndpointsApiExplorer(); | ||
builder.Services.AddSwaggerGen(); | ||
|
||
WebApplication app = builder.Build(); | ||
|
||
// Configure the HTTP request pipeline. | ||
if (app.Environment.IsDevelopment()) | ||
{ | ||
app.UseSwagger(); | ||
app.UseSwaggerUI(); | ||
} | ||
|
||
app.UseHttpsRedirection(); | ||
|
||
app.UseAuthorization(); | ||
|
||
app.MapControllers(); | ||
|
||
app.Run(); | ||
using Matroos.Worker.Services; | ||
using Matroos.Worker.Services.Interfaces; | ||
|
||
WebApplicationBuilder builder = WebApplication.CreateBuilder(args); | ||
|
||
// Add services to the container. | ||
|
||
builder.Services.AddControllers(); | ||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle | ||
builder.Services.AddEndpointsApiExplorer(); | ||
builder.Services.AddSwaggerGen(); | ||
|
||
// Services | ||
builder.Services.AddSingleton<IMainService, MainService>(); | ||
|
||
WebApplication app = builder.Build(); | ||
|
||
// Configure the HTTP request pipeline. | ||
if (app.Environment.IsDevelopment()) | ||
{ | ||
app.UseSwagger(); | ||
app.UseSwaggerUI(); | ||
} | ||
|
||
app.UseHttpsRedirection(); | ||
|
||
app.UseAuthorization(); | ||
|
||
app.MapControllers(); | ||
|
||
app.Run(); |
Oops, something went wrong.