diff --git a/BlueWest.Api/BlueWest.Api.csproj b/BlueWest.Api/BlueWest.Api.csproj
deleted file mode 100644
index f5cc937..0000000
--- a/BlueWest.Api/BlueWest.Api.csproj
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
- net6.0
- 10
- BlueWest.WebApi
- true
- true
- bin\$(Configuration)\$(AssemblyName).xml
- true
- preview
-
-
-
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/BlueWest.Api/Controllers/ApplicationController.cs b/BlueWest.Api/Controllers/ApplicationController.cs
deleted file mode 100644
index e85b610..0000000
--- a/BlueWest.Api/Controllers/ApplicationController.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using Microsoft.AspNetCore.Authentication.Cookies;
-using Microsoft.AspNetCore.Authentication.JwtBearer;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Cors;
-using Microsoft.AspNetCore.Mvc;
-
-namespace BlueWest.WebApi.Controllers;
-
-[ApiController]
-[Route("application")]
-[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
-[Authorize(AuthenticationSchemes = CookieAuthenticationDefaults.AuthenticationScheme)]
-[EnableCors(Constants.CorsPolicyName)]
-[ServiceFilter(typeof(SessionAuthorizationFilter))]
-
-public class ApplicationController : ControllerBase
-{
- [HttpGet]
- [ResponseCache(Location = ResponseCacheLocation.None, NoStore = true)]
- public ContentResult GetTimeTicks() => Content(
- DateTime.Now.Ticks.ToString());
-}
\ No newline at end of file
diff --git a/BlueWest.Api/Controllers/ApplicationUserController.cs b/BlueWest.Api/Controllers/ApplicationUserController.cs
deleted file mode 100644
index aefd8db..0000000
--- a/BlueWest.Api/Controllers/ApplicationUserController.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-using BlueWest.Data.Application.Users;
-using BlueWest.Domain;
-
-using BlueWest.WebApi.Context.Users;
-using Microsoft.AspNetCore.Authentication.Cookies;
-using Microsoft.AspNetCore.Authentication.JwtBearer;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Cors;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-
-namespace BlueWest.WebApi.Controllers
-{
- ///
- [ApiController]
- [Route("application/users")]
- [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
- [Authorize(AuthenticationSchemes = CookieAuthenticationDefaults.AuthenticationScheme)]
- [EnableCors(Constants.CorsPolicyName)]
- [ServiceFilter(typeof(SessionAuthorizationFilter))]
-
- public class ApplicationUserController : ControllerBase
- {
- private readonly ApplicationUserDbContext _dbContext;
-
- ///
- public ApplicationUserController(ApplicationUserDbContext context)
- {
- _dbContext = context;
- }
-
- #region Users
-
- ///
- /// Get Application users
- ///
- ///
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- [HttpGet]
- public ActionResult GetApplicationUsers(
- int skip = 0,
- int take = 50,
- int orderDir = 1)
- {
-
- var (success, users) = _dbContext.GetUsers( skip, take, orderDir);
- if (!success) return new NotFoundResult();
- return Ok(users);
- }
-
-
- ///
- /// Updates a User
- ///
- /// The UserId ISO 3166 code
- /// User payload data
- ///
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status400BadRequest)]
- [HttpPut("{UserCode}")]
- public ActionResult UpdateApplicationUser(string applicationUserId, ApplicationUserUnique UserToUpdate)
- {
- var (success, updatedUser) = _dbContext.UpdateApplicationUser(UserToUpdate, applicationUserId);
-
- if (success)
- {
- return Ok(updatedUser);
- }
-
-
- return new NotFoundResult();
- }
-
-
- #endregion
-
-
- /*
- #region GetUserById
-
- ///
- /// Get User by Id
- ///
- /// ISO 3166-1 UserId numeric code
- ///
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- [HttpGet("{UserId}", Name = nameof(GetUserById))]
- public ActionResult GetUserById(int UserId)
- {
- var (success, User) = _dbContext.GetOneUserById(UserId);
-
- if (success)
- {
- return Ok(User);
- }
-
- return new NotFoundResult();
- }
-
- #endregion
- */
-
- #region Roles
-
- ///
- /// Get Application users
- ///
- ///
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- [HttpGet("roles")]
- public ActionResult GetApplicationRoles(
- int skip = 0,
- int take = 50,
- int orderDir = 1)
- {
-
- var (success, users) = _dbContext.GetRoles( skip, take, orderDir);
- if (!success) return new NotFoundResult();
- return Ok(users);
- }
-
- #endregion
-
-
- }
-}
-
-///
-/// Application Constants
-///
-public static class Constants
-{
- ///
- /// Policy Name
- ///
- public const string CorsPolicyName = "_myAllowSpecificOrigins";
-}
-
diff --git a/BlueWest.Api/Controllers/AuthController.cs b/BlueWest.Api/Controllers/AuthController.cs
deleted file mode 100644
index d429524..0000000
--- a/BlueWest.Api/Controllers/AuthController.cs
+++ /dev/null
@@ -1,109 +0,0 @@
-using System.Threading.Tasks;
-using BlueWest.Data.Auth;
-using BlueWest.Data.Auth.Context.Users;
-using Microsoft.AspNetCore.Authentication;
-using Microsoft.AspNetCore.Authentication.Cookies;
-using Microsoft.AspNetCore.Authentication.JwtBearer;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-
-namespace BlueWest.WebApi.Controllers;
-
-///
-/// Auth controller
-///
- [ApiController]
- [Route("api/[controller]")]
- [Authorize(Policy = SessionConstants.ApiNamePolicy)]
-
-/*[EnableCors(Constants.CorsPolicyName)]*/
- public class AuthController : Controller
- {
- private readonly IAuthManager _authManager;
- private readonly IUserManager _userManager;
-
- ///
- ///
- ///
- ///
- ///
- public AuthController( IAuthManager authManager, IUserManager userManager)
- {
- _authManager = authManager;
- _userManager = userManager;
- }
- ///
- /// Signup user
- ///
- ///
- ///
- [AllowAnonymous]
- [HttpPost("register")]
- public async Task> SignupUserAsync(RegisterRequest registerRequest)
- {
- return await _authManager.CreateUserAsync(registerRequest);
- }
-
-
-
- ///
- /// Gets a bearer token
- ///
- ///
- ///
- [AllowAnonymous]
- [HttpPost("login")]
- public async Task> GetSessionToken(LoginRequest loginViewModel)
- {
- var (success, sessionToken, _) = await _authManager.GetSessionTokenIdByLoginRequest(loginViewModel, JwtBearerDefaults.AuthenticationScheme);
-
- if (success)
- {
- return Ok(new {sessionToken});
-
- }
- return Problem();
- }
-
-
- ///
- /// Do Cookie based login.
- ///
- ///
- ///
- /*[AllowAnonymous]
- [HttpPost("login")]
- public async Task DoLoginByCookie(LoginRequest loginDto)
- {
- var (success, sessionToken, identity) = await _authManager.GetSessionTokenId(loginDto);
-
- if (success)
- {
- await HttpContext.SignInAsync(
- CookieAuthenticationDefaults.AuthenticationScheme,
- new ClaimsPrincipal(identity),
- new AuthenticationProperties
- {
- IsPersistent = true,
- ExpiresUtc = DateTime.UtcNow.Add(SessionConstants.DefaultValidForSpan)
- });
-
- return Ok(new {authenticated = true, sessionToken});
- }
-
- return new ForbidResult(CookieAuthenticationDefaults.AuthenticationScheme);
- }*/
-
- ///
- /// Do Cookie based logout
- ///
- ///
- [AllowAnonymous]
- [HttpPost("logout")]
- public async Task DoCookieLogoutAsync()
- {
- await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
- }
-
- }
\ No newline at end of file
diff --git a/BlueWest.Api/Controllers/CountryController.cs b/BlueWest.Api/Controllers/CountryController.cs
deleted file mode 100644
index 306592d..0000000
--- a/BlueWest.Api/Controllers/CountryController.cs
+++ /dev/null
@@ -1,205 +0,0 @@
-using BlueWest.Domain;
-using BlueWest.Data;
-using BlueWest.Data.Auth;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Cors;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-
-namespace BlueWest.WebApi.Controllers
-{
- ///
- /// Controller responsible to get countryId data
- ///
- [ApiController]
- [Route("[controller]")]
- [Authorize(Policy = SessionConstants.ApiNamePolicy)]
- [EnableCors(Constants.CorsPolicyName)]
- [ServiceFilter(typeof(SessionAuthorizationFilter))]
-
- // [Authorize(Roles = "Administrator")]
- public class CountryController : ControllerBase
- {
-
- #region Initialization
- private readonly CountryDbContext _dbContext;
-
- ///
- /// Controller responsible for handling countryId data in the Country table
- ///
- ///
- public CountryController(CountryDbContext dbContext)
- {
- _dbContext = dbContext;
- }
-
- #endregion
-
- public override AcceptedAtActionResult AcceptedAtAction(string actionName, string controllerName)
- {
- return base.AcceptedAtAction(actionName, controllerName);
- }
-
- #region GetCountries
-
- ///
- /// Get countries
- ///
- ///
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- [HttpGet]
- public ActionResult GetCountries(
- int skip = 0,
- int take = 50,
- int orderDir = 1)
- {
-
- var (success, countries) = _dbContext.GetCountries( skip, take, orderDir);
- if (!success) return new NotFoundResult();
- return Ok(countries);
-
- }
-
- #endregion
-
- #region GetCountryById
-
- ///
- /// Get Country by Id
- ///
- /// ISO 3166-1 countryId numeric code
- ///
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- [HttpGet("{countryId}", Name = nameof(GetCountryById))]
- public ActionResult GetCountryById(int countryId)
- {
- var (success, country) = _dbContext.GetOneCountryById(countryId);
-
- if (success)
- {
- return Ok(country);
- }
-
- return new NotFoundResult();
- }
-
- #endregion
-
- #region GetCountryCurrencies
-
- ///
- /// Get currencies of a countryId
- ///
- ///
- /// How many records to skip
- /// How many records to take
- /// The order direction
-
- ///
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- [HttpGet("{countryId}/currencies")]
- public ActionResult GetCountryCurrencies(int countryId, int skip = 0, int take = 50, int orderDir = 1)
- {
- var (success, result) = _dbContext.GetCountryCurrencies(countryId, skip, take, orderDir);
-
- if(success)
- {
- return Ok(result);
- }
-
- return new NotFoundResult();
- }
-
- #endregion
-
- #region AddCountry
-
- ///
- /// Add Country
- ///
- /// The countryId data to create
- /// The newly created countryId
- /// ///
- /// Creates a Country.
- ///
- ///
- /// Sample request:
- ///
- /// POST /Countries
- /// {
- /// "code": 1,
- /// "stateName": "United States of America",
- /// "tld": "us"
- /// }
- ///
- ///
- /// Returns the newly created countryId
- [ProducesResponseType(StatusCodes.Status201Created)]
- [ProducesResponseType(StatusCodes.Status406NotAcceptable)]
-
- [HttpPost]
- public ActionResult AddCountry(CountryCreate countryToCreate)
- {
- var (success, country) = _dbContext.AddCountry(countryToCreate);
- if (!success) return new BadRequestResult();
- return CreatedAtRoute(nameof(GetCountryById), new {countryId = country.Id}, country);
- }
-
-
- #endregion
-
- #region UpdateCountry
-
- ///
- /// Updates a Country
- ///
- /// The countryId ISO 3166 code
- /// Country payload data
- ///
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status400BadRequest)]
- [HttpPut("{countryCode}")]
- public ActionResult UpdateCountry(int countryCode, CountryUpdate countryToUpdate)
- {
- var (success, country) = _dbContext.UpdateCountry(countryToUpdate, countryCode);
-
- if (success)
- {
- return Ok(country);
- }
-
- return new NotFoundResult();
- }
-
- #endregion
-
- #region AddCurrencyToCountry
-
- ///
- /// Adds a currency to Country
- ///
- ///
- ///
- ///
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status409Conflict)]
- [HttpPost("{countryId}/currencies")]
- public ActionResult AddCurrencyToCountry(int countryId, CurrencyCreate currencyCreate)
- {
- var (success, message, newCurrency) = _dbContext.AddCurrencyToCountry(countryId, currencyCreate);
-
- if(success)
- {
- return Ok(newCurrency);
- }
-
- return new NotFoundObjectResult(message);
- }
-
- #endregion
-
- }
-}
\ No newline at end of file
diff --git a/BlueWest.Api/Controllers/CurrencyController.cs b/BlueWest.Api/Controllers/CurrencyController.cs
deleted file mode 100644
index efe708c..0000000
--- a/BlueWest.Api/Controllers/CurrencyController.cs
+++ /dev/null
@@ -1,207 +0,0 @@
-using BlueWest.Domain;
-using BlueWest.Data;
-using Microsoft.AspNetCore.Authentication.Cookies;
-using Microsoft.AspNetCore.Authentication.JwtBearer;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Cors;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-
-namespace BlueWest.WebApi.Controllers
-{
- ///
- /// The controller responsible to fetch currency data
- ///
- [ApiController]
- [Route("[controller]")]
- [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
- [Authorize(AuthenticationSchemes = CookieAuthenticationDefaults.AuthenticationScheme)]
- [EnableCors(Constants.CorsPolicyName)]
- [ServiceFilter(typeof(SessionAuthorizationFilter))]
-
- // [Authorize(Roles = "Administrator")]
- public partial class CurrencyController : ControllerBase
- {
-
- #region Initialization
- private readonly CountryDbContext _dbContext;
-
- ///
- /// Api Controller for Currency data
- ///
- ///
- public CurrencyController(CountryDbContext dbContext)
- {
- _dbContext = dbContext;
- }
-
- #endregion
-
- #region GetCurrencies
- ///
- /// Gets the currency data from currency table
- ///
- ///
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- [HttpGet]
- public ActionResult GetCurrencies(int skip = 0, int take = 50, int orderDir = 1)
- {
- var (success, result) = _dbContext.GetCurrencies(skip, take, orderDir);
-
- if (success)
- {
- return Ok(result);
- }
- return new NotFoundResult();
- }
-
- #endregion
-
- #region GetCurrencyById
- ///
- /// Gets a currency by the currency number (id)
- ///
- /// The id of the currency to get
- ///
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- [HttpGet("{currencyId}", Name = nameof(GetCurrencyById))]
- public ActionResult GetCurrencyById(int currencyId)
- {
- var (success, result) = _dbContext.GetOneCurrencyById(currencyId);
-
- if (success)
- {
- return Ok(result);
- }
-
- return new NotFoundResult();
- }
-
- #endregion
-
- #region GetCurrencyWithCode
-
- ///
- /// Gets a currency by code.
- ///
- /// The currency Code
- ///
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- [HttpGet("{currencyCode}", Name = nameof(GetCurrencyWithCode))]
- public ActionResult GetCurrencyWithCode(string currencyCode)
- {
- var (success, currency) =
- _dbContext.GetCurrencyWith(x => x.Code == currencyCode);
-
- if (success)
- {
- return Ok(currency);
- }
-
- return new NotFoundResult();
- }
-
- #endregion
-
- #region AddCurrency
- ///
- /// Add Currency to the table of currencies
- ///
- /// Currency data to create
- ///
- [ProducesResponseType(StatusCodes.Status201Created)]
- [HttpPost]
- public ActionResult AddCurrency(CurrencyCreate currencyToCreate)
- {
- var (success, newCurrency) = _dbContext.AddCurrency(currencyToCreate);
-
- if (!success)
- {
- return new NotFoundResult();
- }
-
- return CreatedAtRoute(nameof(GetCurrencyById), new { CurrencyId = newCurrency.Code }, newCurrency);
-
- }
-
- #endregion
-
- #region UpdateCurrency
- ///
- /// Update a currency data from the Currency table in the database
- ///
- /// The currency number we want to update
- /// Currency Data to update
- ///
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status400BadRequest)]
- [HttpPut("{currencyNumber}")]
- public ActionResult UpdateCurrency(int currencyNumber, CurrencyUpdate currencyToUpdate)
- {
- var (success, currency) = _dbContext.UpdateCurrency(currencyToUpdate, currencyNumber);
-
- if (success)
- {
- return Ok(currency);
- }
-
- return new NotFoundResult();
- }
-
- #endregion
-
- #region GetCountryFromCurrency
- ///
- /// Gets a specific country id in a country
- ///
- /// The id of the currency
- /// The id of the country
- ///
- /*
- * [GetOneFrom(nameof(Currency.Id), nameof(Country.Id), typeof(CountryUnique))]
- */
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- [HttpGet("{currencyId}/countries/{countryId}", Name = nameof(GetCountryFromCurrency))]
- public ActionResult GetCountryFromCurrency(int currencyId, int countryId)
- {
- var (success, country) = _dbContext.GetCountryFromCurrency(currencyId, countryId);
-
-
- if (success)
- {
- return Ok(country);
- }
-
- return new NotFoundResult();
-
- }
-
- #endregion
-
- #region AddCountry
- ///
- /// Add Currency to the table of currencies
- ///
- ///
- ///
- [ProducesResponseType(StatusCodes.Status201Created)]
- [HttpPost("{currencyId}/countries")]
- public ActionResult AddCountry(CountryCreate countryToCreate)
- {
- var (success, result) = _dbContext.AddCountry(countryToCreate);
-
- if (success)
- {
- return Ok(result);
- }
- return new BadRequestResult();
- }
-
- #endregion
-
- }
-}
\ No newline at end of file
diff --git a/BlueWest.Api/Controllers/FinanceController.cs b/BlueWest.Api/Controllers/FinanceController.cs
deleted file mode 100644
index 3a0ae21..0000000
--- a/BlueWest.Api/Controllers/FinanceController.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-using System;
-using BlueWest.Domain;
-using BlueWest.Data;
-using Microsoft.AspNetCore.Authentication.Cookies;
-using Microsoft.AspNetCore.Authentication.JwtBearer;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Cors;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-
-namespace BlueWest.WebApi.Controllers;
-
-///
-/// The controller responsible to fetch currency data
-///
-[ApiController]
-[Route("[controller]")]
-[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
-[Authorize(AuthenticationSchemes = CookieAuthenticationDefaults.AuthenticationScheme)]
-//[Authorize(Roles = "Administrator")]
-[EnableCors(Constants.CorsPolicyName)]
-[ServiceFilter(typeof(SessionAuthorizationFilter))]
-
-public class FinanceController : ControllerBase
-{
- private readonly FinanceDbContext _dbContext;
-
- ///
- /// Finance Controller Api Controller
- ///
- /// The finance database context
- public FinanceController(FinanceDbContext dbContext)
- {
- _dbContext = dbContext;
- }
-
-
- ///
- /// Returns a transaction by the provided id
- ///
- ///
- ///
- ///
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status400BadRequest)]
- [HttpGet("{userId}/transactions/{transactionId}")]
- public ActionResult GetTransactionsById(int userId, TimeSpan transactionId)
- {
- return new NotFoundResult();
- }
-
- ///
- /// Posts a finance transaction
- ///
- ///
- ///
- ///
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status400BadRequest)]
- [HttpPost("{userId}/transactions")]
- public ActionResult PostTransaction(int userId, FinanceOpCreate financeTransaction)
- {
- return new BadRequestResult();
- }
-
-
- ///
- /// Get Transactions
- ///
- ///
- ///
-
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status400BadRequest)]
- [HttpGet("{userId}/transactions")]
- public ActionResult GetTransactions(int userId)
- {
- return Ok();
- }
-
-
-}
\ No newline at end of file
diff --git a/BlueWest.Api/Controllers/UserController.cs b/BlueWest.Api/Controllers/UserController.cs
deleted file mode 100644
index 31a9708..0000000
--- a/BlueWest.Api/Controllers/UserController.cs
+++ /dev/null
@@ -1,126 +0,0 @@
-using System.Linq;
-using BlueWest.Domain;
-using BlueWest.Domain;
-using BlueWest.Data;
-using Microsoft.AspNetCore.Authentication.Cookies;
-using Microsoft.AspNetCore.Authentication.JwtBearer;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Cors;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-
-namespace BlueWest.WebApi.Controllers
-{
- ///
- /// Api Controller for handling users data
- ///
- [ApiController]
- [Route("[controller]")]
- [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
- [Authorize(AuthenticationSchemes = CookieAuthenticationDefaults.AuthenticationScheme)]
- //[Authorize(Roles = "Administrator")]
- [EnableCors(Constants.CorsPolicyName)]
-
- public class UserController : ControllerBase
- {
-
- private readonly UserDbContext _dbContext;
-
- ///
- /// Controller responsible to handle user data
- ///
- ///
- public UserController(UserDbContext dbContext)
- {
- _dbContext = dbContext;
- }
-
-
- ///
- /// Gets all the users in the user table12312
- ///
- ///
- [ProducesResponseType(StatusCodes.Status200OK)]
- [HttpGet]
- public ActionResult Get()
- {
- var users = _dbContext.Users.ToArray();
- return Ok(users);
-
- }
-
- ///
- /// Get User by Id
- ///
- ///
- ///
-
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- [HttpGet("{userId}", Name = nameof(GetUserById))]
- public ActionResult GetUserById(int userId)
- {
- var user = _dbContext.Users.FirstOrDefault(x => x.Id == userId);
-
- if (user != null)
- {
- return Ok(user);
- }
-
- return new NotFoundResult();
- }
-
-
- ///
- /// Adds a user to the database
- ///
- /// User to add
- ///
- [ProducesResponseType(StatusCodes.Status201Created)]
- [HttpPost]
- public ActionResult AddUser(UserCreate userCreate)
- {
- var user = new User(userCreate);
- _dbContext.Users.Add(user);
- _dbContext.SaveChanges();
- return CreatedAtRoute(nameof(GetUserById), new {userId = user.Id}, user);
- }
-
- ///
- /// Updates user data
- ///
- /// User id
- ///
- ///
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status400BadRequest)]
- [HttpPut($"{{userId:int}}")]
- public ActionResult UpdateUser(int userId, UserCreate userCreate)
- {
-
- return new NotFoundResult();
- }
-
- ///
- /// Deletes a user from the database
- ///
- ///
- ///
- [ProducesResponseType(StatusCodes.Status204NoContent)]
- [ProducesResponseType(StatusCodes.Status400BadRequest)]
- [HttpDelete("{id:int}")]
- public ActionResult DeleteUser(int id)
- {
- var user = _dbContext.Users.FirstOrDefault(u => u.Id == id);
- if (user == null)
- {
- return new NotFoundResult();
- }
- _dbContext.Users.Remove(user);
- _dbContext.SaveChanges();
- return Ok();
- }
-
-
- }
-}
\ No newline at end of file
diff --git a/BlueWest.Api/Dockerfile b/BlueWest.Api/Dockerfile
deleted file mode 100644
index 3789d9a..0000000
--- a/BlueWest.Api/Dockerfile
+++ /dev/null
@@ -1,50 +0,0 @@
-FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
-WORKDIR /app
-#EXPOSE 80
-#EXPOSE 443
-
-
-FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
-WORKDIR /src
-
-COPY ["BlueWest.Data.Capital/BlueWest.Data.Capital.csproj", "BlueWest.Data.Capital/"]
-RUN dotnet restore "BlueWest.Data.Capital/BlueWest.Data.Capital.csproj"
-
-
-COPY ["BlueWest/BlueWest.csproj", "BlueWest/"]
-RUN dotnet restore "BlueWest/BlueWest.csproj"
-
-
-COPY ["BlueWest.Data.Application/BlueWest.Data.Application.csproj", "BlueWest.Data.Application/"]
-RUN dotnet restore "BlueWest.Data.Application/BlueWest.Data.Application.csproj"
-
-
-COPY ["BlueWest.Api/BlueWest.Api.csproj", "BlueWest.Api/"]
-RUN dotnet restore "BlueWest.Api/BlueWest.Api.csproj"
-
-
-COPY ["include/BlueWest.MapTo/src/BlueWest.MapTo/BlueWest.MapTo.csproj", "include/BlueWest.MapTo/src/BlueWest.MapTo/"]
-RUN dotnet restore "include/BlueWest.MapTo/src/BlueWest.MapTo/BlueWest.MapTo.csproj"
-
-
-COPY ["include/BlueWest.EfMethods/src/BlueWest.EfMethods/BlueWest.EfMethods.csproj", "include/BlueWest.EfMethods/src/BlueWest.EfMethods/"]
-RUN dotnet restore "include/BlueWest.EfMethods/src/BlueWest.EfMethods/BlueWest.EfMethods.csproj"
-
-
-COPY ["include/Math-Expression-Evaluator/SimpleExpressionEvaluator/SimpleExpressionEvaluator.csproj", "include/Math-Expression-Evaluator/SimpleExpressionEvaluator/"]
-RUN dotnet restore "include/Math-Expression-Evaluator/SimpleExpressionEvaluator/SimpleExpressionEvaluator.csproj"
-
-
-COPY [".", "."]
-
-RUN dotnet build "BlueWest.Api/BlueWest.Api.csproj" -c Release -o /app/build
-
-FROM build AS publish
-RUN dotnet publish "BlueWest.Api/BlueWest.Api.csproj" -c Release -o /app/publish --self-contained false
-
-FROM base AS final
-WORKDIR /app
-COPY --from=publish /app/publish .
-ENV ASPNETCORE_URLS http://0.0.0.0:80
-WORKDIR /app
-ENTRYPOINT ["dotnet", "BlueWest.Api.dll" ]
diff --git a/BlueWest.Api/ExchangeInterface.cs b/BlueWest.Api/ExchangeInterface.cs
deleted file mode 100644
index 8eca1e6..0000000
--- a/BlueWest.Api/ExchangeInterface.cs
+++ /dev/null
@@ -1,94 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using BlueWest.Domain;
-using BlueWest.Domain;
-using BlueWest.Tools;
-using BlueWest.WebApi.Context;
-
-namespace BlueWest.WebApi.Interfaces
-{
- ///
- /// Empty constructor
- ///
-
- public struct ExchangeEvent { }
- ///
- /// Interface for getting and storing exchange rates data
- ///
- ///
- public sealed class ExchangeInterface : EventListener, IDisposable, IAsyncDisposable
- {
- private readonly ApplicationUserDbContext _applicationUserDbContext;
- private readonly EventManager _eventManager;
- private readonly CountryDbContext _countryDbContext;
- private readonly FinanceDbContext _financeDbContext;
- private readonly UserDbContext _userDbContext;
-
- #region Initialization
-
- ///
- /// Database Ef context constructor
- ///
- /// Country context
- /// Finance context
- /// User context
- /// Event manager injection
-
- public ExchangeInterface(
- ApplicationUserDbContext applicationUserDbContext,
- CountryDbContext countryDbContext,
- FinanceDbContext financeDbContext,
- UserDbContext userDbContext,
- EventManager eventManager)
- {
- _applicationUserDbContext = applicationUserDbContext;
- _countryDbContext = countryDbContext;
- _financeDbContext = financeDbContext;
- _userDbContext = userDbContext;
- _eventManager = eventManager;
- Init();
- }
-
- ///
- /// Database Ef context constructor
- ///
- public ExchangeInterface() { }
-
- private void Init()
- {
- _eventManager.EventStartListening(this);
- Console.WriteLine($"{nameof(ExchangeInterface)} Just started!");
- }
-
- #endregion
-
- ///
- /// On Exchange Event
- ///
- ///
- public void OnEvent(ExchangeEvent eventType)
- {
- Console.WriteLine($"Service received exchange {nameof(ExchangeEvent)}");
- }
-
- ///
- /// 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);
- return ValueTask.CompletedTask;
-
- }
- }
-}
-
diff --git a/BlueWest.Api/Program.cs b/BlueWest.Api/Program.cs
deleted file mode 100644
index fa26ba7..0000000
--- a/BlueWest.Api/Program.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.Hosting;
-using Microsoft.Extensions.Logging;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-using BlueWest.Core;
-using BlueWest.Tools;
-using BlueWest.WebApi.Interfaces;
-
-namespace BlueWest.WebApi
-{
- ///
- /// Entry point of the application.
- ///
- public class Program
- {
- ///
- /// Event Manager class
- ///
- public static EventManager EventManager { get; set; }
-
- private static ThreadServer _threadServer;
-
- /*private static CSharpCompilation GenerateCode(string sourceCode)
- {
- var codeString = SourceText.From(sourceCode);
- var parsedSyntaxTree = SyntaxFactory.ParseSyntaxTree(codeString, CSharpParseOptions.Default);
-
- return CSharpCompilation.Create("Hello.dll",
- new[] { parsedSyntaxTree },
- references: ReferenceAssemblies.Net50, // install jared's Basic.Reference.Assemblies for this, otherwise, you are going to manually add the DLLs you want
- options: new CSharpCompilationOptions(OutputKind.ConsoleApplication,
-
- optimizationLevel: OptimizationLevel.Release));
- }*/
-
- ///
- /// Host Interface of the application.
- ///
- public static IHost MainHost { get; private set; }
-
- ///
- /// Entry point of the application
- ///
- /// Command line arguments.
- public static void Main(string[] args)
- {
- MainHost = CreateHostBuilder(args)
- .UseContentRoot(Directory.GetCurrentDirectory())
- .Build();
-
- MainHost.Run();
-
- //var tryGetEventManager = MainHost.Services.GetService(typeof(EventManager));
- // _ = MainHost.Services.GetService(typeof(ExchangeInterface));
-
-
- /*if(tryGetEventManager == null) Console.WriteLine($"Failed to get {nameof(EventManager)} Service.");
-
- if (tryGetEventManager is EventManager eventManager)
- {
- // Use RunASync
- System.Threading.Thread.Sleep(2500);
- _threadServer = new ThreadServer(eventManager);
- _threadServer.Init();
- }*/
-
-
- }
-
- private static IHostBuilder CreateHostBuilder(string[] args) =>
- Host.CreateDefaultBuilder(args)
-
- .ConfigureWebHostDefaults(webBuilder =>
- {
- webBuilder.UseStartup();
- });
- }
-}
diff --git a/BlueWest.Api/Properties/launchSettings.json b/BlueWest.Api/Properties/launchSettings.json
deleted file mode 100644
index 3d937ec..0000000
--- a/BlueWest.Api/Properties/launchSettings.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "$schema": "http://json.schemastore.org/launchsettings.json",
- "iisSettings": {
- "windowsAuthentication": false,
- "anonymousAuthentication": true,
- "iisExpress": {
- "applicationUrl": "http://localhost:65056",
- "sslPort": 44398
- }
- },
- "profiles": {
- "IIS Express": {
- "commandName": "IISExpress",
- "launchBrowser": true,
- "launchUrl": "swagger",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- },
- "BlueWest.WebApi": {
- "commandName": "Project",
- "dotnetRunMessages": "true",
- "launchBrowser": true,
- "launchUrl": "swagger",
- "applicationUrl": "https://localhost:5001;http://localhost:5000",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Production"
- }
- }
- }
-}
diff --git a/BlueWest.Api/Protos/greet.proto b/BlueWest.Api/Protos/greet.proto
deleted file mode 100644
index 20b5c31..0000000
--- a/BlueWest.Api/Protos/greet.proto
+++ /dev/null
@@ -1,21 +0,0 @@
-syntax = "proto3";
-
-option csharp_namespace = "BlueWest.Streaming";
-
-package greet;
-
-// The greeting service definition.
-service Greeter {
- // Sends a greeting
- rpc SayHello (HelloRequest) returns (HelloReply);
-}
-
-// The request message containing the user's name.
-message HelloRequest {
- string name = 1;
-}
-
-// The response message containing the greetings.
-message HelloReply {
- string message = 1;
-}
diff --git a/BlueWest.Api/Services/GreeterService.cs b/BlueWest.Api/Services/GreeterService.cs
deleted file mode 100644
index 7d236eb..0000000
--- a/BlueWest.Api/Services/GreeterService.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using System.Threading.Tasks;
-using Microsoft.Extensions.Logging;
-
-namespace BlueWest.WebApi;
-
-public class GreeterService
-{
-
-}
\ No newline at end of file
diff --git a/BlueWest.Api/Services/Interceptors/ServerLoggerInterceptor.cs b/BlueWest.Api/Services/Interceptors/ServerLoggerInterceptor.cs
deleted file mode 100644
index 27ac98b..0000000
--- a/BlueWest.Api/Services/Interceptors/ServerLoggerInterceptor.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using Grpc.Core.Interceptors;
-
-namespace BlueWest.WebApi.Interceptors
-{
- ///
- /// Server Logger Interceptor
- ///
- public class ServerLoggerInterceptor : Interceptor
- {
-
- }
-}
-
diff --git a/BlueWest.Api/Session/ResetPasswordViewModel.cs b/BlueWest.Api/Session/ResetPasswordViewModel.cs
deleted file mode 100644
index d00d7ac..0000000
--- a/BlueWest.Api/Session/ResetPasswordViewModel.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System.ComponentModel.DataAnnotations;
-
-namespace BlueWest.WebApi.Context.Users;
-
-///
-/// Reset password view model
-///
-public class ResetPasswordViewModel
-{
- ///
- /// Email address from which the password needs to be reset.
- ///
- [Required]
- [EmailAddress]
- public string Email { get; set; }
-
- ///
- /// Password
- ///
- [Required]
- [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
- [DataType(DataType.Password)]
- public string Password { get; set; }
-
- ///
- /// Password confirmation
- ///
- [DataType(DataType.Password)]
- [Display(Name = "Confirm password")]
- [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
- public string ConfirmPassword { get; set; }
-
- ///
- /// The code to reset password.
- ///
- public string Code { get; set; }
-}
\ No newline at end of file
diff --git a/BlueWest.Api/Session/SessionAuthorizationFilter.cs b/BlueWest.Api/Session/SessionAuthorizationFilter.cs
deleted file mode 100644
index 33138b3..0000000
--- a/BlueWest.Api/Session/SessionAuthorizationFilter.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using BlueWest.Data.Auth;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.Filters;
-
-namespace BlueWest.WebApi.Controllers;
-
-///
-/// Use this filter where an authorized session is need to navigate in the frontend.
-///
-public class SessionAuthorizationFilter :
- IAsyncAuthorizationFilter,
- IAuthorizationFilter
-{
- private ISessionCache _sessionCache { get;}
- ///
- /// Session Authorization filter
- ///
- ///
- public SessionAuthorizationFilter(ISessionCache sessionCache)
- {
- _sessionCache = sessionCache;
- }
-
- ///
- /// Empty Attribute Constructor
- ///
- public SessionAuthorizationFilter() { }
-
- ///
- /// First verification executed before each request
- ///
- ///
- public void OnAuthorization(AuthorizationFilterContext context)
- {
- var sessionToken = context.HttpContext.Request.Headers.GetSessionTokenHeader();
-
- if (sessionToken == String.Empty)
- {
- context.Result = new ForbidResult("Invalid header");
- }
-
- var sessionIsValid = _sessionCache.IsSessionValid(sessionToken);
-
- if (!sessionIsValid)
- {
- context.Result = new ForbidResult("Session is not valid.");
- }
- }
-
- ///
- /// First verification executed before each request
- ///
- ///
- public async Task OnAuthorizationAsync(AuthorizationFilterContext context)
- {
- var sessionToken = context.HttpContext.Request.Headers.GetSessionTokenHeader();
-
- if (sessionToken == String.Empty)
- {
- context.Result = new ForbidResult("Invalid header");
- }
-
- var sessionIsValid = await _sessionCache.IsSessionValidAsync(sessionToken);
-
- if (!sessionIsValid)
- {
- context.Result = new ForbidResult("Session is not valid.");
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/BlueWest.Api/Session/SessionExtensions.cs b/BlueWest.Api/Session/SessionExtensions.cs
deleted file mode 100644
index 9efa192..0000000
--- a/BlueWest.Api/Session/SessionExtensions.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using BlueWest.Data.Auth;
-using Microsoft.AspNetCore.Http;
-
-namespace BlueWest.WebApi.Controllers
-{
- public static class SessionExtensions
- {
- ///
- /// Check for the session token header
- ///
- ///
- ///
- public static string GetSessionTokenHeader(this IHeaderDictionary headerDictionary)
- {
- if (headerDictionary.ContainsKey(SessionConstants.SessionTokenHeaderName))
- {
- return headerDictionary[SessionConstants.SessionTokenHeaderName];
- }
-
- return string.Empty;
- }
- }
-}
-
diff --git a/BlueWest.Api/Session/SessionManager.cs b/BlueWest.Api/Session/SessionManager.cs
deleted file mode 100644
index 86ffe14..0000000
--- a/BlueWest.Api/Session/SessionManager.cs
+++ /dev/null
@@ -1,130 +0,0 @@
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-using BlueWest.Cryptography;
-using BlueWest.Data.Application;
-using BlueWest.Data.Auth;
-using Microsoft.Extensions.Hosting;
-using Redis.OM;
-using Redis.OM.Searching;
-
-namespace BlueWest.WebApi.Session
-{
- ///
- /// Session Provider Context
- ///
- public sealed class SessionManager : ISessionCache
- {
- private readonly RedisConnectionProvider _provider;
- private readonly RedisCollection _sessionTokens;
- ///
- /// Index Creation Device
- ///
- /// Redis connection
- public SessionManager(
- RedisConnectionProvider provider)
- {
- _provider = provider;
- _sessionTokens = (RedisCollection)provider.RedisCollection();
- }
-
- ///
- /// Empty constructor
- ///
- public SessionManager() { }
-
- ///
- /// Get a session token by the respective Id.
- ///
- ///
- ///
- public async Task GetSessionTokenByIdAsync(string tokenId)
- {
- return await _sessionTokens.Where(x => x.Id == tokenId)
- .FirstOrDefaultAsync();
- }
-
- ///
- /// Create a new session token
- ///
- ///
- public async Task AddSessionToken(SessionToken token)
- {
- await _sessionTokens.InsertAsync(token);
- }
-
- ///
- public async Task SaveAsync()
- {
- await _sessionTokens.SaveAsync();
- }
-
-
- ///
- /// Save session data
- ///
- public void Save()
- {
- _sessionTokens.Save();
- }
-
- ///
- /// Gets a Bearer By Access Token Id
- ///
- ///
- public async Task IsSessionValidAsync(string sessionTokenId)
- {
- var accessToken = await _sessionTokens
- .Where(t => t.Id == sessionTokenId)
- .FirstOrDefaultAsync();
-
- if (accessToken == null) return false;
-
- if (accessToken.IsValid)
- {
- // Check if it's not expired
- var expirationDate = accessToken.CreatedDate + accessToken.ValidFor;
- var timeNow = DateTimeOffset.Now.ToUnixTimeMilliseconds();
- if (expirationDate >= timeNow) return accessToken.IsValid;
- accessToken.IsValid = false;
- await _sessionTokens.SaveAsync();
- }
-
- return accessToken.IsValid;
- }
-
- ///
- /// Checks if a session is valid
- ///
- ///
- ///
- public bool IsSessionValid(string sessionTokenId)
- {
- var accessToken = _sessionTokens
- .FirstOrDefault(t => t.Id == sessionTokenId);
-
- if (accessToken == null) return false;
-
- if (!accessToken.IsValid) return accessToken.IsValid;
-
- accessToken.Validate();
- _sessionTokens.Save();
-
- return accessToken.IsValid;
- }
-
-
- ///
- public async Task StartAsync(CancellationToken cancellationToken)
- {
- await _provider.Connection.CreateIndexAsync(typeof(SessionToken));
- }
-
- ///
- public Task StopAsync(CancellationToken cancellationToken)
- {
- return Task.CompletedTask;
- }
- }
-}
-
diff --git a/BlueWest.Api/Startup.cs b/BlueWest.Api/Startup.cs
deleted file mode 100644
index c8379ec..0000000
--- a/BlueWest.Api/Startup.cs
+++ /dev/null
@@ -1,191 +0,0 @@
-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.Data.Auth;
-using BlueWest.Tools;
-using BlueWest.WebApi.Interceptors;
-using BlueWest.WebApi.Interfaces;
-using BlueWest.WebApi.Tools;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Logging;
-using Microsoft.OpenApi.Models;
-
-namespace BlueWest.WebApi
-{
- ///
- /// Startup class for the API.
- ///
- public class Startup
- {
- private readonly IConfiguration _configuration;
- private readonly IWebHostEnvironment _environment;
-
- private readonly string MyAllowSpecificOrigins = Constants.CorsPolicyName;
-
- ///
- /// Startup configuration of the API
- ///
- public Startup(IConfiguration configuration, IWebHostEnvironment hostEnvironment)
- {
- _configuration = configuration;
- _environment = hostEnvironment;
- }
-
-
- ///
- /// Configure Services
- ///
- /// Dependency injection
- public void ConfigureServices(IServiceCollection services)
- {
- services.AddCors(options =>
- {
- options.AddPolicy(name: MyAllowSpecificOrigins,
- builder =>
- {
- builder.WithOrigins("http://localhost:5173/", "http://localhost:5173", "http://127.0.0.1:5173", "localhost:5173")
- .AllowAnyMethod()
- .AllowAnyHeader()
- .AllowCredentials();
- });
- });
- services.AddDistributedMemoryCache();
-
- services.AddSession(options =>
- {
- options.Cookie.Name = ".BlueWest.Session";
- options.Cookie.Domain = SessionConstants.CookieDomain;
- options.Cookie.HttpOnly = true;
- });
- services
- .AddResponseCaching()
- .AddControllers(options =>
- {
- options.CacheProfiles.Add("Default30",
- new CacheProfile()
- {
- Duration = 30
- });
- })
- .AddJsonOptions(options => options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.Preserve);
-
- services.AddLogging(builder =>
- {
- builder.AddSimpleConsole();
- });
-
-
- services
- .AddSwaggerGen(options =>
- {
- options.SchemaFilter();
- options.SwaggerDoc("v1", new OpenApiInfo
- {
- Title = "BlueWest.Api.App",
- Version = "v1"
- });
-
- // 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);
-
- options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
- {
- Description =
- "JWT Authorization header using the Bearer scheme (Example: 'Bearer 12345abcdef')",
- Name = "Authorization",
- In = ParameterLocation.Header,
- Type = SecuritySchemeType.ApiKey,
- Scheme = "Bearer"
- });
-
- options.AddSecurityRequirement(new OpenApiSecurityRequirement
- {
- {
- new OpenApiSecurityScheme
- {
- Reference = new OpenApiReference
- {
- Type = ReferenceType.SecurityScheme,
- Id = "Bearer"
- }
- },
- Array.Empty()
- }
- });
-
- });
-
-
- services.AddGrpc(options =>
- {
- options.Interceptors.Add();
- });
-
- services.AddSingleton();
- /*
- services.AddSingleton(
- new PhysicalFileProvider(
- Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/ImageFiles")
- )
- );
- */
-
-
- services
- .AddSingleton();
-
-
- services.AddAuthServerServices( _configuration, _environment);
- services.AddScoped();
-
- services.PrepareMySqlDatabasePool(_configuration, _environment);
-
-
-
- }
-
-
-
- ///
- /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
- ///
- /// Object with the necessary data to configure an application's request pipeline
- /// Provides information about the web hosting environment an application is running in.
- public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
- {
-
- //app.UseStaticFiles();
-
- app.UseSwagger();
-
- app.UseSwaggerUI(c =>
- {
- c.RoutePrefix = "swagger";
- c.SwaggerEndpoint("/swagger/v1/swagger.json", "BlueWest.Api v1");
- });
-
- app.UseStaticFiles();
- //app.UseHttpsRedirection();
-
- app.UseRouting();
- app.UseCors(MyAllowSpecificOrigins);
- app.UseSession();
- app.UseAuthentication();
- app.UseAuthorization();
- app.UseEndpoints(endpoints =>
- {
- endpoints.MapControllers();
- // endpoints.MapGrpcService();
- });
- }
- }
-}
diff --git a/BlueWest.Api/StartupExtensions.cs b/BlueWest.Api/StartupExtensions.cs
deleted file mode 100644
index d17b5ae..0000000
--- a/BlueWest.Api/StartupExtensions.cs
+++ /dev/null
@@ -1,256 +0,0 @@
-using System;
-using System.Text;
-using System.Threading.Tasks;
-using BlueWest.Domain;
-using BlueWest.Domain;
-using BlueWest.Cryptography;
-using BlueWest.Data.Application.Users;
-using BlueWest.Data.Auth;
-using BlueWest.Data.Auth.Context.Users;
-using BlueWest.WebApi.Configuration;
-using BlueWest.WebApi.Context.Users;
-using BlueWest.WebApi.Session;
-using Microsoft.AspNetCore.Authentication.Cookies;
-using Microsoft.AspNetCore.Authentication.JwtBearer;
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Hosting;
-using Microsoft.Extensions.Logging;
-using Microsoft.IdentityModel.Tokens;
-using Redis.OM;
-
-namespace BlueWest.WebApi
-{
- ///
- /// Startup Extensions
- ///
- public static class StartupExtensions
- {
- private static MySqlServerVersion GetMySqlServerVersion(int major, int minor, int build) => new (new Version(major, minor, build));
-
- private static string GetConnectionString(this IConfiguration configurationRoot, string db)
- {
- // Docker / No-Docker
- var startupMode = configurationRoot["mode"];
-
- if (startupMode == "docker")
- {
- var config = configurationRoot.GetSection("ConnectionStringDocker")[db];
- return config;
- }
- else
- {
- var config = configurationRoot.GetSection("ConnectionStringNoDocker")[db];
- return config;
- }
-
- return string.Empty;
- }
-
- ///
- /// Get MYSQL Connection String
- ///
- ///
- ///
- ///
- private static DbContextOptionsBuilder GetMySqlSettings(
- this DbContextOptionsBuilder optionsBuilder,
- IConfiguration configuration,
- IWebHostEnvironment environment)
- {
- var sqlVersion = GetMySqlServerVersion(8, 0, 11);
-
- // Docker / No-Docker
-
- var mySqlConnectionString = configuration.GetConnectionString("MySQL");
-
- if (mySqlConnectionString == string.Empty)
- {
- throw new InvalidOperationException("Fatal error: MySQL Connection string is empty.");
- }
-
-
- optionsBuilder
- .UseMySql(
- mySqlConnectionString,
- sqlVersion)
- .UseMySql(sqlVersion,
- builder =>
- {
- builder.EnableRetryOnFailure(6, TimeSpan.FromSeconds(3), null);
- });
-
- // The following three options help with debugging, but should
- // be changed or removed for production.
- if (environment.IsDevelopment())
- {
- optionsBuilder
- .LogTo(Console.WriteLine, LogLevel.Information)
- .EnableSensitiveDataLogging()
- .EnableDetailedErrors();
- }
-
- return optionsBuilder;
- }
-
- ///
- /// Setup database Contexts
- ///
- ///
- ///
- ///
- ///
- public static IServiceCollection PrepareMySqlDatabasePool(this IServiceCollection serviceCollection,
- IConfiguration configuration, IWebHostEnvironment environment)
- {
- return serviceCollection
- .AddDbContextPool(options =>
- options.GetMySqlSettings(configuration, environment))
- .AddDbContextPool(options =>
- options.GetMySqlSettings(configuration, environment))
- .AddDbContextPool(options =>
- options.GetMySqlSettings(configuration, environment))
- .AddDbContextPool(options =>
- options.GetMySqlSettings(configuration, environment))
- .AddDbContextPool(options =>
- options.GetMySqlSettings(configuration, environment));
- }
-
- internal static IServiceCollection AddAuthServerServices(this IServiceCollection services, IConfiguration configuration , IWebHostEnvironment environment)
- {
-
- var connectionString = configuration.GetConnectionString("Redis");
-
- if (connectionString == null)
- {
- throw new InvalidOperationException("Redis connection string is empty");
- }
-
- services
- .AddSingleton(new RedisConnectionProvider(connectionString))
- .AddScoped()
- .AddScoped()
- .AddHostedService()
- .AddSingleton()
- .AddScoped()
- .AddScoped()
- .AddScoped()
- .AddScoped();
-
- // Database Context and Swagger
-
-
- // Register the ConfigurationBuilder instance of AuthSettings
- var authSettings = configuration.GetSection(nameof(AuthSettings));
- services.Configure(authSettings);
- var signingKey = new SymmetricSecurityKey
- (Encoding.ASCII.GetBytes(authSettings[nameof(AuthSettings.SecretKey)]));
-
- // jwt wire up
- // Get options from app settings
- var jwtAppSettingOptions = configuration
- .GetSection(nameof(JwtIssuerOptions));
-
- // Configure JwtIssuerOptions
- services.Configure(options =>
- {
- options.Issuer = jwtAppSettingOptions[nameof(JwtIssuerOptions.Issuer)];
- options.Audience = jwtAppSettingOptions[nameof(JwtIssuerOptions.Audience)];
- options.SigningCredentials = new SigningCredentials
- (signingKey, SecurityAlgorithms.HmacSha256);
- });
-
- var tokenValidationParameters = new TokenValidationParameters
- {
- ValidateIssuer = true,
- ValidIssuer = jwtAppSettingOptions[nameof(JwtIssuerOptions.Issuer)],
-
- ValidateAudience = true,
- ValidAudience = jwtAppSettingOptions[nameof(JwtIssuerOptions.Audience)],
-
- ValidateIssuerSigningKey = true,
- IssuerSigningKey = signingKey,
-
- RequireExpirationTime = false,
- ValidateLifetime = true,
- ClockSkew = TimeSpan.Zero
- };
-
- services.AddAuthentication(options =>
- {
-
- options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
- options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
- options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
- options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
- options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
- })
- .AddCookie(options =>
- {
- options.Cookie.SameSite = SameSiteMode.Lax;
- options.Cookie.SecurePolicy = CookieSecurePolicy.SameAsRequest;
- options.Cookie.MaxAge = SessionConstants.DefaultSessionMaxAge;
- options.LoginPath = "/api/auth/logincookie";
- options.LogoutPath = "/api/auth/logout";
- })
- .AddJwtBearer(configureOptions =>
- {
- configureOptions.ClaimsIssuer = jwtAppSettingOptions[nameof(JwtIssuerOptions.Issuer)];
- configureOptions.TokenValidationParameters = tokenValidationParameters;
- configureOptions.SaveToken = true;
-
- configureOptions.Events = new JwtBearerEvents
- {
- OnAuthenticationFailed = context =>
- {
- if (context.Exception.GetType() == typeof(SecurityTokenExpiredException))
- {
- context.Response.Headers.Add("Token-Expired", "true");
- }
-
- return Task.CompletedTask;
- },
- };
- });
-
-
- // api user claim policy
- services.AddAuthorization(options =>
- {
- options.AddPolicy(SessionConstants.ApiNamePolicy,
- policy => policy.RequireClaim(Data.Auth.Context.Users.Constants.JwtClaimIdentifiers.Rol,
- Data.Auth.Context.Users.Constants.JwtClaims.ApiAccess));
-
- });
-
- // add identity
- var identityBuilder = services.AddIdentityCore(o =>
- {
- o.User.RequireUniqueEmail = true;
-
- // configure identity options
- o.Password.RequireDigit = false;
- o.Password.RequireLowercase = false;
- o.Password.RequireUppercase = false;
- o.Password.RequireNonAlphanumeric = false;
- o.Password.RequiredLength = 6;
- })
- .AddUserManager()
- .AddUserStore();
-
- identityBuilder = new IdentityBuilder(identityBuilder.UserType, typeof(ApplicationRole), identityBuilder.Services);
- identityBuilder
- .AddEntityFrameworkStores()
- .AddDefaultTokenProviders();
-
- return services;
- }
-
- }
-}
-
-
diff --git a/BlueWest.Api/SwaggerEnumSchemaFilter.cs b/BlueWest.Api/SwaggerEnumSchemaFilter.cs
deleted file mode 100644
index 167313a..0000000
--- a/BlueWest.Api/SwaggerEnumSchemaFilter.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using System;
-using System.Linq;
-using Microsoft.OpenApi.Any;
-using Microsoft.OpenApi.Models;
-using Swashbuckle.AspNetCore.SwaggerGen;
-
-namespace BlueWest.WebApi.Tools
-{
- ///
- public class SwaggerEnumSchemaFilter : ISchemaFilter
- {
- ///
- /// Apply Swagger OpenApi schema
- ///
- /// OpenApiSchema model
- /// Schema filter context
- public void Apply(OpenApiSchema model, SchemaFilterContext context)
- {
- if (context.Type.IsEnum)
- {
- model.Enum.Clear();
- Enum.GetNames(context.Type)
- .ToList()
- .ForEach(n => model.Enum.Add(new OpenApiString(n)));
- }
- }
- }
-
-}
\ No newline at end of file
diff --git a/BlueWest.Api/UpdateContexts.bash b/BlueWest.Api/UpdateContexts.bash
deleted file mode 100644
index e106552..0000000
--- a/BlueWest.Api/UpdateContexts.bash
+++ /dev/null
@@ -1,6 +0,0 @@
-dotnet ef database update -c ApplicationUserDbContext
-dotnet ef database update -c CountryDbContext
-dotnet ef database update -c CompanyDbContext
-dotnet ef database update -c UserDbContext
-
-
diff --git a/BlueWest.Api/appsettings.Development.json b/BlueWest.Api/appsettings.Development.json
deleted file mode 100644
index 8983e0f..0000000
--- a/BlueWest.Api/appsettings.Development.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft": "Warning",
- "Microsoft.Hosting.Lifetime": "Information"
- }
- }
-}
diff --git a/BlueWest.Api/appsettings.json b/BlueWest.Api/appsettings.json
deleted file mode 100644
index 79246b4..0000000
--- a/BlueWest.Api/appsettings.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft": "Warning",
- "Microsoft.Hosting.Lifetime": "Information"
- }
- },
- "AllowedHosts": "*",
- "ConnectionStringDocker": {
- "MySQL": "server=db;user=blueuser;password=dXjw127124dJ;database=bluedb;",
- "Redis": "redis://redisinstance:6379"
- },
- "ConnectionStringNoDocker": {
- "MySQL": "server=localhost;user=blueuser;password=dXjw127124dJ;database=bluedb;",
- "Redis": "redis://localhost:6379"
- },
- "AuthSettings": {
- "SecretKey": "iJWHDmHLpUA283sqsfhqGbMRdRj1PVkH"
- },
- "JwtIssuerOptions": {
- "Issuer": "SomeIssuer",
- "Audience": "http://localhost:5000"
- }
-}
diff --git a/BlueWest.Data.Capital/BlueWest.Data.Capital.csproj b/BlueWest.Data.Capital/BlueWest.Data.Capital.csproj
index d216f12..51ccd8d 100644
--- a/BlueWest.Data.Capital/BlueWest.Data.Capital.csproj
+++ b/BlueWest.Data.Capital/BlueWest.Data.Capital.csproj
@@ -22,7 +22,6 @@
-
diff --git a/BlueWest.Data.Capital/Capital/Company/Company.cs b/BlueWest.Data.Capital/Capital/Company/Company.cs
deleted file mode 100644
index f05efab..0000000
--- a/BlueWest.Data.Capital/Capital/Company/Company.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using System;
-using System.Collections.Generic;
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom(new [] {typeof(CompanyCreate), typeof(CompanyUpdate)})]
- public partial class Company
- {
- public int Id { get; set; }
-
- public string Name { get; set; }
-
- public string Address { get; set; }
-
- public CompanyType CompanyType { get; set; }
-
- public Country CurrentCountry { get; set; }
-
- public Country OriginCountry { get; set; }
-
- public DateTime FoundingDate { get; set; }
-
- public List Industry { get; set; }
-
- public DateTime CreationDate { get; set; }
-
- }
-}
-
diff --git a/BlueWest.Data.Capital/Capital/Company/CompanyCreate.cs b/BlueWest.Data.Capital/Capital/Company/CompanyCreate.cs
deleted file mode 100644
index c65085a..0000000
--- a/BlueWest.Data.Capital/Capital/Company/CompanyCreate.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom(typeof(Company))]
- public partial class CompanyCreate
- {
- public string Name { get; set; }
-
- public string Address { get; set; }
-
- public Country CurrentCountry { get; set; }
-
- public Country OriginCountry { get; set; }
-
- public DateTime FoundingDate { get; set; }
-
- public DateTime CreateTime { get; } = DateTime.Now;
-
- }
-}
-
diff --git a/BlueWest.Data.Capital/Capital/Company/CompanyType/CompanyType.cs b/BlueWest.Data.Capital/Capital/Company/CompanyType/CompanyType.cs
deleted file mode 100644
index 89fbedf..0000000
--- a/BlueWest.Data.Capital/Capital/Company/CompanyType/CompanyType.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom(typeof(Company))]
- public partial class CompanyType
- {
- public int Id { get; set; }
- public string Name { get; set; }
-
- }
-}
-
diff --git a/BlueWest.Data.Capital/Capital/Company/CompanyType/CompanyTypeCreate.cs b/BlueWest.Data.Capital/Capital/Company/CompanyType/CompanyTypeCreate.cs
deleted file mode 100644
index ada0d49..0000000
--- a/BlueWest.Data.Capital/Capital/Company/CompanyType/CompanyTypeCreate.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom(typeof(Company))]
- public partial class CompanyTypeCreate
- {
- public string Name { get; set; }
-
- }
-}
-
diff --git a/BlueWest.Data.Capital/Capital/Company/CompanyUnique.cs b/BlueWest.Data.Capital/Capital/Company/CompanyUnique.cs
deleted file mode 100644
index bad00f5..0000000
--- a/BlueWest.Data.Capital/Capital/Company/CompanyUnique.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom(typeof(Company))]
- public partial class CompanyUnique
- {
- public int Id { get; set; }
-
- public string Name { get; set; }
-
- public string Address { get; set; }
-
- public CompanyType CompanyType { get; set; }
-
- public Country CurrentCountry { get; set; }
-
- public Country OriginCountry { get; set; }
-
- public DateTime FoundingDate { get; set; }
- }
-}
-
diff --git a/BlueWest.Data.Capital/Capital/Company/CompanyUpdate.cs b/BlueWest.Data.Capital/Capital/Company/CompanyUpdate.cs
deleted file mode 100644
index 8df2f3b..0000000
--- a/BlueWest.Data.Capital/Capital/Company/CompanyUpdate.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom(typeof(Company))]
- public partial class CompanyUpdate
- {
- public string Name { get; set; }
-
- public string Address { get; set; }
-
- public Country CurrentCountry { get; set; }
-
- public Country OriginCountry { get; set; }
-
- public DateTime FoundingDate { get; set; }
- }
-}
-
diff --git a/BlueWest.Data.Capital/Capital/Company/Product/Product.cs b/BlueWest.Data.Capital/Capital/Company/Product/Product.cs
deleted file mode 100644
index 2e3570a..0000000
--- a/BlueWest.Data.Capital/Capital/Company/Product/Product.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System.Collections.Generic;
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom(new []{typeof(ProductUpdate), typeof(ProductCreate), typeof(ProductUnique)})]
- public partial class Product
- {
- public int Id { get; set; }
- public string Name { get; set; }
- public string Size { get; set; }
- public double Price { get; set; }
-
- public Currency Currency { get; set; }
- public Industry Industry { get; set; }
- public List Seller { get; set; }
- }
-}
-
diff --git a/BlueWest.Data.Capital/Capital/Company/Product/ProductCreate.cs b/BlueWest.Data.Capital/Capital/Company/Product/ProductCreate.cs
deleted file mode 100644
index 6b20c5e..0000000
--- a/BlueWest.Data.Capital/Capital/Company/Product/ProductCreate.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom(typeof(Product))]
- public partial class ProductCreate
- {
- public string Name { get; set; }
- public string Size { get; set; }
- public Industry Industry { get; set; }
- }
-}
-
diff --git a/BlueWest.Data.Capital/Capital/Company/Product/ProductUnique.cs b/BlueWest.Data.Capital/Capital/Company/Product/ProductUnique.cs
deleted file mode 100644
index 6c88883..0000000
--- a/BlueWest.Data.Capital/Capital/Company/Product/ProductUnique.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom(typeof(Product))]
-
- public partial class ProductUnique
- {
- public int Id { get; set; }
- public string Name { get; set; }
- public string Size { get; set; }
- public Industry Industry { get; set; }
- }
-}
-
diff --git a/BlueWest.Data.Capital/Capital/Company/Product/ProductUpdate.cs b/BlueWest.Data.Capital/Capital/Company/Product/ProductUpdate.cs
deleted file mode 100644
index db11e94..0000000
--- a/BlueWest.Data.Capital/Capital/Company/Product/ProductUpdate.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom(typeof(Product))]
- public partial class ProductUpdate
- {
- public string Name { get; set; }
- public string Size { get; set; }
- public Industry Industry { get; set; }
- }
-}
-
diff --git a/BlueWest.Data.Capital/Capital/Country/Country.cs b/BlueWest.Data.Capital/Capital/Country/Country.cs
index 1da4fbb..05fbcc6 100644
--- a/BlueWest.Data.Capital/Capital/Country/Country.cs
+++ b/BlueWest.Data.Capital/Capital/Country/Country.cs
@@ -31,7 +31,6 @@ namespace BlueWest.Data
[MaxLength(2)] public string Alpha2Code { get; set; }
public string TLD { get; set; }
- public List Currencies { get; set; }
public List Users { get; set; }
public DateTime CreationDate { get; set; }
diff --git a/BlueWest.Data.Capital/Capital/Country/generated/GeneratedCountries.cs b/BlueWest.Data.Capital/Capital/Country/generated/GeneratedCountries.cs
deleted file mode 100644
index a7165c9..0000000
--- a/BlueWest.Data.Capital/Capital/Country/generated/GeneratedCountries.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace BlueWest.Data.generated
-{
- public class GeneratedCountries
- {
-
- }
-}
-
diff --git a/BlueWest.Data.Capital/Capital/Currency/Currency.cs b/BlueWest.Data.Capital/Capital/Currency/Currency.cs
deleted file mode 100644
index 4987321..0000000
--- a/BlueWest.Data.Capital/Capital/Currency/Currency.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom(new []{
- typeof(CurrencyUpdate),
- typeof(CurrencyCreate),
- typeof(CurrencyUnique)
- })]
-
- public partial class Currency
- {
- public int Id { get; set; }
- public int Num { get; set; }
- [MaxLength(3)] public string Code { get; set; }
- public List Countries { get; set; }
-
- public DateTime CreateDate { get; set; }
- }
-}
-
diff --git a/BlueWest.Data.Capital/Capital/Currency/CurrencyCreate.cs b/BlueWest.Data.Capital/Capital/Currency/CurrencyCreate.cs
deleted file mode 100644
index df36cb4..0000000
--- a/BlueWest.Data.Capital/Capital/Currency/CurrencyCreate.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom(typeof(Currency))]
- public partial class CurrencyCreate
- {
- public int Num { get; set; }
- [MaxLength(3)] public string Code { get; set; }
- //public List CountriesToCreate { get; set; }
- }
-}
-
diff --git a/BlueWest.Data.Capital/Capital/Currency/CurrencyUnique.cs b/BlueWest.Data.Capital/Capital/Currency/CurrencyUnique.cs
deleted file mode 100644
index 2024523..0000000
--- a/BlueWest.Data.Capital/Capital/Currency/CurrencyUnique.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom(typeof(Currency))]
- public partial class CurrencyUnique
- {
- public int Id { get; set; }
- public int Num { get; set; } // Primary key
- [MaxLength(3)] public string Code { get; set; }
-
- public DateTime CreateDate { get; set; }
-
- }
-}
-
diff --git a/BlueWest.Data.Capital/Capital/Currency/CurrencyUpdate.cs b/BlueWest.Data.Capital/Capital/Currency/CurrencyUpdate.cs
deleted file mode 100644
index 0e9634f..0000000
--- a/BlueWest.Data.Capital/Capital/Currency/CurrencyUpdate.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom(typeof(Currency))]
-
- public partial class CurrencyUpdate
- {
- public int Num { get; set; }
-
- // ISO 4217 Code
- [MaxLength(3)] public string Code { get; set; }
-
- }
-}
diff --git a/BlueWest.Data.Capital/Capital/Industry/Industry.cs b/BlueWest.Data.Capital/Capital/Industry/Industry.cs
deleted file mode 100644
index 546e1ba..0000000
--- a/BlueWest.Data.Capital/Capital/Industry/Industry.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom(new []{typeof(IndustryCreate), typeof(IndustryUpdate)})]
- public partial class Industry
- {
- public int Id { get; set; }
- public string IndustryName { get; set; }
- public Industry IndustryParent { get; set; }
- public List IndustryChilds { get; set; }
-
- public DateTime CreateDate { get; set; }
-
- }
-}
-
diff --git a/BlueWest.Data.Capital/Capital/Industry/IndustryCreate.cs b/BlueWest.Data.Capital/Capital/Industry/IndustryCreate.cs
deleted file mode 100644
index 4a71899..0000000
--- a/BlueWest.Data.Capital/Capital/Industry/IndustryCreate.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom(typeof(Industry))]
- public partial class IndustryCreate
- {
- public string IndustryName { get; set; }
- public Industry IndustryParent { get; set; }
- }
-}
-
diff --git a/BlueWest.Data.Capital/Capital/Industry/IndustryUnique.cs b/BlueWest.Data.Capital/Capital/Industry/IndustryUnique.cs
deleted file mode 100644
index a1a8d21..0000000
--- a/BlueWest.Data.Capital/Capital/Industry/IndustryUnique.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System;
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom(typeof(Industry))]
- public partial class IndustryUnique
- {
- public int Id { get; set; }
- public string IndustryName { get; set; }
- public Industry IndustryParent { get; set; }
-
- public DateTime CreateDate { get; set; }
-
- }
-}
-
diff --git a/BlueWest.Data.Capital/Capital/Industry/IndustryUpdate.cs b/BlueWest.Data.Capital/Capital/Industry/IndustryUpdate.cs
deleted file mode 100644
index 4a1a8b3..0000000
--- a/BlueWest.Data.Capital/Capital/Industry/IndustryUpdate.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom(typeof(Industry))]
- public partial class IndustryUpdate
- {
- public string IndustryName { get; set; }
- public Industry IndustryParent { get; set; }
- }
-}
-
diff --git a/BlueWest.Data.Capital/Capital/Media/MediaSource.cs b/BlueWest.Data.Capital/Capital/Media/MediaSource.cs
deleted file mode 100644
index ba4480a..0000000
--- a/BlueWest.Data.Capital/Capital/Media/MediaSource.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace BlueWest.Data.Media
-{
- public class MediaSource
- {
- public MediaSourceType SourceType { get; set; }
- }
-}
-
diff --git a/BlueWest.Data.Capital/Capital/Media/MediaSourceType.cs b/BlueWest.Data.Capital/Capital/Media/MediaSourceType.cs
deleted file mode 100644
index 47bf541..0000000
--- a/BlueWest.Data.Capital/Capital/Media/MediaSourceType.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace BlueWest.Data.Media
-{
- public class MediaSourceType
- {
- public string SourceTypeName { get; set; }
- }
-}
-
diff --git a/BlueWest.Data.Capital/Capital/Media/Website.cs b/BlueWest.Data.Capital/Capital/Media/Website.cs
deleted file mode 100644
index 5454c77..0000000
--- a/BlueWest.Data.Capital/Capital/Media/Website.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace BlueWest.Data.Media
-{
- public class Website
- {
- public int Id { get; set; }
- public string WebsiteDomain { get; set; }
- public string IsHttps { get; set; }
- public bool HasCloudflareLikeService { get; set; }
- }
-}
-
diff --git a/BlueWest.Data.Capital/Transaction/FinanceOp.cs b/BlueWest.Data.Capital/Transaction/FinanceOp.cs
deleted file mode 100644
index 984905f..0000000
--- a/BlueWest.Data.Capital/Transaction/FinanceOp.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom(typeof(FinanceOpCreate))]
- public partial class FinanceOp
- {
- public int UserId { get; set; }
-
- [Key] public int Id;
- public TimeSpan CreationDate { get; set; }
-
- [Required] public Currency Currency { get; }
-
- public FinanceOpType Type {get;}
-
- private string Description {get;}
-
-
-
- public FinanceOp(TimeSpan creationDate, int userId,
- Currency currency, FinanceOpType financeOpType)
- {
- CreationDate = creationDate;
- UserId = userId;
- Currency = currency;
- Type = financeOpType;
- }
- }
-}
\ No newline at end of file
diff --git a/BlueWest.Data.Capital/Transaction/FinanceOpCreate.cs b/BlueWest.Data.Capital/Transaction/FinanceOpCreate.cs
deleted file mode 100644
index 01351ee..0000000
--- a/BlueWest.Data.Capital/Transaction/FinanceOpCreate.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom( typeof(FinanceOp))]
-
- public partial class FinanceOpCreate
- {
- public int UserId { get; set; }
-
- public Currency Currency { get; }
-
- public FinanceOpType FinanceOpType {get;}
-
-
- public FinanceOpCreate(
- int userId,
- Currency currency ,
- FinanceOpType financeOpType
- )
- {
- Currency = currency;
- UserId = userId;
- Currency = currency;
- FinanceOpType = financeOpType;
- }
- }
-}
diff --git a/BlueWest.Data.Capital/Transaction/FinanceOpRead.cs b/BlueWest.Data.Capital/Transaction/FinanceOpRead.cs
deleted file mode 100644
index 1929082..0000000
--- a/BlueWest.Data.Capital/Transaction/FinanceOpRead.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using MapTo;
-
-namespace BlueWest.Data
-{
- [MapFrom(typeof(FinanceOp))]
-
- public partial class FinanceTransactionReadDto
- {
- public int UserId { get; set; }
-
- public Currency Currency { get; }
-
- public FinanceOpType FinanceOpType {get;}
- public TimeSpan CreationDate { get; set; }
-
- }
-}
diff --git a/BlueWest.Data.Capital/Transaction/FinanceOpType.cs b/BlueWest.Data.Capital/Transaction/FinanceOpType.cs
deleted file mode 100644
index 832e7e4..0000000
--- a/BlueWest.Data.Capital/Transaction/FinanceOpType.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System.ComponentModel.DataAnnotations;
-
-namespace BlueWest.Data
-{
- public partial class FinanceOpType
- {
- [Key] public int Id { get; set; }
-
- public string Name { get; set; }
-
- public string Description { get; set; }
-
- }
-}
-
diff --git a/BlueWest.Data.Capital/Transaction/MathOperation.cs b/BlueWest.Data.Capital/Transaction/MathOperation.cs
deleted file mode 100644
index 8293eab..0000000
--- a/BlueWest.Data.Capital/Transaction/MathOperation.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using SimpleExpressionEvaluator;
-
-namespace BlueWest.Data;
-
-public class MathOperation
-{
- [Key] public TimeSpan CreationDate { get; set; }
-
- private bool _isCalculated = false;
-
- private string _expression;
-
- private decimal _resultingAmount;
-
- private ExpressionEvaluator _expressionEvaluator = new ExpressionEvaluator();
-
- public decimal ResultingAmount
- {
- get
- {
- if (_isCalculated) return _resultingAmount;
- return 0;
- }
- }
-
- public MathOperation() { }
- public MathOperation(string expression, Dictionary letters)
- {
-
- _resultingAmount = _expressionEvaluator.Evaluate(expression, letters);
- _isCalculated = true;
-
- }
-
-}
\ No newline at end of file
diff --git a/BlueWest.Data.Capital/Transaction/TransactionAmount.cs b/BlueWest.Data.Capital/Transaction/TransactionAmount.cs
deleted file mode 100644
index b9c24e2..0000000
--- a/BlueWest.Data.Capital/Transaction/TransactionAmount.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace BlueWest.Data
-{
- public class TransactionAmount
- {
- public Currency Currency { get; set; }
- }
-}
-
diff --git a/BlueWest.Data.Capital/User/User.cs b/BlueWest.Data.Capital/User/User.cs
index ceec788..a098542 100644
--- a/BlueWest.Data.Capital/User/User.cs
+++ b/BlueWest.Data.Capital/User/User.cs
@@ -13,8 +13,6 @@ namespace BlueWest.Data
public string ApplicationUserId { get; set; }
public int Id { get; set; }
public string Name { get; set; }
-
- public List FinanceTransactions { get; set; }
[ForeignKey("CountryId")] public Country Country { get; set; }
diff --git a/BlueWest.Domain/CompanyDbContext.cs b/BlueWest.Domain/CompanyDbContext.cs
deleted file mode 100644
index adb6621..0000000
--- a/BlueWest.Domain/CompanyDbContext.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-
-using BlueWest.Data;
-using BlueWest.Domain.Model;
-using BlueWest.EfMethods;
-using Microsoft.EntityFrameworkCore;
-
-namespace BlueWest.Domain
-{
- ///
- /// Context for accessing company data
- ///
- [EfGenerator]
- public sealed class CompanyDbContext : DbContext
- {
- #region Companies
- ///
- /// Companies.
- ///
- [EfAddMethods(typeof(CompanyCreate), typeof(CompanyUnique))]
- [EfUpdateMethods(typeof(CompanyUpdate),returnType: typeof(CompanyUnique),nameof(Company.Id))]
-
- public DbSet Companies { get; set; }
-
- #endregion
-
- #region Industries
- ///
- /// Industries.
- ///
- [EfAddMethods(typeof(IndustryCreate), typeof(IndustryUnique))]
-
- [EfUpdateMethods(
- updateType: typeof(IndustryUpdate),
- returnType: typeof(IndustryUnique),
- keyPropertyMemberName: nameof(Industry.Id)
- )
- ]
-
- public DbSet Industries { get; set; }
-
- #endregion
-
- #region Products
-
- ///
- /// Products
- ///
-
- [EfAddMethods(typeof(ProductCreate), typeof(ProductUnique))]
-
- [EfUpdateMethods(
- updateType: typeof(ProductUpdate),
- returnType: typeof(ProductUnique),
- keyPropertyMemberName: nameof(Product.Id)
- )
- ]
-
- public DbSet Products { get; set; }
- #endregion
-
- #region Initialization
-
- ///
- /// CompanyDbContext constructor.
- ///
- ///
- public CompanyDbContext(DbContextOptions options) : base(options)
- {
- Database.EnsureCreated();
- }
-
- ///
- /// On model creating.
- ///
- /// Builder model of the database
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- base.OnModelCreating(modelBuilder);
- modelBuilder.ConfigureCurrentDbModel();
- }
-
- #endregion
-
-
- }
-}
-
diff --git a/BlueWest.Domain/CountryDbContext.cs b/BlueWest.Domain/CountryDbContext.cs
index e57d752..a0824de 100644
--- a/BlueWest.Domain/CountryDbContext.cs
+++ b/BlueWest.Domain/CountryDbContext.cs
@@ -28,34 +28,10 @@ namespace BlueWest.Domain
[EfUpdateMethods( updateType: typeof(CountryUpdate), returnType: typeof(CountryUnique), keyPropertyMemberName: nameof(Country.Id))]
[EfGetMany(typeof(CountryUnique))]
- [EfGetList(nameof(Country.Currencies), typeof(CurrencyUnique), nameof(Country.Id))]
-
- [EfAddToList(nameof(Country.Currencies), typeof(CurrencyCreate), typeof(CurrencyUnique), nameof(Country.Id))]
- [EfGetOneFromList(nameof(Country.Id), nameof(Country.Currencies), nameof(Currency.Id), typeof(CurrencyUnique))]
-
public DbSet Countries { get; set; }
#endregion
- #region Currencies
-
- ///
- /// Currencies Database Table
- ///
-
- [EfAddMethods(typeof(CurrencyCreate), typeof(CurrencyUnique))]
- [EfUpdateMethods(typeof(CurrencyUpdate), typeof(CurrencyUnique), nameof(Currency.Id))]
-
- [EfGetOneBy(nameof(Currency.Id), typeof(CurrencyUnique))]
- [EfGetOne(typeof(CurrencyUnique))]
- [EfGetMany(typeof(CurrencyUnique))]
-
- [EfGetList(nameof(Currency.Countries), typeof(CountryUnique), nameof(Currency.Id))]
- [EfGetOneFromList(nameof(Currency.Id), nameof(Currency.Countries), nameof(Country.Id), typeof(CountryUnique))]
-
- public DbSet Currencies { get; set; }
-
- #endregion
#region Initialization
///
@@ -81,7 +57,6 @@ namespace BlueWest.Domain
{
base.OnModelCreating(modelBuilder);
modelBuilder.ConfigureCurrentDbModel();
- modelBuilder.AddCurrencyAndCountryData();
}
#endregion
diff --git a/BlueWest.Domain/Extensions/ModelBuilderCountryDbContextExtensions.cs b/BlueWest.Domain/Extensions/ModelBuilderCountryDbContextExtensions.cs
index ce4410e..0a05215 100644
--- a/BlueWest.Domain/Extensions/ModelBuilderCountryDbContextExtensions.cs
+++ b/BlueWest.Domain/Extensions/ModelBuilderCountryDbContextExtensions.cs
@@ -8,55 +8,8 @@ namespace BlueWest.Domain.Extensions
/// Code first model builder
///
public static class ModelBuilderCountryDbContextExtensions
- { ///
- /// Setup the database model
- ///
- ///
- public static void AddCurrencyAndCountryData(this ModelBuilder modelBuilder)
- {
-
-
- var currencies = new List();
-
- var usaCountry = new Country();
-
- usaCountry.Id = 1;
- usaCountry.Code = 1;
- usaCountry.Name = "United States";
- usaCountry.Alpha2Code = "US";
- usaCountry.StateName = "United States of America";
- usaCountry.TLD = "us";
-
- var germanyCountry = new Country();
-
- germanyCountry.Id = 2;
- germanyCountry.Code = 2;
- germanyCountry.Name = "Germany";
- germanyCountry.Alpha2Code = "DE";
- germanyCountry.StateName = "Germany";
- germanyCountry.TLD = "de";
-
- var dolar = new Currency();
- dolar.Id = 1;
- dolar.Code = "USD";
- dolar.Countries = new List();
- dolar.Countries.Add(usaCountry);
- dolar.Num = 1;
-
-
- var euro = new Currency();
- euro.Id = 2;
- euro.Code = "EUR";
- euro.Countries = new List();
- euro.Countries.Add(germanyCountry);
- euro.Num = 2;
-
-
- modelBuilder
- .Entity()
- .HasData(currencies.ToArray());
- }
-
+ {
+
}
}
diff --git a/BlueWest.Domain/Extensions/ModelBuilderExtensions.cs b/BlueWest.Domain/Extensions/ModelBuilderExtensions.cs
index 7ca47bd..498fe45 100644
--- a/BlueWest.Domain/Extensions/ModelBuilderExtensions.cs
+++ b/BlueWest.Domain/Extensions/ModelBuilderExtensions.cs
@@ -131,45 +131,12 @@ namespace BlueWest.Domain.Model
.Entity().Property(country => country.Id)
.ValueGeneratedOnAdd();
- // Currency
- modelBuilder
- .Entity(builder => builder
- .HasKey(currency => currency.Id))
- .Entity()
- .Property(currency => currency.Id)
- .ValueGeneratedOnAdd();
-
- // Company PK
- modelBuilder
- .Entity(builder => builder
- .HasKey(company => company.Id))
- .Entity().Property(company => company.Id)
- .ValueGeneratedOnAdd();
-
- // Industry PK
- modelBuilder
- .Entity(builder => builder
- .HasKey(industry => industry.Id))
- .Entity().Property(industry => industry.Id)
- .ValueGeneratedOnAdd();
-
-
- // Product
- modelBuilder
- .Entity(builder => builder
- .HasKey(industry => industry.Id));
-
- modelBuilder
- .Entity()
- .Property(industry => industry.Id)
- .ValueGeneratedOnAdd();
// FinanceOp
- return
- modelBuilder.Entity(builder => builder
- .HasKey(financeOp => financeOp.Id));
-
-
+ return
+ modelBuilder;
+
+
}
#endregion
@@ -178,30 +145,13 @@ namespace BlueWest.Domain.Model
private static ModelBuilder CurrencyModel(this ModelBuilder modelBuilder)
{
- modelBuilder.Entity().ToTable("Currencies");
modelBuilder.Entity().ToTable("Countries");
-
- modelBuilder
- .Entity()
- .HasMany(ub => ub.Countries)
- .WithMany(au => au.Currencies);
-
- modelBuilder.Entity()
- .HasMany(ub => ub.Currencies)
- .WithMany(au => au.Countries);
-
return modelBuilder;
}
private static ModelBuilder ConfigureUserModel(this ModelBuilder modelBuilder)
{
- // FinanceOp => User
- modelBuilder
- .Entity(builder => builder
- .HasOne()
- .WithMany(ft => ft.FinanceTransactions)
- .HasForeignKey(x => x.UserId));
return modelBuilder;
}
diff --git a/BlueWest.Domain/FinanceDbContext.cs b/BlueWest.Domain/FinanceDbContext.cs
deleted file mode 100644
index 2cd8eaf..0000000
--- a/BlueWest.Domain/FinanceDbContext.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-using BlueWest.Data;
-using BlueWest.Domain.Model;
-using Microsoft.EntityFrameworkCore;
-
-namespace BlueWest.Domain
-{
- ///
- /// Finance operations table
- ///
- public sealed class FinanceDbContext : DbContext
- {
- #region Transactions
-
- ///
- /// Table storing transactions
- ///
- public DbSet Transactions { get; set; }
-
- #endregion
-
- #region TransactionType
-
- ///
- /// Table storing transaction types.
- ///
- public DbSet TransactionTypes { get; set; }
-
-
- #endregion
-
- #region Initialization
-
- ///
- /// CompanyDbContext constructor.
- ///
- ///
- public FinanceDbContext(DbContextOptions options) : base(options)
- {
- Database.EnsureCreated();
- }
-
- ///
- /// On model creating.
- ///
- /// Builder model of the database
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- base.OnModelCreating(modelBuilder);
- modelBuilder.ConfigureCurrentDbModel();
- }
-
- #endregion
-
- }
-}
-
diff --git a/BlueWest.Views/StartupExtensions.cs b/BlueWest.Views/StartupExtensions.cs
index 89cb3c5..a0553fc 100644
--- a/BlueWest.Views/StartupExtensions.cs
+++ b/BlueWest.Views/StartupExtensions.cs
@@ -216,10 +216,6 @@ public static class StartupExtensions
options.GetMySqlSettings(configuration, environment))
.AddDbContextPool(options =>
options.GetMySqlSettings(configuration, environment))
- .AddDbContextPool(options =>
- options.GetMySqlSettings(configuration, environment))
- .AddDbContextPool(options =>
- options.GetMySqlSettings(configuration, environment))
.AddDbContextPool(options =>
options.GetMySqlSettings(configuration, environment));
}
diff --git a/BlueWest.sln b/BlueWest.sln
index 7b8caff..eb1d3d2 100644
--- a/BlueWest.sln
+++ b/BlueWest.sln
@@ -7,8 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlueWest", "BlueWest\BlueWe
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlueWest.Data.Capital", "BlueWest.Data.Capital\BlueWest.Data.Capital.csproj", "{E518C62D-768C-4885-9C9D-FD5761605B54}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlueWest.Api", "BlueWest.Api\BlueWest.Api.csproj", "{6D3321B5-CF1A-4251-B28D-329EDA6DC278}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlueWest.MapTo", "include\BlueWest.MapTo\src\BlueWest.MapTo\BlueWest.MapTo.csproj", "{72B37540-A12F-466E-A58F-7BA2B247CB74}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleExpressionEvaluator", "include\Math-Expression-Evaluator\SimpleExpressionEvaluator\SimpleExpressionEvaluator.csproj", "{30637214-EDE9-4C2E-BFD6-E4B163FA308B}"
@@ -57,10 +55,6 @@ Global
{E518C62D-768C-4885-9C9D-FD5761605B54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E518C62D-768C-4885-9C9D-FD5761605B54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E518C62D-768C-4885-9C9D-FD5761605B54}.Release|Any CPU.Build.0 = Release|Any CPU
- {6D3321B5-CF1A-4251-B28D-329EDA6DC278}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {6D3321B5-CF1A-4251-B28D-329EDA6DC278}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {6D3321B5-CF1A-4251-B28D-329EDA6DC278}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {6D3321B5-CF1A-4251-B28D-329EDA6DC278}.Release|Any CPU.Build.0 = Release|Any CPU
{72B37540-A12F-466E-A58F-7BA2B247CB74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{72B37540-A12F-466E-A58F-7BA2B247CB74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{72B37540-A12F-466E-A58F-7BA2B247CB74}.Release|Any CPU.ActiveCfg = Release|Any CPU