Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 32 additions & 36 deletions MobileConfiguration/Controllers/MobileConfigurationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,47 @@
using MobileConfiguration.Repository;
using Shared.Results.Web;

namespace MobileConfiguration.Controllers
{
using DataTransferObjects;
using Models;
namespace MobileConfiguration.Controllers;
using DataTransferObjects;
using Models;

[Route("api/[controller]")]
[ApiController]
public class TransactionMobileConfigurationController : ControllerBase
{
private readonly IConfigurationRepository Repository;
[Route("api/[controller]")]
[ApiController]
public class TransactionMobileConfigurationController : ControllerBase
{
private readonly IConfigurationRepository Repository;

public TransactionMobileConfigurationController(IConfigurationRepository repository) {
this.Repository = repository;
}
public TransactionMobileConfigurationController(IConfigurationRepository repository) {
this.Repository = repository;
}

[HttpPost]
public async Task<IActionResult> PostConfiguration([FromBody] Configuration configuration,
CancellationToken cancellationToken) {
[HttpPost]
public async Task<IActionResult> PostConfiguration([FromBody] Configuration configuration,
CancellationToken cancellationToken) {

MobileConfiguration configurationModel = Factories.Factory.ToMobileConfiguration(configuration);
MobileConfiguration configurationModel = Factories.Factory.ToMobileConfiguration(configuration);

var result = await this.Repository.CreateConfiguration(configurationModel, cancellationToken);
var result = await this.Repository.CreateConfiguration(configurationModel, cancellationToken);

return result.ToActionResultX();
}
return result.ToActionResultX();
}

[HttpGet]
[Route("{id}")]
public async Task<IActionResult> GetConfiguration([FromRoute] String id, CancellationToken cancellationToken) {
MobileConfiguration configurationModel = await this.Repository.GetConfiguration(ConfigurationType.TransactionMobile, id, cancellationToken);
[HttpGet]
[Route("{id}")]
public async Task<IActionResult> GetConfiguration([FromRoute] String id, CancellationToken cancellationToken) {
MobileConfiguration configurationModel = await this.Repository.GetConfiguration(ConfigurationType.TransactionMobile, id, cancellationToken);

ConfigurationResponse response = Factories.Factory.ToConfigurationResponse(configurationModel);
return this.Ok(response);
}
ConfigurationResponse response = Factories.Factory.ToConfigurationResponse(configurationModel);

return this.Ok(response);
}

[HttpPut]
public async Task<IActionResult> PutConfiguration(String id, Configuration configuration, CancellationToken cancellationToken) {
MobileConfiguration configurationModel = Factories.Factory.ToMobileConfiguration(configuration);
await this.Repository.UpdateConfiguration(ConfigurationType.TransactionMobile, id, configurationModel, cancellationToken);
[HttpPut]
public async Task<IActionResult> PutConfiguration(String id, Configuration configuration, CancellationToken cancellationToken) {
MobileConfiguration configurationModel = Factories.Factory.ToMobileConfiguration(configuration);

await this.Repository.UpdateConfiguration(ConfigurationType.TransactionMobile, id, configurationModel, cancellationToken);

return this.Ok();
}
return this.Ok();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,53 @@

#nullable disable

namespace MobileConfiguration.Database.Migrations.SqlServer
namespace MobileConfiguration.Database.Migrations.SqlServer;

/// <inheritdoc />
public partial class InitialDatabase : Migration
{
/// <inheritdoc />
public partial class InitialDatabase : Migration
protected override void Up(MigrationBuilder migrationBuilder)
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Configurations",
columns: table => new
{
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
ConfigType = table.Column<int>(type: "int", nullable: false),
ClientId = table.Column<string>(type: "nvarchar(max)", nullable: false),
ClientSecret = table.Column<string>(type: "nvarchar(max)", nullable: false),
DeviceIdentifier = table.Column<string>(type: "nvarchar(max)", nullable: false),
EnableAutoUpdates = table.Column<bool>(type: "bit", nullable: false),
HostAddresses = table.Column<string>(type: "nvarchar(max)", nullable: false),
LogLevelId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Configurations", x => new { x.Id, x.ConfigType });
});
migrationBuilder.CreateTable(
name: "Configurations",
columns: table => new
{
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
ConfigType = table.Column<int>(type: "int", nullable: false),
ClientId = table.Column<string>(type: "nvarchar(max)", nullable: false),
ClientSecret = table.Column<string>(type: "nvarchar(max)", nullable: false),
DeviceIdentifier = table.Column<string>(type: "nvarchar(max)", nullable: false),
EnableAutoUpdates = table.Column<bool>(type: "bit", nullable: false),
HostAddresses = table.Column<string>(type: "nvarchar(max)", nullable: false),
LogLevelId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Configurations", x => new { x.Id, x.ConfigType });
});

migrationBuilder.CreateTable(
name: "LoggingLevels",
columns: table => new
{
LogLevelId = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Description = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_LoggingLevels", x => x.LogLevelId);
});
}
migrationBuilder.CreateTable(
name: "LoggingLevels",
columns: table => new
{
LogLevelId = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Description = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_LoggingLevels", x => x.LogLevelId);
});
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Configurations");
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Configurations");

migrationBuilder.DropTable(
name: "LoggingLevels");
}
migrationBuilder.DropTable(
name: "LoggingLevels");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,34 @@

#nullable disable

namespace MobileConfiguration.Database.Migrations.SqlServer
namespace MobileConfiguration.Database.Migrations.SqlServer;

/// <inheritdoc />
public partial class AddAppCentreConfig : Migration
{
/// <inheritdoc />
public partial class AddAppCentreConfig : Migration
protected override void Up(MigrationBuilder migrationBuilder)
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ApplicationCentreConfigurations",
columns: table => new
{
ApplicationId = table.Column<string>(type: "nvarchar(450)", nullable: false),
AndroidKey = table.Column<string>(type: "nvarchar(max)", nullable: false),
IosKey = table.Column<string>(type: "nvarchar(max)", nullable: false),
MacosKey = table.Column<string>(type: "nvarchar(max)", nullable: false),
WindowsKey = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationCentreConfigurations", x => x.ApplicationId);
});
}
migrationBuilder.CreateTable(
name: "ApplicationCentreConfigurations",
columns: table => new
{
ApplicationId = table.Column<string>(type: "nvarchar(450)", nullable: false),
AndroidKey = table.Column<string>(type: "nvarchar(max)", nullable: false),
IosKey = table.Column<string>(type: "nvarchar(max)", nullable: false),
MacosKey = table.Column<string>(type: "nvarchar(max)", nullable: false),
WindowsKey = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationCentreConfigurations", x => x.ApplicationId);
});
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ApplicationCentreConfigurations");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ApplicationCentreConfigurations");
}
}
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
using Microsoft.EntityFrameworkCore.Migrations;

using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace MobileConfiguration.Database.Migrations.SqlServer
namespace MobileConfiguration.Database.Migrations.SqlServer;
/// <inheritdoc />
public partial class remove_appcentre_config : Migration
{
/// <inheritdoc />
public partial class remove_appcentre_config : Migration
protected override void Up(MigrationBuilder migrationBuilder)
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ApplicationCentreConfigurations");
}
migrationBuilder.DropTable(
name: "ApplicationCentreConfigurations");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ApplicationCentreConfigurations",
columns: table => new
{
ApplicationId = table.Column<string>(type: "nvarchar(450)", nullable: false),
AndroidKey = table.Column<string>(type: "nvarchar(max)", nullable: false),
IosKey = table.Column<string>(type: "nvarchar(max)", nullable: false),
MacosKey = table.Column<string>(type: "nvarchar(max)", nullable: false),
WindowsKey = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationCentreConfigurations", x => x.ApplicationId);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ApplicationCentreConfigurations",
columns: table => new
{
ApplicationId = table.Column<string>(type: "nvarchar(450)", nullable: false),
AndroidKey = table.Column<string>(type: "nvarchar(max)", nullable: false),
IosKey = table.Column<string>(type: "nvarchar(max)", nullable: false),
MacosKey = table.Column<string>(type: "nvarchar(max)", nullable: false),
WindowsKey = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationCentreConfigurations", x => x.ApplicationId);
});
}
}
Loading
Loading