Fix data type errors
This commit is contained in:
parent
3b350c6a46
commit
ce43ecf51d
|
@ -5,7 +5,7 @@ using Microsoft.Extensions.Configuration;
|
|||
namespace BlueWest.WebApi.MySQL;
|
||||
|
||||
/// <summary>
|
||||
/// Table containing countries
|
||||
/// Countries and Currencies
|
||||
/// </summary>
|
||||
public class CountriesDbContext : DbContext
|
||||
{
|
||||
|
|
|
@ -3,10 +3,18 @@ using Microsoft.EntityFrameworkCore;
|
|||
|
||||
namespace BlueWest.WebApi.MySQL
|
||||
{
|
||||
public class FinanceDbContext
|
||||
/// <summary>
|
||||
/// Finance operations table
|
||||
/// </summary>
|
||||
public class FinanceDbContext : DbContext
|
||||
{
|
||||
public DbSet<FinanceOp> Transactions { get; set; }
|
||||
public DbSet<FinanceOpType> TransactionTypes { get; set; }
|
||||
|
||||
public FinanceDbContext(DbContextOptions<UserDbContext> options) : base(options)
|
||||
{
|
||||
Database.EnsureCreated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,10 @@ namespace BlueWest.WebApi.MySQL
|
|||
public IConfiguration Configuration;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Database for the context of database users
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
public UserDbContext(DbContextOptions<UserDbContext> options) : base(options)
|
||||
{
|
||||
Database.EnsureCreated();
|
||||
|
|
|
@ -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<UserDbContext>(options =>
|
||||
options.GetSqlSettings(Configuration));
|
||||
|
||||
services.AddDbContextPool<CountriesDbContext>(options =>
|
||||
|
||||
services.AddDbContextPool<UserDbContext>(options =>
|
||||
options.GetSqlSettings(Configuration))
|
||||
.AddDbContextPool<CountriesDbContext>(options =>
|
||||
options.GetSqlSettings(Configuration))
|
||||
.AddDbContextPool<FinanceDbContext>(options =>
|
||||
options.GetSqlSettings(Configuration))
|
||||
.AddDbContextPool<CountriesDbContext>(options =>
|
||||
options.GetSqlSettings(Configuration));
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace BlueWest.Data
|
|||
public int Code { get; set; } // Primary key
|
||||
public string StateName { get; set; }
|
||||
|
||||
public List<CurrencyCreate> CurrenciesToCreate { get; set; }
|
||||
public List<CurrencyUnique> CurrenciesToCreate { get; set; }
|
||||
|
||||
[MaxLength(2)] public string Alpha2Code { get; set; }
|
||||
|
||||
|
|
|
@ -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() { }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,9 @@ namespace BlueWest.Data
|
|||
{
|
||||
[MapFrom(new []{
|
||||
typeof(CurrencyUpdate),
|
||||
typeof(CurrencyCreate)})]
|
||||
typeof(CurrencyCreate),
|
||||
typeof(CurrencyUnique)
|
||||
})]
|
||||
|
||||
public partial class Currency
|
||||
{
|
||||
|
|
|
@ -9,8 +9,7 @@ namespace BlueWest.Data
|
|||
{
|
||||
public int Num { get; set; } // Primary key
|
||||
[MaxLength(3)] public string Code { get; set; }
|
||||
|
||||
public List<CountryCreate> CountriesToCreate { get; set; }
|
||||
public List<CountryUnique> CountriesToCreate { get; set; }
|
||||
public CurrencyCreate() { }
|
||||
|
||||
public Currency ToCurrency()
|
||||
|
|
|
@ -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() { }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -11,9 +11,6 @@ namespace BlueWest.Data
|
|||
// ISO 4217 Code
|
||||
[MaxLength(3)] public string Code { get; set; }
|
||||
|
||||
public CurrencyUpdate()
|
||||
{
|
||||
|
||||
}
|
||||
public CurrencyUpdate() { }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue