Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -369,3 +369,4 @@ FodyWeavers.xsd

.idea/
Imports/
.idea/
15 changes: 0 additions & 15 deletions .idea/.idea.DataImport/.idea/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/.idea.DataImport/.idea/encodings.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/.idea.DataImport/.idea/indexLayout.xml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/.idea.DataImport/.idea/vcs.xml

This file was deleted.

25 changes: 13 additions & 12 deletions DataImport.API/Controllers/CountryController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using DataImport.API.Controllers.BaseController;
using DataImport.Commands.Queries;
using DataImport.Data.Enums; // <-- add this

namespace DataImport.API.Controllers;

[Route("api/v{version:apiVersion}/[controller]")]
public class CountryController : ApiControllerBasev1
{
private readonly IMediator _mediator;

public CountryController(IMediator mediator)
{
_mediator = mediator;
Expand All @@ -15,30 +17,29 @@ public CountryController(IMediator mediator)
[HttpPost]
[Route("get-count-by-country")]
public async Task<IActionResult> GetCountryCount(
[FromQuery] GetCountryCountQuery request,
[FromQuery] Country country,
CancellationToken ct)
{
if (string.IsNullOrWhiteSpace(request?.country.ToString()))
return BadRequest("Country name is required");

var result = await _mediator.Send(
new GetCountryCountQuery(request.country),
ct);
if (!Enum.IsDefined(typeof(Country), country))
return BadRequest("Valid country is required");

var result = await _mediator.Send(new GetCountryCountQuery(country), ct);
return Ok(result);
}

[HttpPost]
[Route("get-sanctions-by-country")]
public async Task<IActionResult> GetCountrySanctionsPaged(
[FromQuery] GetCountrySanctionsPagedQuery request,
CancellationToken ct)
[FromQuery] Country country,
[FromQuery] int pageSize = 20,
[FromQuery] int page = 1,
CancellationToken ct = default)
{
if (string.IsNullOrWhiteSpace(request?.country.ToString()))
return BadRequest("Country name is required");
if (!Enum.IsDefined(typeof(Country), country))
return BadRequest("Valid country is required");

var result = await _mediator.Send(
new GetCountrySanctionsPagedQuery(request.country),
new GetCountrySanctionsPagedQuery(country, pageSize, page),
ct);

return Ok(result);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace DataImport.Migrations
{
/// <inheritdoc />
public partial class AddedFieldsForDelisting : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ContentHash",
table: "SanctionDetails",
type: "nvarchar(64)",
maxLength: 64,
nullable: true);

migrationBuilder.AddColumn<bool>(
name: "IsActive",
table: "SanctionDetails",
type: "bit",
nullable: false,
defaultValue: false);

migrationBuilder.AddColumn<DateTime>(
name: "LastSeenAtUtc",
table: "SanctionDetails",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

migrationBuilder.AddColumn<DateTime>(
name: "RemovedAtUtc",
table: "SanctionDetails",
type: "datetime2",
nullable: true);

migrationBuilder.AddColumn<int>(
name: "Removed",
table: "DataImportLogs",
type: "int",
nullable: false,
defaultValue: 0);

migrationBuilder.CreateIndex(
name: "IX_SanctionDetails_IsActive_SdnType_LastName",
table: "SanctionDetails",
columns: new[] { "IsActive", "SdnType", "LastName" });
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_SanctionDetails_IsActive_SdnType_LastName",
table: "SanctionDetails");

migrationBuilder.DropColumn(
name: "ContentHash",
table: "SanctionDetails");

migrationBuilder.DropColumn(
name: "IsActive",
table: "SanctionDetails");

migrationBuilder.DropColumn(
name: "LastSeenAtUtc",
table: "SanctionDetails");

migrationBuilder.DropColumn(
name: "RemovedAtUtc",
table: "SanctionDetails");

migrationBuilder.DropColumn(
name: "Removed",
table: "DataImportLogs");
}
}
}
18 changes: 18 additions & 0 deletions DataImport.Data/Migrations/SanctionsDbContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<DateTime>("RanAtUtc")
.HasColumnType("datetime2");

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

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

Expand Down Expand Up @@ -69,6 +72,10 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");

b.Property<string>("ContentHash")
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");

b.Property<string>("Country")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
Expand All @@ -80,16 +87,25 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<DateTime>("ImportedAtUtc")
.HasColumnType("datetime2");

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

b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(350)
.HasColumnType("nvarchar(350)");

b.Property<DateTime>("LastSeenAtUtc")
.HasColumnType("datetime2");

b.Property<string>("RecordUniqueId")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");

b.Property<DateTime?>("RemovedAtUtc")
.HasColumnType("datetime2");

b.Property<string>("SdnType")
.IsRequired()
.HasMaxLength(20)
Expand All @@ -106,6 +122,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.HasIndex("SdnType", "LastName");

b.HasIndex("IsActive", "SdnType", "LastName");

b.ToTable("SanctionDetails");
});
#pragma warning restore 612, 618
Expand Down
6 changes: 3 additions & 3 deletions DataImport.Data/Models/DataImportLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public class DataImportLog
public int Inserted { get; set; }
public int Updated { get; set; }
public int Unchanged { get; set; }
public bool WasDownloaded { get; set; }
public int Removed { get; set; }
public bool WasDownloaded { get; set; }
public bool Succeeded { get; set; }
public string? ErrorMessage { get; set; }

public string? ErrorMessage { get; set; }
}
}
Loading
Loading