diff --git a/BlueWest.Api/MySQL/CountriesDbContext.cs b/BlueWest.Api/MySQL/CountriesDbContext.cs
index 8a50dcb..13d61b7 100644
--- a/BlueWest.Api/MySQL/CountriesDbContext.cs
+++ b/BlueWest.Api/MySQL/CountriesDbContext.cs
@@ -5,7 +5,7 @@ using Microsoft.Extensions.Configuration;
namespace BlueWest.WebApi.MySQL;
///
-/// Table containing countries
+/// Countries and Currencies
///
public class CountriesDbContext : DbContext
{
diff --git a/BlueWest.Api/MySQL/FinanceDbContext.cs b/BlueWest.Api/MySQL/FinanceDbContext.cs
index ab462d7..324b3b9 100644
--- a/BlueWest.Api/MySQL/FinanceDbContext.cs
+++ b/BlueWest.Api/MySQL/FinanceDbContext.cs
@@ -3,10 +3,18 @@ using Microsoft.EntityFrameworkCore;
namespace BlueWest.WebApi.MySQL
{
- public class FinanceDbContext
+ ///
+ /// Finance operations table
+ ///
+ public class FinanceDbContext : DbContext
{
public DbSet Transactions { get; set; }
public DbSet TransactionTypes { get; set; }
+
+ public FinanceDbContext(DbContextOptions options) : base(options)
+ {
+ Database.EnsureCreated();
+ }
}
}
diff --git a/BlueWest.Api/MySQL/UserDbContext.cs b/BlueWest.Api/MySQL/UserDbContext.cs
index 14e7f8a..4cc79c9 100644
--- a/BlueWest.Api/MySQL/UserDbContext.cs
+++ b/BlueWest.Api/MySQL/UserDbContext.cs
@@ -14,6 +14,10 @@ namespace BlueWest.WebApi.MySQL
public IConfiguration Configuration;
+ ///
+ /// Database for the context of database users
+ ///
+ ///
public UserDbContext(DbContextOptions options) : base(options)
{
Database.EnsureCreated();
diff --git a/BlueWest.Api/Startup.cs b/BlueWest.Api/Startup.cs
index dbdade6..9163700 100644
--- a/BlueWest.Api/Startup.cs
+++ b/BlueWest.Api/Startup.cs
@@ -11,6 +11,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
+using System.Text.Json.Serialization;
using System.Threading.Tasks;
using BlueWest.WebApi.MySQL;
using BlueWest.WebApi.Tools;
@@ -42,7 +43,11 @@ namespace BlueWest.WebApi
});*/
});
- services.AddControllers();
+ services.AddControllers()
+ .AddJsonOptions(options =>
+ {
+ options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.Preserve;
+ });
/*services
.AddNewtonsoftJson(options =>
options.SerializerSettings.Converters.Add(new StringEnumConverter()));
@@ -75,10 +80,15 @@ namespace BlueWest.WebApi
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
options.IncludeXmlComments(xmlPath);
});
+
+
services.AddDbContextPool(options =>
- options.GetSqlSettings(Configuration));
-
- services.AddDbContextPool(options =>
+ options.GetSqlSettings(Configuration))
+ .AddDbContextPool(options =>
+ options.GetSqlSettings(Configuration))
+ .AddDbContextPool(options =>
+ options.GetSqlSettings(Configuration))
+ .AddDbContextPool(options =>
options.GetSqlSettings(Configuration));
diff --git a/BlueWest.Data/Country/Country.cs b/BlueWest.Data/Country/Country.cs
index 5f05747..0e16ab1 100644
--- a/BlueWest.Data/Country/Country.cs
+++ b/BlueWest.Data/Country/Country.cs
@@ -5,7 +5,13 @@ using MapTo;
namespace BlueWest.Data
{
- [MapFrom(new [] {typeof(CountryUpdate), typeof(CountryCreate)})]
+ [MapFrom(new []
+ {
+ typeof(CountryUpdate),
+ typeof(CountryCreate),
+ typeof(CountryUnique)
+ })]
+
public partial class Country
{
// ISO 3166-1 numeric code
diff --git a/BlueWest.Data/Country/CountryCreate.cs b/BlueWest.Data/Country/CountryCreate.cs
index e8c8491..b8c596d 100644
--- a/BlueWest.Data/Country/CountryCreate.cs
+++ b/BlueWest.Data/Country/CountryCreate.cs
@@ -11,7 +11,7 @@ namespace BlueWest.Data
public int Code { get; set; } // Primary key
public string StateName { get; set; }
- public List CurrenciesToCreate { get; set; }
+ public List CurrenciesToCreate { get; set; }
[MaxLength(2)] public string Alpha2Code { get; set; }
diff --git a/BlueWest.Data/Country/CountryUnique.cs b/BlueWest.Data/Country/CountryUnique.cs
new file mode 100644
index 0000000..159e9b3
--- /dev/null
+++ b/BlueWest.Data/Country/CountryUnique.cs
@@ -0,0 +1,23 @@
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using MapTo;
+
+namespace BlueWest.Data
+{
+ [MapFrom( typeof(Country))]
+
+ public partial class CountryUnique
+ {
+ // ISO 3166-1 numeric code
+ public int Code { get; set; } // Primary key
+ public string StateName { get; set; }
+
+ [MaxLength(2)] public string Alpha2Code { get; set; }
+
+ public string TLD { get; set; }
+
+ public CountryUnique() { }
+
+ }
+}
+
diff --git a/BlueWest.Data/Currency/Currency.cs b/BlueWest.Data/Currency/Currency.cs
index 6ca39a2..d3155ba 100644
--- a/BlueWest.Data/Currency/Currency.cs
+++ b/BlueWest.Data/Currency/Currency.cs
@@ -6,7 +6,9 @@ namespace BlueWest.Data
{
[MapFrom(new []{
typeof(CurrencyUpdate),
- typeof(CurrencyCreate)})]
+ typeof(CurrencyCreate),
+ typeof(CurrencyUnique)
+ })]
public partial class Currency
{
diff --git a/BlueWest.Data/Currency/CurrencyCreate.cs b/BlueWest.Data/Currency/CurrencyCreate.cs
index 388f999..f6038a3 100644
--- a/BlueWest.Data/Currency/CurrencyCreate.cs
+++ b/BlueWest.Data/Currency/CurrencyCreate.cs
@@ -9,8 +9,7 @@ namespace BlueWest.Data
{
public int Num { get; set; } // Primary key
[MaxLength(3)] public string Code { get; set; }
-
- public List CountriesToCreate { get; set; }
+ public List CountriesToCreate { get; set; }
public CurrencyCreate() { }
public Currency ToCurrency()
diff --git a/BlueWest.Data/Currency/CurrencyUnique.cs b/BlueWest.Data/Currency/CurrencyUnique.cs
new file mode 100644
index 0000000..fd56688
--- /dev/null
+++ b/BlueWest.Data/Currency/CurrencyUnique.cs
@@ -0,0 +1,18 @@
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using MapTo;
+
+namespace BlueWest.Data
+{
+ [MapFrom(typeof(Currency))]
+ public partial class CurrencyUnique
+ {
+ public int Num { get; set; } // Primary key
+ [MaxLength(3)] public string Code { get; set; }
+
+ public CurrencyUnique() { }
+
+
+ }
+}
+
diff --git a/BlueWest.Data/Currency/CurrencyUpdate.cs b/BlueWest.Data/Currency/CurrencyUpdate.cs
index c662f9c..c9427b7 100644
--- a/BlueWest.Data/Currency/CurrencyUpdate.cs
+++ b/BlueWest.Data/Currency/CurrencyUpdate.cs
@@ -11,9 +11,6 @@ namespace BlueWest.Data
// ISO 4217 Code
[MaxLength(3)] public string Code { get; set; }
- public CurrencyUpdate()
- {
-
- }
+ public CurrencyUpdate() { }
}
}