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
69 changes: 33 additions & 36 deletions MobileConfiguration/Controllers/MobileConfigurationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,48 @@
using MobileConfiguration.Repository;
using Shared.Results.Web;

namespace MobileConfiguration.Controllers
{
using DataTransferObjects;
using Models;

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

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

[HttpPost]
public async Task<IActionResult> PostConfiguration([FromBody] Configuration configuration,
CancellationToken cancellationToken) {
[Route("api/[controller]")]
[ApiController]
public class TransactionMobileConfigurationController : ControllerBase
{
private readonly IConfigurationRepository Repository;

MobileConfiguration configurationModel = Factories.Factory.ToMobileConfiguration(configuration);
public TransactionMobileConfigurationController(IConfigurationRepository repository) {
this.Repository = repository;
}

var result = await this.Repository.CreateConfiguration(configurationModel, cancellationToken);
[HttpPost]
public async Task<IActionResult> PostConfiguration([FromBody] Configuration configuration,
CancellationToken cancellationToken) {

return result.ToActionResultX();
}
MobileConfiguration configurationModel = Factories.Factory.ToMobileConfiguration(configuration);

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

ConfigurationResponse response = Factories.Factory.ToConfigurationResponse(configurationModel);

return this.Ok(response);
}
return result.ToActionResultX();
}

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

return this.Ok();
}
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);

return this.Ok();
}
}
Original file line number Diff line number Diff line change
@@ -1,55 +1,54 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;

#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
Expand Up @@ -2,35 +2,33 @@

#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);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,57 @@

#nullable disable

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

[DbContext(typeof(ConfigurationContext))]
partial class ConfigurationSqlServerContextModelSnapshot : ModelSnapshot
{
[DbContext(typeof(ConfigurationContext))]
partial class ConfigurationSqlServerContextModelSnapshot : ModelSnapshot
protected override void BuildModel(ModelBuilder modelBuilder)
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
modelBuilder
.HasAnnotation("ProductVersion", "9.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 128);

SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);

modelBuilder.Entity("MobileConfiguration.Database.Entities.Configuration", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
modelBuilder.Entity("MobileConfiguration.Database.Entities.Configuration", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");

b.Property<int>("ConfigType")
.HasColumnType("int");
b.Property<int>("ConfigType")
.HasColumnType("int");

b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("ClientSecret")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ClientSecret")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("DeviceIdentifier")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("DeviceIdentifier")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<bool>("EnableAutoUpdates")
.HasColumnType("bit");
b.Property<bool>("EnableAutoUpdates")
.HasColumnType("bit");

b.Property<string>("HostAddresses")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("HostAddresses")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<int>("LogLevelId")
.HasColumnType("int");
b.Property<int>("LogLevelId")
.HasColumnType("int");

b.HasKey("Id", "ConfigType");
b.HasKey("Id", "ConfigType");

b.ToTable("Configurations");
});
b.ToTable("Configurations");
});

modelBuilder.Entity("MobileConfiguration.Database.Entities.LoggingLevels", b =>
{
modelBuilder.Entity("MobileConfiguration.Database.Entities.LoggingLevels", b =>
{
b.Property<int>("LogLevelId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
Expand All @@ -75,4 +75,4 @@
#pragma warning restore 612, 618
}
}
}

Check failure on line 78 in MobileConfiguration/Database/Migrations/SqlServer/ConfigurationSqlServerContextModelSnapshot.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Type or namespace definition, or end-of-file expected

Check failure on line 78 in MobileConfiguration/Database/Migrations/SqlServer/ConfigurationSqlServerContextModelSnapshot.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Type or namespace definition, or end-of-file expected
Loading
Loading