diff --git a/BlueWest.Api/BlueWest.Api.csproj b/BlueWest.Api/BlueWest.Api.csproj
index ac23ef4..f85aeec 100644
--- a/BlueWest.Api/BlueWest.Api.csproj
+++ b/BlueWest.Api/BlueWest.Api.csproj
@@ -15,7 +15,6 @@
-
diff --git a/BlueWest.Api/Context/CompanyDbContext.cs b/BlueWest.Api/Context/CompanyDbContext.cs
index 237b18e..3fe7e3c 100644
--- a/BlueWest.Api/Context/CompanyDbContext.cs
+++ b/BlueWest.Api/Context/CompanyDbContext.cs
@@ -6,12 +6,24 @@ using Microsoft.EntityFrameworkCore;
namespace BlueWest.WebApi.EF
{
- internal sealed class CompanyDbContext : DbContext
+ ///
+ /// Context for accessing company data
+ ///
+ public sealed class CompanyDbContext : DbContext
{
+ ///
+ /// Db set of Companies
+ ///
public DbSet Companies { get; set; }
+ ///
+ /// Db set of Industries.
+ ///
public DbSet Industries { get; set; }
+ ///
+ /// Db set of Products.
+ ///
public DbSet Products { get; set; }
@@ -25,6 +37,10 @@ namespace BlueWest.WebApi.EF
Database.EnsureCreated();
}
+ ///
+ /// On database model creating
+ ///
+ /// Builder model of the database
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
diff --git a/BlueWest.Api/Context/CountryDbContext.cs b/BlueWest.Api/Context/CountryDbContext.cs
index f18b427..e3960c5 100644
--- a/BlueWest.Api/Context/CountryDbContext.cs
+++ b/BlueWest.Api/Context/CountryDbContext.cs
@@ -9,13 +9,22 @@ namespace BlueWest.WebApi.EF
///
/// Countries and Currencies
///
- internal sealed class CountryDbContext : DbContext
+ public sealed class CountryDbContext : DbContext
{
+ ///
+ /// Countries Database Table
+ ///
public DbSet Countries { get; set; }
+ ///
+ /// Currencies Database Table
+ ///
public DbSet Currencies { get; set; }
+ ///
+ /// App Configuration
+ ///
public IConfiguration Configuration;
diff --git a/BlueWest.Api/Context/ExchangeInterface.cs b/BlueWest.Api/Context/ExchangeInterface.cs
index 6894ddc..45db8ee 100644
--- a/BlueWest.Api/Context/ExchangeInterface.cs
+++ b/BlueWest.Api/Context/ExchangeInterface.cs
@@ -5,12 +5,16 @@ using BlueWest.WebApi.EF;
namespace BlueWest.WebApi.Interfaces
{
+ ///
+ /// Empty constructor
+ ///
+
public struct ExchangeEvent { }
///
/// Interface for getting and storing exchange rates data
///
///
- internal sealed class ExchangeInterface : EventListener, IDisposable, IAsyncDisposable
+ public sealed class ExchangeInterface : EventListener, IDisposable, IAsyncDisposable
{
private readonly EventManager _eventManager;
private readonly CountryDbContext _countryDbContext;
@@ -18,6 +22,16 @@ namespace BlueWest.WebApi.Interfaces
private readonly UserDbContext _userDbContext;
#region Initialization
+
+ ///
+ /// Exchange Interface Object
+ ///
+ /// Country context
+ /// Finance context
+ /// User context
+ /// Event manager injection
+
+
public ExchangeInterface(
CountryDbContext countryDbContext,
FinanceDbContext financeDbContext,
@@ -31,6 +45,9 @@ namespace BlueWest.WebApi.Interfaces
Init();
}
+ ///
+ /// Empty constructor
+ ///
public ExchangeInterface() { }
private void Init()
@@ -51,13 +68,17 @@ namespace BlueWest.WebApi.Interfaces
}
///
- /// Stop Listening for events
+ /// Stop Listening for events on dispose
///
public void Dispose()
{
_eventManager.EventStopListening(this);
}
+ ///
+ /// Stop Listening for events on dispose async
+ ///
+ ///
public ValueTask DisposeAsync()
{
_eventManager.EventStopListening(this);
diff --git a/BlueWest.Api/Context/Extensions/CountryDbExtensions.cs b/BlueWest.Api/Context/Extensions/CountryDbExtensions.cs
index a5699a7..2800453 100644
--- a/BlueWest.Api/Context/Extensions/CountryDbExtensions.cs
+++ b/BlueWest.Api/Context/Extensions/CountryDbExtensions.cs
@@ -7,14 +7,44 @@ using Microsoft.EntityFrameworkCore;
namespace BlueWest.WebApi.EF
{
- internal static class CountryDbExtensions
+ ///
+ /// Country table database extensions
+ ///
+ public static class CountryDbExtensions
{
-
- internal static (bool, Country) NotFound() => (false, null);
- internal static (bool, string, Country) ErrorMessage(string message) => (false, message, null);
- internal static (bool, string, Country) Success(bool success, Country country) => (success, "1", null);
+ static CountryDbExtensions()
+ {
+ }
- internal static (bool, Country) UpdateCountry(
+ ///
+ /// Returns Not found projection
+ ///
+ ///
+ public static (bool, Country) NotFound() => (false, null);
+
+ ///
+ /// Returns Error Message projection
+ ///
+ ///
+ /// (false, message, null)
+ public static (bool, string, Country) ErrorMessage(string message) => (false, message, null);
+
+ ///
+ /// Returns Success intent projection
+ ///
+ /// Success message
+ /// Entity object
+ /// (bool success, Country country)
+ public static (bool, string, Country) Success(bool success, Country country) => (success, "1", null);
+
+ ///
+ /// Updates a country data.
+ ///
+ /// DbContext.
+ /// Country data to update.
+ /// Country Id.
+ ///
+ public static (bool, Country) UpdateCountry(
this CountryDbContext dbContext,
CountryUpdate countryUpdate,
int countryId)
@@ -28,13 +58,16 @@ namespace BlueWest.WebApi.EF
}
- internal static async Task GetCountryByIdAsync(this DbSet countries, int countryId) =>
- await countries.FirstOrDefaultAsync(x => x.Id == countryId);
-
-
- internal static (bool, string, Country) AddCurrency( this CountryDbContext dbContext, int countryId, CurrencyCreate currencyCreate)
+ ///
+ /// Adds a new Currency to the specified country
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static (bool, string, Country) AddCurrency( this CountryDbContext dbContext, int countryId, CurrencyCreate currencyCreate)
{
- var country = dbContext.Countries.FirstOrDefault(d => d.Code == countryId);
+ var country = dbContext.Countries.FirstOrDefault(d => d.Id == countryId);
// Check if currency exists
if (country == null) return (false, "Country Not found.", null);
@@ -46,12 +79,20 @@ namespace BlueWest.WebApi.EF
return Success(success, country);
}
- internal static (bool, string, Country) AddCurrency(
+ ///
+ /// Add Currency with optional duplication checks
+ ///
+ ///
+ /// Country Id
+ /// Data to create currency
+ /// List of expressions
+ ///
+ public static (bool, string, Country) AddCurrency(
this CountryDbContext dbContext,
int countryId, CurrencyCreate currencyCreate,
Expression>[] duplicationValidations)
{
- var country = dbContext.Countries.FirstOrDefault(d => d.Code == countryId);
+ var country = dbContext.Countries.FirstOrDefault(d => d.Id == countryId);
// Check if currency exists
if (country == null) return (false, $"{nameof(country)} Not found.", null);
diff --git a/BlueWest.Api/Context/Extensions/CurrencyExtensions.cs b/BlueWest.Api/Context/Extensions/CurrencyExtensions.cs
index 26213f7..f47b425 100644
--- a/BlueWest.Api/Context/Extensions/CurrencyExtensions.cs
+++ b/BlueWest.Api/Context/Extensions/CurrencyExtensions.cs
@@ -5,12 +5,25 @@ using Microsoft.EntityFrameworkCore;
namespace BlueWest.WebApi.EF
{
- internal static class CurrencyExtensions
+ ///
+ /// Currency table data extensions
+ ///
+ public static class CurrencyExtensions
{
- internal static (bool, Currency) NotFound() => (false, null);
+ ///
+ /// Not found projection
+ ///
+ ///
+ public static (bool, Currency) NotFound() => (false, null);
- internal static (bool, Currency) AddCurrency(this CountryDbContext dbContext, CurrencyCreate currencyToCreate)
+ ///
+ /// Add new Currency
+ ///
+ ///
+ ///
+ ///
+ public static (bool, Currency) AddCurrency(this CountryDbContext dbContext, CurrencyCreate currencyToCreate)
{
var newCurrency = new Currency(currencyToCreate);
dbContext.Add(newCurrency);
@@ -19,7 +32,14 @@ namespace BlueWest.WebApi.EF
}
- internal static (bool, Currency) UpdateCurrency(this CountryDbContext dbContext, int currencyId, CurrencyUpdate currencyToUpdate)
+ ///
+ /// Updates currency
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static (bool, Currency) UpdateCurrency(this CountryDbContext dbContext, int currencyId, CurrencyUpdate currencyToUpdate)
{
var currency = dbContext.Currencies.FirstOrDefault(x => x.Id == currencyId);
if (currency == null) return NotFound();
diff --git a/BlueWest.Api/Context/Extensions/DatabaseFundamentalsAttribute.cs b/BlueWest.Api/Context/Extensions/DatabaseFundamentalsAttribute.cs
deleted file mode 100644
index 2ded8f2..0000000
--- a/BlueWest.Api/Context/Extensions/DatabaseFundamentalsAttribute.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-
-namespace BlueWest.WebApi.EF
-{
- [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
- public class DatabaseFundamentalsAttribute : Attribute
- {
- public Type DatabaseContextType;
- public Type EntityType;
-
- public DatabaseFundamentalsAttribute(Type databaseContextType, Type entityType) { }
- }
-}
-
diff --git a/BlueWest.Api/Context/FinanceDbContext.cs b/BlueWest.Api/Context/FinanceDbContext.cs
index 6a7b4f0..37f1a66 100644
--- a/BlueWest.Api/Context/FinanceDbContext.cs
+++ b/BlueWest.Api/Context/FinanceDbContext.cs
@@ -7,23 +7,31 @@ namespace BlueWest.WebApi.EF
///
/// Finance operations table
///
- internal sealed class FinanceDbContext : DbContext
+ public sealed class FinanceDbContext : DbContext
{
- [DatabaseFundamentals(typeof(FinanceDbContext), typeof(FinanceOp))]
- internal DbSet Transactions { get; set; }
+ ///
+ /// Table storing transactions
+ ///
+ public DbSet Transactions { get; set; }
- [DatabaseFundamentals(typeof(FinanceDbContext), typeof(FinanceOpType))]
- internal DbSet TransactionTypes { get; set; }
+ ///
+ /// Table storing transaction types.
+ ///
+ public DbSet TransactionTypes { get; set; }
///
/// Finance transactions context
///
///
- internal FinanceDbContext(DbContextOptions options) : base(options)
+ public FinanceDbContext(DbContextOptions options) : base(options)
{
Database.EnsureCreated();
}
-
+
+ ///
+ /// On database model creating
+ ///
+ /// Builder model of the database
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
diff --git a/BlueWest.Api/Context/UserDbContext.cs b/BlueWest.Api/Context/UserDbContext.cs
index 3eaa396..48cf906 100644
--- a/BlueWest.Api/Context/UserDbContext.cs
+++ b/BlueWest.Api/Context/UserDbContext.cs
@@ -6,28 +6,34 @@ using Microsoft.Extensions.Configuration;
namespace BlueWest.WebApi.EF
{
- internal sealed class UserDbContext : DbContext
+ ///
+ /// Database context for app users
+ ///
+ public sealed class UserDbContext : DbContext
{
- internal DbSet Users { get; set; }
- internal IConfiguration Configuration;
+ ///
+ /// Users entity.
+ ///
+ public DbSet Users { get; set; }
+
+ ///
+ /// App configuration.
+ ///
+ public IConfiguration Configuration;
///
/// Database for the context of database users
///
///
- internal UserDbContext(DbContextOptions options) : base(options)
+ public UserDbContext(DbContextOptions options) : base(options)
{
Database.EnsureCreated();
}
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- {
- /*optionsBuilder.UseMySql(
- Configuration.GetConnectionString("LocalMySQL"),
- new MySqlServerVersion(new Version(8, 0, 11))
- );*/
- }
-
+ ///
+ /// On database model creating
+ ///
+ /// Builder model of the database
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
diff --git a/BlueWest.Api/Controllers/CountryController.cs b/BlueWest.Api/Controllers/CountryController.cs
index 4258ba8..bdeec19 100644
--- a/BlueWest.Api/Controllers/CountryController.cs
+++ b/BlueWest.Api/Controllers/CountryController.cs
@@ -10,16 +10,16 @@ using Microsoft.AspNetCore.Mvc;
namespace BlueWest.WebApi.Controllers
{
///
- /// Controller responsible to get country data
+ /// Controller responsible to get countryId data
///
[ApiController]
[Route("[controller]")]
- internal class CountryController : ControllerBase
+ public class CountryController : ControllerBase
{
private readonly CountryDbContext _dbContext;
///
- /// Controller responsible for handling country data in the Country table
+ /// Controller responsible for handling countryId data in the Country table
///
///
public CountryController(CountryDbContext dbContext)
@@ -31,8 +31,8 @@ namespace BlueWest.WebApi.Controllers
///
/// Add Country
///
- /// The country data to create
- /// The newly created country
+ /// The countryId data to create
+ /// The newly created countryId
/// ///
/// Creates a Country.
///
@@ -47,7 +47,7 @@ namespace BlueWest.WebApi.Controllers
/// }
///
///
- /// Returns the newly created country
+ /// Returns the newly created countryId
[ProducesResponseType(StatusCodes.Status201Created)]
[ProducesResponseType(StatusCodes.Status406NotAcceptable)]
@@ -65,7 +65,7 @@ namespace BlueWest.WebApi.Controllers
///
/// Updates a Country
///
- /// The country ISO 3166 code
+ /// The countryId ISO 3166 code
/// Country payload data
///
[ProducesResponseType(StatusCodes.Status200OK)]
@@ -73,11 +73,11 @@ namespace BlueWest.WebApi.Controllers
[HttpPut("{countryCode}")]
public ActionResult UpdateCountry(int countryCode, CountryUpdate countryToUpdate)
{
- var (success, country) = _dbContext.UpdateCountry(countryToUpdate, countryCode);
+ var (success, countryId) = _dbContext.UpdateCountry(countryToUpdate, countryCode);
if (success)
{
- return Ok(country);
+ return Ok(countryId);
}
return new NotFoundResult();
@@ -106,7 +106,7 @@ namespace BlueWest.WebApi.Controllers
///
/// Get Country by Id
///
- /// ISO 3166-1 country numeric code
+ /// ISO 3166-1 countryId numeric code
///
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
@@ -124,7 +124,7 @@ namespace BlueWest.WebApi.Controllers
}
///
- /// Get currencies of a country
+ /// Get currencies of a countryId
///
///
///
@@ -133,9 +133,9 @@ namespace BlueWest.WebApi.Controllers
[HttpGet("{countryId}/currencies")]
public ActionResult GetCountryCurrencies(int countryId)
{
- var country = _dbContext.Countries.FirstOrDefault(d => d.Id == countryId);
+ var countryObj = _dbContext.Countries.FirstOrDefault(d => d.Id == countryId);
- if (country == null) return new NotFoundResult();
+ if (countryObj == null) return new NotFoundResult();
var array = _dbContext
.Countries
diff --git a/BlueWest.Api/Controllers/CurrencyController.cs b/BlueWest.Api/Controllers/CurrencyController.cs
index e713ac0..f6f6f04 100644
--- a/BlueWest.Api/Controllers/CurrencyController.cs
+++ b/BlueWest.Api/Controllers/CurrencyController.cs
@@ -13,10 +13,14 @@ namespace BlueWest.WebApi.Controllers
///
[ApiController]
[Route("[controller]")]
- internal class CurrencyController : ControllerBase
+ public class CurrencyController : ControllerBase
{
private readonly CountryDbContext _dbContext;
+ ///
+ /// Api Controller for Currency data
+ ///
+ ///
public CurrencyController(CountryDbContext dbContext)
{
_dbContext = dbContext;
@@ -39,7 +43,6 @@ namespace BlueWest.WebApi.Controllers
/// Add Currency to the table of currencies
///
/// Currency data to create
- /// Countries
///
[ProducesResponseType(StatusCodes.Status201Created)]
[HttpPost]
diff --git a/BlueWest.Api/Controllers/FinanceController.cs b/BlueWest.Api/Controllers/FinanceController.cs
index b54223b..ba1cab4 100644
--- a/BlueWest.Api/Controllers/FinanceController.cs
+++ b/BlueWest.Api/Controllers/FinanceController.cs
@@ -11,10 +11,14 @@ namespace BlueWest.WebApi.Controllers;
///
[ApiController]
[Route("[controller]")]
-internal class FinanceController : ControllerBase
+public class FinanceController : ControllerBase
{
private readonly FinanceDbContext _dbContext;
+ ///
+ /// Finance Controller Api Controller
+ ///
+ /// The finance database context
public FinanceController(FinanceDbContext dbContext)
{
_dbContext = dbContext;
diff --git a/BlueWest.Api/Controllers/SwaggerEnumSchemaFilter.cs b/BlueWest.Api/Controllers/SwaggerEnumSchemaFilter.cs
index 4948230..167313a 100644
--- a/BlueWest.Api/Controllers/SwaggerEnumSchemaFilter.cs
+++ b/BlueWest.Api/Controllers/SwaggerEnumSchemaFilter.cs
@@ -6,8 +6,14 @@ using Swashbuckle.AspNetCore.SwaggerGen;
namespace BlueWest.WebApi.Tools
{
- internal class SwaggerEnumSchemaFilter : ISchemaFilter
+ ///
+ public class SwaggerEnumSchemaFilter : ISchemaFilter
{
+ ///
+ /// Apply Swagger OpenApi schema
+ ///
+ /// OpenApiSchema model
+ /// Schema filter context
public void Apply(OpenApiSchema model, SchemaFilterContext context)
{
if (context.Type.IsEnum)
diff --git a/BlueWest.Api/Controllers/UserController.cs b/BlueWest.Api/Controllers/UserController.cs
index 9ac1923..f0828f5 100644
--- a/BlueWest.Api/Controllers/UserController.cs
+++ b/BlueWest.Api/Controllers/UserController.cs
@@ -9,9 +9,12 @@ using Microsoft.AspNetCore.Mvc;
namespace BlueWest.WebApi.Controllers
{
+ ///
+ /// Api Controller for handling users data
+ ///
[ApiController]
[Route("[controller]")]
- internal class UserController : ControllerBase
+ public class UserController : ControllerBase
{
private readonly UserDbContext _dbContext;
diff --git a/BlueWest.Api/Extensions/ModelBuilderExtensions.cs b/BlueWest.Api/Extensions/ModelBuilderExtensions.cs
index 784e116..09aa7ac 100644
--- a/BlueWest.Api/Extensions/ModelBuilderExtensions.cs
+++ b/BlueWest.Api/Extensions/ModelBuilderExtensions.cs
@@ -9,7 +9,11 @@ namespace BlueWest.WebApi.EF.Model
public static class ModelBuilderExtensions
{
#region Initialization
-
+
+ static ModelBuilderExtensions()
+ {
+ }
+
///
/// Setup the database model
///
@@ -105,21 +109,7 @@ namespace BlueWest.WebApi.EF.Model
private static ModelBuilder ConfigureUserModel(this ModelBuilder modelBuilder)
{
- // User => Country
- modelBuilder
- .Entity(builder => builder
- .HasOne()
- .WithMany(co => co.Users));
-
-
- // Country => User
- modelBuilder
- .Entity(builder => builder
- .HasMany()
- .WithOne(u => u.Country)
- .HasForeignKey(x => x.CountryId));
-
-
+
// FinanceOp => User
modelBuilder
.Entity(builder => builder
diff --git a/BlueWest.Api/Extensions/SwaggerExtensions.cs b/BlueWest.Api/Extensions/SwaggerExtensions.cs
deleted file mode 100644
index ddc4922..0000000
--- a/BlueWest.Api/Extensions/SwaggerExtensions.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System;
-using System.IO;
-using System.Reflection;
-using BlueWest.WebApi.Tools;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.OpenApi.Models;
-using Swashbuckle.AspNetCore.SwaggerGen;
-
-namespace BlueWest.WebApi.Extensions
-{
- public static class SwaggerExtensions
- {
- ///
- /// Swagger documentation provider options
- ///
- ///
- public static void ConfigureSwaggerOptions(this SwaggerGenOptions swaggerGenOptions)
- {
- swaggerGenOptions.SchemaFilter();
- swaggerGenOptions.SwaggerDoc("v1", new OpenApiInfo
- {
- Title = "BlueWest.Api.App",
- Version = "v1",
- Description = "BlueWest.Api.App",
- TermsOfService = new Uri("https://git.codeliturgy.com/terms-of-service"),
- Contact = new OpenApiContact
- {
- Name = "Benny",
- Email = string.Empty,
- Url = new Uri("https://git.codeliturgy.com"),
- },
- License = new OpenApiLicense
- {
- Name = "Use under LICX",
- Url = new Uri("https://git.codeliturgy.com/license"),
- }
- });
-
- // Set the comments path for the Swagger JSON and UI.
- var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
- var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
- swaggerGenOptions.IncludeXmlComments(xmlPath);
- }
- }
-}
-
diff --git a/BlueWest.Api/Identity/AuthManager.cs b/BlueWest.Api/Identity/AuthManager.cs
index 37712c8..94a4f5b 100644
--- a/BlueWest.Api/Identity/AuthManager.cs
+++ b/BlueWest.Api/Identity/AuthManager.cs
@@ -1,5 +1,8 @@
namespace BlueWest.Data;
+///
+/// Auth Manager
+///
public class AuthManager
{
diff --git a/BlueWest.Api/Identity/EntityDbContext.cs b/BlueWest.Api/Identity/EntityDbContext.cs
deleted file mode 100644
index e16a17b..0000000
--- a/BlueWest.Api/Identity/EntityDbContext.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using BlueWest.WebApi.EF;
-using Microsoft.AspNetCore.Identity;
-
-namespace BlueWest.WebApi;
-
-public class EntityDbContext : IdentityUser
-{
-
-}
\ No newline at end of file
diff --git a/BlueWest.Api/Identity/IdentityContext.cs b/BlueWest.Api/Identity/IdentityContext.cs
deleted file mode 100644
index d405f8a..0000000
--- a/BlueWest.Api/Identity/IdentityContext.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System.Security.Principal;
-
-namespace BlueWest.Data;
-
-public class IdentityContext : IIdentity
-{
- public string AuthenticationType { get; }
- public bool IsAuthenticated { get; }
- public string Name { get; }
-}
\ No newline at end of file
diff --git a/BlueWest.Api/Program.cs b/BlueWest.Api/Program.cs
index 3b329b3..94daa71 100644
--- a/BlueWest.Api/Program.cs
+++ b/BlueWest.Api/Program.cs
@@ -43,6 +43,10 @@ namespace BlueWest.WebApi
///
public static IHost MainHost { get; private set; }
+ ///
+ /// Entry point of the application
+ ///
+ /// Command line arguments.
public static void Main(string[] args)
{
MainHost = CreateHostBuilder(args)
diff --git a/BlueWest.Api/Startup.cs b/BlueWest.Api/Startup.cs
index 54acbd4..bde2bf5 100644
--- a/BlueWest.Api/Startup.cs
+++ b/BlueWest.Api/Startup.cs
@@ -1,11 +1,15 @@
+using System;
+using System.IO;
+using System.Reflection;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System.Text.Json.Serialization;
using BlueWest.Tools;
-using BlueWest.WebApi.Extensions;
using BlueWest.WebApi.Interfaces;
+using BlueWest.WebApi.Tools;
+using Microsoft.OpenApi.Models;
namespace BlueWest.WebApi
{
@@ -50,7 +54,33 @@ namespace BlueWest.WebApi
.AddJsonOptions(options => options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.Preserve);
services
- .AddSwaggerGen(options => options.ConfigureSwaggerOptions());
+ .AddSwaggerGen(options =>
+ {
+ options.SchemaFilter();
+ options.SwaggerDoc("v1", new OpenApiInfo
+ {
+ Title = "BlueWest.Api.App",
+ Version = "v1",
+ Description = "BlueWest.Api.App",
+ TermsOfService = new Uri("https://git.codeliturgy.com/terms-of-service"),
+ Contact = new OpenApiContact
+ {
+ Name = "Benny",
+ Email = string.Empty,
+ Url = new Uri("https://git.codeliturgy.com"),
+ },
+ License = new OpenApiLicense
+ {
+ Name = "Use under LICX",
+ Url = new Uri("https://git.codeliturgy.com/license"),
+ }
+ });
+
+ // Set the comments path for the Swagger JSON and UI.
+ var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
+ var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
+ options.IncludeXmlComments(xmlPath);
+ });
services
.AddSingleton()
.PrepareDatabasePool(_configuration, _environment)
diff --git a/BlueWest.Data.Capital/Company/Company.cs b/BlueWest.Data.Capital/Company/Company.cs
index cdba176..a7506a0 100644
--- a/BlueWest.Data.Capital/Company/Company.cs
+++ b/BlueWest.Data.Capital/Company/Company.cs
@@ -22,11 +22,7 @@ namespace BlueWest.Data
public DateTime FoundingDate { get; set; }
public List Industry { get; set; }
-
- public Company()
- {
-
- }
+
}
}
diff --git a/BlueWest.Data.Capital/Company/CompanyCreate.cs b/BlueWest.Data.Capital/Company/CompanyCreate.cs
index b7c15ff..1ac00a3 100644
--- a/BlueWest.Data.Capital/Company/CompanyCreate.cs
+++ b/BlueWest.Data.Capital/Company/CompanyCreate.cs
@@ -16,10 +16,6 @@ namespace BlueWest.Data
public DateTime FoundingDate { get; set; }
- public CompanyCreate()
- {
-
- }
}
}
diff --git a/BlueWest.Data.Capital/Company/CompanyType.cs b/BlueWest.Data.Capital/Company/CompanyType.cs
index 9338975..89fbedf 100644
--- a/BlueWest.Data.Capital/Company/CompanyType.cs
+++ b/BlueWest.Data.Capital/Company/CompanyType.cs
@@ -8,10 +8,6 @@ namespace BlueWest.Data
public int Id { get; set; }
public string Name { get; set; }
- public CompanyType()
- {
-
- }
}
}
diff --git a/BlueWest.Data.Capital/Company/CompanyTypeCreate.cs b/BlueWest.Data.Capital/Company/CompanyTypeCreate.cs
index 4b7817c..ada0d49 100644
--- a/BlueWest.Data.Capital/Company/CompanyTypeCreate.cs
+++ b/BlueWest.Data.Capital/Company/CompanyTypeCreate.cs
@@ -6,11 +6,7 @@ namespace BlueWest.Data
public partial class CompanyTypeCreate
{
public string Name { get; set; }
-
- public CompanyTypeCreate()
- {
-
- }
+
}
}
diff --git a/BlueWest.Data.Capital/Company/Product.cs b/BlueWest.Data.Capital/Company/Product.cs
index 4cb024a..b044966 100644
--- a/BlueWest.Data.Capital/Company/Product.cs
+++ b/BlueWest.Data.Capital/Company/Product.cs
@@ -7,11 +7,6 @@ namespace BlueWest.Data
public string Name { get; set; }
public Industry Industry { get; set; }
public List Seller { get; set; }
-
- public Product()
- {
-
- }
}
}
diff --git a/BlueWest.Data.Capital/Country/Country.cs b/BlueWest.Data.Capital/Country/Country.cs
index 059f416..e0b7181 100644
--- a/BlueWest.Data.Capital/Country/Country.cs
+++ b/BlueWest.Data.Capital/Country/Country.cs
@@ -32,18 +32,7 @@ namespace BlueWest.Data
public List Currencies { get; set; }
public List Users { get; set; }
-
-
- [JsonConstructor]
- public Country(string stateName, string tld, List currencies)
- {
- StateName = stateName;
- TLD = tld;
- Currencies = currencies;
- }
-
- public Country() { }
-
+
}
}
diff --git a/BlueWest.Data.Capital/Country/CountryCreate.cs b/BlueWest.Data.Capital/Country/CountryCreate.cs
index 6848c5c..16823c2 100644
--- a/BlueWest.Data.Capital/Country/CountryCreate.cs
+++ b/BlueWest.Data.Capital/Country/CountryCreate.cs
@@ -13,13 +13,11 @@ namespace BlueWest.Data
public string Name { get; set; }
public string StateName { get; set; }
- public List CurrenciesToCreate { get; set; }
+ //public List CurrenciesToCreate { get; set; }
- [MaxLength(2)] public string Alpha2Code { get; set; }
+ public string Alpha2Code { get; set; }
public string TLD { get; set; }
-
- public CountryCreate() { }
}
diff --git a/BlueWest.Data.Capital/Country/CountryUnique.cs b/BlueWest.Data.Capital/Country/CountryUnique.cs
index d63d061..c15fd78 100644
--- a/BlueWest.Data.Capital/Country/CountryUnique.cs
+++ b/BlueWest.Data.Capital/Country/CountryUnique.cs
@@ -20,9 +20,7 @@ namespace BlueWest.Data
[MaxLength(2)] public string Alpha2Code { get; set; }
public string TLD { get; set; }
-
- public CountryUnique() { }
-
+
}
}
diff --git a/BlueWest.Data.Capital/Country/CountryUpdate.cs b/BlueWest.Data.Capital/Country/CountryUpdate.cs
index 1698bd9..a0c11d4 100644
--- a/BlueWest.Data.Capital/Country/CountryUpdate.cs
+++ b/BlueWest.Data.Capital/Country/CountryUpdate.cs
@@ -16,7 +16,6 @@ namespace BlueWest.Data
/// ISO 3166-1 numeric code
///
public int Code { get; set; }
- public CountryUpdate() { }
}
}
diff --git a/BlueWest.Data.Capital/Currency/Currency.cs b/BlueWest.Data.Capital/Currency/Currency.cs
index 3f2fe8a..66b2db2 100644
--- a/BlueWest.Data.Capital/Currency/Currency.cs
+++ b/BlueWest.Data.Capital/Currency/Currency.cs
@@ -16,8 +16,6 @@ namespace BlueWest.Data
public int Num { get; set; }
[MaxLength(3)] public string Code { get; set; }
public List Countries { get; set; }
-
- public Currency() { }
}
}
diff --git a/BlueWest.Data.Capital/Currency/CurrencyCreate.cs b/BlueWest.Data.Capital/Currency/CurrencyCreate.cs
index 79c4daf..df36cb4 100644
--- a/BlueWest.Data.Capital/Currency/CurrencyCreate.cs
+++ b/BlueWest.Data.Capital/Currency/CurrencyCreate.cs
@@ -7,11 +7,9 @@ namespace BlueWest.Data
[MapFrom(typeof(Currency))]
public partial class CurrencyCreate
{
- public int Num { get; set; } // Primary key
+ public int Num { get; set; }
[MaxLength(3)] public string Code { get; set; }
- public List CountriesToCreate { get; set; }
- public CurrencyCreate() { }
-
+ //public List CountriesToCreate { get; set; }
}
}
diff --git a/BlueWest.Data.Capital/Currency/CurrencyUnique.cs b/BlueWest.Data.Capital/Currency/CurrencyUnique.cs
index fd56688..29225fd 100644
--- a/BlueWest.Data.Capital/Currency/CurrencyUnique.cs
+++ b/BlueWest.Data.Capital/Currency/CurrencyUnique.cs
@@ -10,8 +10,6 @@ namespace BlueWest.Data
public int Num { get; set; } // Primary key
[MaxLength(3)] public string Code { get; set; }
- public CurrencyUnique() { }
-
}
}
diff --git a/BlueWest.Data.Capital/Currency/CurrencyUpdate.cs b/BlueWest.Data.Capital/Currency/CurrencyUpdate.cs
index 6cfaf2f..0e9634f 100644
--- a/BlueWest.Data.Capital/Currency/CurrencyUpdate.cs
+++ b/BlueWest.Data.Capital/Currency/CurrencyUpdate.cs
@@ -13,6 +13,5 @@ namespace BlueWest.Data
// ISO 4217 Code
[MaxLength(3)] public string Code { get; set; }
- public CurrencyUpdate() { }
}
}
diff --git a/BlueWest.Data.Capital/Transaction/FinanceOp.cs b/BlueWest.Data.Capital/Transaction/FinanceOp.cs
index e2542e3..984905f 100644
--- a/BlueWest.Data.Capital/Transaction/FinanceOp.cs
+++ b/BlueWest.Data.Capital/Transaction/FinanceOp.cs
@@ -20,7 +20,6 @@ namespace BlueWest.Data
private string Description {get;}
- public FinanceOp() { }
public FinanceOp(TimeSpan creationDate, int userId,
Currency currency, FinanceOpType financeOpType)
diff --git a/BlueWest.Data.Capital/Transaction/FinanceOpType.cs b/BlueWest.Data.Capital/Transaction/FinanceOpType.cs
index ce868ad..ab49a3f 100644
--- a/BlueWest.Data.Capital/Transaction/FinanceOpType.cs
+++ b/BlueWest.Data.Capital/Transaction/FinanceOpType.cs
@@ -9,11 +9,7 @@ namespace BlueWest.Data
public string Name;
private string Description;
-
- public FinanceOpType()
- {
- }
}
}
diff --git a/BlueWest.Data.Capital/User/User.cs b/BlueWest.Data.Capital/User/User.cs
index 5f5e358..9ab2d22 100644
--- a/BlueWest.Data.Capital/User/User.cs
+++ b/BlueWest.Data.Capital/User/User.cs
@@ -15,19 +15,12 @@ namespace BlueWest.Data
public List FinanceTransactions { get; set; }
- public Country Country { get; set; }
-
- [ForeignKey("Countries")]
- public int CountryId { get; set; }
+ [ForeignKey("CountryId")] public Country Country { get; set; }
public User(int id, string name)
{
Id = id;
Name = name;
}
-
- public User()
- {
- }
}
}
\ No newline at end of file
diff --git a/BlueWest.Data.Capital/User/UserCreate.cs b/BlueWest.Data.Capital/User/UserCreate.cs
index 4522aed..7a8c114 100644
--- a/BlueWest.Data.Capital/User/UserCreate.cs
+++ b/BlueWest.Data.Capital/User/UserCreate.cs
@@ -8,10 +8,5 @@ namespace BlueWest.Data
{
public string Name { get; set; }
- public UserCreate()
- {
-
- }
-
}
}
\ No newline at end of file