From 7ae5d3bc81b5596a05c9d2fee5b29562a80c910d Mon Sep 17 00:00:00 2001 From: Alexandr Sulimov Date: Sat, 17 Jun 2023 14:16:09 +0300 Subject: [PATCH] fix --- MyOffice.Core/Extensions/GuidExtensions.cs | 11 + MyOffice.Core/Extensions/StringExtensions.cs | 26 + MyOffice.Core/Helpers/JsonHelper.cs | 31 + MyOffice.Data.Models/Accounts/Account.cs | 72 +-- .../Accounts/AccountAccess.cs | 16 + .../Accounts/AccountAccountCategory.cs | 10 + .../Accounts/AccountCategory.cs | 12 + .../Accounts/AccountMotion.cs | 17 + MyOffice.Data.Models/Currencies/Currency.cs | 16 + .../Currencies/CurrencyGlobal.cs | 13 + .../Currencies/CurrencyRate.cs | 11 + MyOffice.Data.Models/Motions/MotionAccount.cs | 13 + .../Motions/MotionCategory.cs | 12 + MyOffice.Data.Models/Motions/MotionGlobal.cs | 8 + MyOffice.Data.Models/Users/User.cs | 15 +- .../AccountAccountCategoryRepository.cs | 21 + .../Account/AccountCategoryRepository.cs | 38 ++ .../Account/AccountMotionRepository.cs | 11 + .../Account/AccountRepository.cs | 75 +++ .../IAccountAccountCategoryRepository.cs | 9 + .../Account/IAccountCategoryRepository.cs | 12 + .../Account/IAccountMotionRepository.cs | 8 + .../Account/IAccountyRepository.cs | 14 + .../Currency/CurrencyGlobalRepository.cs | 11 + .../Currency/CurrencyRateRepository.cs | 29 + .../Currency/CurrencyRepository.cs | 41 ++ .../Currency/ICurrencyGlobalRepository.cs | 8 + .../Currency/ICurrencyRateRepository.cs | 10 + .../Currency/ICurrencyRepository.cs | 13 + .../Motion/IMotionCategoryRepository.cs | 12 + .../Motion/IMotionGlobalRepository.cs | 10 + .../Motion/IMotionsRepository.cs | 13 + .../Motion/MotionCategoryRepository.cs | 37 ++ .../Motion/MotionGlobalRepository.cs | 21 + .../Motion/MotionRepository.cs | 46 ++ MyOffice.Data.Repositories/RepositoryBase.cs | 22 +- .../Users/UserExternalRepository.cs | 6 +- .../Users/UserRepository.cs | 6 +- MyOffice.DbContext/AppDbContext.cs | 92 ++- MyOffice.DbContext/RepositoryInitializer.cs | 27 +- .../20230429063332_Host.Designer.cs | 386 +++++++++++ .../Migrations/20230429063332_Host.cs | 217 +++++++ .../20230429090658_user_currency.Designer.cs | 407 ++++++++++++ .../20230429090658_user_currency.cs | 61 ++ ...30429092104_currency_shortname.Designer.cs | 403 ++++++++++++ .../20230429092104_currency_shortname.cs | 29 + ...0429092950_gcurrency_shortname.Designer.cs | 403 ++++++++++++ .../20230429092950_gcurrency_shortname.cs | 40 ++ ...0230430103617_account_category.Designer.cs | 467 ++++++++++++++ .../20230430103617_account_category.cs | 74 +++ ...0230601100601_CurrencyQuantity.Designer.cs | 473 ++++++++++++++ .../20230601100601_CurrencyQuantity.cs | 40 ++ ...230601100833_CurrencyQuantity2.Designer.cs | 473 ++++++++++++++ .../20230601100833_CurrencyQuantity2.cs | 40 ++ ...230601121013_AccountCategories.Designer.cs | 491 ++++++++++++++ .../20230601121013_AccountCategories.cs | 171 +++++ ...609062452_AccountCategoriesFix.Designer.cs | 491 ++++++++++++++ .../20230609062452_AccountCategoriesFix.cs | 66 ++ .../20230611145152_Motion.Designer.cs | 606 +++++++++++++++++ .../Migrations/20230611145152_Motion.cs | 213 ++++++ ...230614175616_MotionCategoryFix.Designer.cs | 609 ++++++++++++++++++ .../20230614175616_MotionCategoryFix.cs | 38 ++ ...30614181358_MotionCategoryFix2.Designer.cs | 606 +++++++++++++++++ .../20230614181358_MotionCategoryFix2.cs | 60 ++ ...30614183224_MotionCategoryFix3.Designer.cs | 608 +++++++++++++++++ .../20230614183224_MotionCategoryFix3.cs | 60 ++ .../Migrations/AppDbContextModelSnapshot.cs | 488 +++++++++++++- MyOffice.SPA/angular.json | 3 +- MyOffice.SPA/package.json | 8 +- MyOffice.SPA/src/app/api-routes.ts | 35 +- MyOffice.SPA/src/app/app.module.ts | 2 + .../signin/signin.component.html | 4 +- .../authentication/signin/signin.component.ts | 12 +- MyOffice.SPA/src/app/config.external-login.ts | 1 - MyOffice.SPA/src/app/core/core.module.ts | 2 + .../update.date.http.interceptor .ts | 43 ++ .../src/app/core/models/user-profile.model.ts | 1 + .../src/app/core/models/user.model.ts | 3 +- .../src/app/core/service/auth.service.ts | 2 +- .../core/validators/atleastone.validator.ts | 21 + .../validators/atleastonenumber.validator.ts | 24 + .../src/app/layout/header/header.component.ts | 2 +- .../src/app/layout/sidebar/sidebar-items.ts | 96 ++- .../app/layout/sidebar/sidebar.component.ts | 24 +- .../app/layout/sidebar/sidebar.metadata.ts | 1 + .../app/model/account.accessRight.model.ts | 8 + .../src/app/model/account.category.model.ts | 5 + .../src/app/model/account.detailed.model.ts | 6 + MyOffice.SPA/src/app/model/account.model.ts | 11 + MyOffice.SPA/src/app/model/account.motion.ts | 8 + MyOffice.SPA/src/app/model/currency.model.ts | 11 + .../src/app/model/motion.category.model.ts | 5 + MyOffice.SPA/src/app/model/motion.model.ts | 7 + .../app/pages/accounts/account.component.html | 30 + .../app/pages/accounts/account.component.scss | 0 .../app/pages/accounts/account.component.ts | 91 +++ .../app/pages/accounts/motion.component.html | 55 ++ .../app/pages/accounts/motion.component.scss | 0 .../app/pages/accounts/motion.component.ts | 90 +++ .../src/app/pages/pages-routing.module.ts | 30 + MyOffice.SPA/src/app/pages/pages.module.ts | 63 +- .../account/account.category.component.html | 47 ++ .../account/account.category.component.scss | 0 .../account/account.category.component.ts | 122 ++++ .../settings/account/account.component.html | 88 +++ .../settings/account/account.component.scss | 0 .../settings/account/account.component.ts | 109 ++++ .../account/add.account.component.html | 67 ++ .../account/add.account.component.scss | 0 .../settings/account/add.account.component.ts | 90 +++ .../account/edit.account.component.html | 103 +++ .../account/edit.account.component.scss | 0 .../account/edit.account.component.ts | 104 +++ .../currency/connect.currency.component.html | 94 +++ .../currency/connect.currency.component.scss | 0 .../currency/connect.currency.component.ts | 78 +++ .../settings/currency/currency.component.html | 73 +++ .../settings/currency/currency.component.scss | 0 .../settings/currency/currency.component.ts | 90 +++ .../currency/rate.currency.component.html | 84 +++ .../currency/rate.currency.component.scss | 0 .../currency/rate.currency.component.ts | 79 +++ .../motion/edit.motion.component.html | 45 ++ .../motion/edit.motion.component.scss | 0 .../settings/motion/edit.motion.component.ts | 74 +++ .../motion/motion.category.component.html | 47 ++ .../motion/motion.category.component.scss | 0 .../motion/motion.category.component.ts | 122 ++++ .../settings/motion/motion.component.html | 54 ++ .../settings/motion/motion.component.scss | 0 .../pages/settings/motion/motion.component.ts | 98 +++ .../user-profile/user-profile.component.html | 33 +- .../user-profile/user-profile.component.ts | 51 +- .../app/services/account.category.service.ts | 24 + .../src/app/services/currency.service.ts | 24 + .../src/app/services/motion.service.ts | 35 + .../src/assets/scss/ui/_expansion.scss | 22 +- MyOffice.SPA/src/proxy.conf.js | 2 +- MyOffice.SPA/src/styles.scss | 41 ++ MyOffice.Services/Account/AccountService.cs | 318 +++++++++ .../Account/Domain/AccountAdd.cs | 9 + .../Account/Domain/AccountAddResult.cs | 10 + .../Domain/AccountCategoryRemoveResult.cs | 10 + .../Account/Domain/AccountEdit.cs | 9 + .../Account/Domain/AccountEditResult.cs | 10 + .../Account/Domain/AccountMotionAdd.cs | 11 + .../Account/Domain/AccountMotionAddResult.cs | 8 + MyOffice.Services/Currency/CurrencyService.cs | 94 +++ .../Currency/Domain/AddCurrencyStatus.cs | 16 + .../Domain/MotionCategoryRemoveResult.cs | 10 + MyOffice.Services/Motion/MotionService.cs | 136 ++++ .../Validators/ContextValidator.cs | 6 + MyOffice.Shared/Configuration.cs | 23 +- MyOffice.Web/Controllers/AccountController.cs | 50 ++ .../Controllers/CurrencyController.cs | 95 +++ MyOffice.Web/Controllers/GeneralController.cs | 30 + MyOffice.Web/Controllers/MotionController.cs | 122 ++++ .../Controllers/SettingsAccountController.cs | 178 +++++ MyOffice.Web/Controllers/UserController.cs | 4 +- .../Configure/IdentityServerConfig.cs | 2 +- .../Identity/Domain/ApplicationUser.cs | 1 + .../Identity/Repositories/UserStore.cs | 4 + .../Models/Account/AccessRightsViewModel.cs | 27 + .../Account/AccountCategoryViewModel.cs | 29 + .../Account/AccountDetailedViewModel.cs | 21 + .../Models/Account/AccountEditRequestModel.cs | 13 + .../Models/Account/AccountViewModel.cs | 46 ++ .../AccountMotion/AccountMotionViewModel.cs | 39 ++ .../Models/Currency/CurrencyAddModel.cs | 19 + .../Currency/CurrencyGlobalViewModel.cs | 27 + .../Models/Currency/CurrencyViewModel.cs | 32 + .../Models/Motion/MotionCategoryViewModel.cs | 33 + MyOffice.Web/Models/Motion/MotionEditModel.cs | 8 + MyOffice.Web/Models/Motion/MotionViewModel.cs | 33 + MyOffice.Web/Models/User/UserViewModel.cs | 25 + MyOffice.Web/Program.cs | 66 +- MyOffice.Web/Properties/launchSettings.json | 20 +- MyOffice.Web/appsettings.json | 2 +- MyOffice.Web/rsa_key.pem | 27 + MyOffice.Web/web.config | 2 +- 180 files changed, 12932 insertions(+), 192 deletions(-) create mode 100644 MyOffice.Core/Helpers/JsonHelper.cs create mode 100644 MyOffice.Data.Models/Accounts/AccountAccess.cs create mode 100644 MyOffice.Data.Models/Accounts/AccountAccountCategory.cs create mode 100644 MyOffice.Data.Models/Accounts/AccountCategory.cs create mode 100644 MyOffice.Data.Models/Accounts/AccountMotion.cs create mode 100644 MyOffice.Data.Models/Currencies/Currency.cs create mode 100644 MyOffice.Data.Models/Currencies/CurrencyGlobal.cs create mode 100644 MyOffice.Data.Models/Currencies/CurrencyRate.cs create mode 100644 MyOffice.Data.Models/Motions/MotionAccount.cs create mode 100644 MyOffice.Data.Models/Motions/MotionCategory.cs create mode 100644 MyOffice.Data.Models/Motions/MotionGlobal.cs create mode 100644 MyOffice.Data.Repositories/Account/AccountAccountCategoryRepository.cs create mode 100644 MyOffice.Data.Repositories/Account/AccountCategoryRepository.cs create mode 100644 MyOffice.Data.Repositories/Account/AccountMotionRepository.cs create mode 100644 MyOffice.Data.Repositories/Account/AccountRepository.cs create mode 100644 MyOffice.Data.Repositories/Account/IAccountAccountCategoryRepository.cs create mode 100644 MyOffice.Data.Repositories/Account/IAccountCategoryRepository.cs create mode 100644 MyOffice.Data.Repositories/Account/IAccountMotionRepository.cs create mode 100644 MyOffice.Data.Repositories/Account/IAccountyRepository.cs create mode 100644 MyOffice.Data.Repositories/Currency/CurrencyGlobalRepository.cs create mode 100644 MyOffice.Data.Repositories/Currency/CurrencyRateRepository.cs create mode 100644 MyOffice.Data.Repositories/Currency/CurrencyRepository.cs create mode 100644 MyOffice.Data.Repositories/Currency/ICurrencyGlobalRepository.cs create mode 100644 MyOffice.Data.Repositories/Currency/ICurrencyRateRepository.cs create mode 100644 MyOffice.Data.Repositories/Currency/ICurrencyRepository.cs create mode 100644 MyOffice.Data.Repositories/Motion/IMotionCategoryRepository.cs create mode 100644 MyOffice.Data.Repositories/Motion/IMotionGlobalRepository.cs create mode 100644 MyOffice.Data.Repositories/Motion/IMotionsRepository.cs create mode 100644 MyOffice.Data.Repositories/Motion/MotionCategoryRepository.cs create mode 100644 MyOffice.Data.Repositories/Motion/MotionGlobalRepository.cs create mode 100644 MyOffice.Data.Repositories/Motion/MotionRepository.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230429063332_Host.Designer.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230429063332_Host.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230429090658_user_currency.Designer.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230429090658_user_currency.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230429092104_currency_shortname.Designer.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230429092104_currency_shortname.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230429092950_gcurrency_shortname.Designer.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230429092950_gcurrency_shortname.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230430103617_account_category.Designer.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230430103617_account_category.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230601100601_CurrencyQuantity.Designer.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230601100601_CurrencyQuantity.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230601100833_CurrencyQuantity2.Designer.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230601100833_CurrencyQuantity2.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230601121013_AccountCategories.Designer.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230601121013_AccountCategories.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230609062452_AccountCategoriesFix.Designer.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230609062452_AccountCategoriesFix.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230611145152_Motion.Designer.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230611145152_Motion.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230614175616_MotionCategoryFix.Designer.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230614175616_MotionCategoryFix.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230614181358_MotionCategoryFix2.Designer.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230614181358_MotionCategoryFix2.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230614183224_MotionCategoryFix3.Designer.cs create mode 100644 MyOffice.Migration.Postgres/Migrations/20230614183224_MotionCategoryFix3.cs create mode 100644 MyOffice.SPA/src/app/core/interceptor/update.date.http.interceptor .ts create mode 100644 MyOffice.SPA/src/app/core/validators/atleastone.validator.ts create mode 100644 MyOffice.SPA/src/app/core/validators/atleastonenumber.validator.ts create mode 100644 MyOffice.SPA/src/app/model/account.accessRight.model.ts create mode 100644 MyOffice.SPA/src/app/model/account.category.model.ts create mode 100644 MyOffice.SPA/src/app/model/account.detailed.model.ts create mode 100644 MyOffice.SPA/src/app/model/account.model.ts create mode 100644 MyOffice.SPA/src/app/model/account.motion.ts create mode 100644 MyOffice.SPA/src/app/model/currency.model.ts create mode 100644 MyOffice.SPA/src/app/model/motion.category.model.ts create mode 100644 MyOffice.SPA/src/app/model/motion.model.ts create mode 100644 MyOffice.SPA/src/app/pages/accounts/account.component.html create mode 100644 MyOffice.SPA/src/app/pages/accounts/account.component.scss create mode 100644 MyOffice.SPA/src/app/pages/accounts/account.component.ts create mode 100644 MyOffice.SPA/src/app/pages/accounts/motion.component.html create mode 100644 MyOffice.SPA/src/app/pages/accounts/motion.component.scss create mode 100644 MyOffice.SPA/src/app/pages/accounts/motion.component.ts create mode 100644 MyOffice.SPA/src/app/pages/settings/account/account.category.component.html create mode 100644 MyOffice.SPA/src/app/pages/settings/account/account.category.component.scss create mode 100644 MyOffice.SPA/src/app/pages/settings/account/account.category.component.ts create mode 100644 MyOffice.SPA/src/app/pages/settings/account/account.component.html create mode 100644 MyOffice.SPA/src/app/pages/settings/account/account.component.scss create mode 100644 MyOffice.SPA/src/app/pages/settings/account/account.component.ts create mode 100644 MyOffice.SPA/src/app/pages/settings/account/add.account.component.html create mode 100644 MyOffice.SPA/src/app/pages/settings/account/add.account.component.scss create mode 100644 MyOffice.SPA/src/app/pages/settings/account/add.account.component.ts create mode 100644 MyOffice.SPA/src/app/pages/settings/account/edit.account.component.html create mode 100644 MyOffice.SPA/src/app/pages/settings/account/edit.account.component.scss create mode 100644 MyOffice.SPA/src/app/pages/settings/account/edit.account.component.ts create mode 100644 MyOffice.SPA/src/app/pages/settings/currency/connect.currency.component.html create mode 100644 MyOffice.SPA/src/app/pages/settings/currency/connect.currency.component.scss create mode 100644 MyOffice.SPA/src/app/pages/settings/currency/connect.currency.component.ts create mode 100644 MyOffice.SPA/src/app/pages/settings/currency/currency.component.html create mode 100644 MyOffice.SPA/src/app/pages/settings/currency/currency.component.scss create mode 100644 MyOffice.SPA/src/app/pages/settings/currency/currency.component.ts create mode 100644 MyOffice.SPA/src/app/pages/settings/currency/rate.currency.component.html create mode 100644 MyOffice.SPA/src/app/pages/settings/currency/rate.currency.component.scss create mode 100644 MyOffice.SPA/src/app/pages/settings/currency/rate.currency.component.ts create mode 100644 MyOffice.SPA/src/app/pages/settings/motion/edit.motion.component.html create mode 100644 MyOffice.SPA/src/app/pages/settings/motion/edit.motion.component.scss create mode 100644 MyOffice.SPA/src/app/pages/settings/motion/edit.motion.component.ts create mode 100644 MyOffice.SPA/src/app/pages/settings/motion/motion.category.component.html create mode 100644 MyOffice.SPA/src/app/pages/settings/motion/motion.category.component.scss create mode 100644 MyOffice.SPA/src/app/pages/settings/motion/motion.category.component.ts create mode 100644 MyOffice.SPA/src/app/pages/settings/motion/motion.component.html create mode 100644 MyOffice.SPA/src/app/pages/settings/motion/motion.component.scss create mode 100644 MyOffice.SPA/src/app/pages/settings/motion/motion.component.ts create mode 100644 MyOffice.SPA/src/app/services/account.category.service.ts create mode 100644 MyOffice.SPA/src/app/services/currency.service.ts create mode 100644 MyOffice.SPA/src/app/services/motion.service.ts create mode 100644 MyOffice.Services/Account/AccountService.cs create mode 100644 MyOffice.Services/Account/Domain/AccountAdd.cs create mode 100644 MyOffice.Services/Account/Domain/AccountAddResult.cs create mode 100644 MyOffice.Services/Account/Domain/AccountCategoryRemoveResult.cs create mode 100644 MyOffice.Services/Account/Domain/AccountEdit.cs create mode 100644 MyOffice.Services/Account/Domain/AccountEditResult.cs create mode 100644 MyOffice.Services/Account/Domain/AccountMotionAdd.cs create mode 100644 MyOffice.Services/Account/Domain/AccountMotionAddResult.cs create mode 100644 MyOffice.Services/Currency/CurrencyService.cs create mode 100644 MyOffice.Services/Currency/Domain/AddCurrencyStatus.cs create mode 100644 MyOffice.Services/Motion/Domain/MotionCategoryRemoveResult.cs create mode 100644 MyOffice.Services/Motion/MotionService.cs create mode 100644 MyOffice.Services/Validators/ContextValidator.cs create mode 100644 MyOffice.Web/Controllers/AccountController.cs create mode 100644 MyOffice.Web/Controllers/CurrencyController.cs create mode 100644 MyOffice.Web/Controllers/GeneralController.cs create mode 100644 MyOffice.Web/Controllers/MotionController.cs create mode 100644 MyOffice.Web/Controllers/SettingsAccountController.cs create mode 100644 MyOffice.Web/Models/Account/AccessRightsViewModel.cs create mode 100644 MyOffice.Web/Models/Account/AccountCategoryViewModel.cs create mode 100644 MyOffice.Web/Models/Account/AccountDetailedViewModel.cs create mode 100644 MyOffice.Web/Models/Account/AccountEditRequestModel.cs create mode 100644 MyOffice.Web/Models/Account/AccountViewModel.cs create mode 100644 MyOffice.Web/Models/AccountMotion/AccountMotionViewModel.cs create mode 100644 MyOffice.Web/Models/Currency/CurrencyAddModel.cs create mode 100644 MyOffice.Web/Models/Currency/CurrencyGlobalViewModel.cs create mode 100644 MyOffice.Web/Models/Currency/CurrencyViewModel.cs create mode 100644 MyOffice.Web/Models/Motion/MotionCategoryViewModel.cs create mode 100644 MyOffice.Web/Models/Motion/MotionEditModel.cs create mode 100644 MyOffice.Web/Models/Motion/MotionViewModel.cs create mode 100644 MyOffice.Web/Models/User/UserViewModel.cs create mode 100644 MyOffice.Web/rsa_key.pem diff --git a/MyOffice.Core/Extensions/GuidExtensions.cs b/MyOffice.Core/Extensions/GuidExtensions.cs index 65234b4..712799c 100644 --- a/MyOffice.Core/Extensions/GuidExtensions.cs +++ b/MyOffice.Core/Extensions/GuidExtensions.cs @@ -6,4 +6,15 @@ public static class GuidExtensions { return guid.ToString().EqualsIgnoreCase(str); } + + public static string ToShort(this Guid guid) + { + /*string encoded = Convert.ToBase64String(guid.ToByteArray()); + encoded = encoded + .Replace("/", "_") + .Replace("+", "-"); + + return encoded.Substring(0, 22);*/ + return guid.ToString("N"); + } } \ No newline at end of file diff --git a/MyOffice.Core/Extensions/StringExtensions.cs b/MyOffice.Core/Extensions/StringExtensions.cs index ae7e772..e55934b 100644 --- a/MyOffice.Core/Extensions/StringExtensions.cs +++ b/MyOffice.Core/Extensions/StringExtensions.cs @@ -1,5 +1,7 @@ namespace MyOffice.Core.Extensions; +using Microsoft.Extensions.Logging; + public static class StringExtensions { public static bool IsMissing(this string? str) @@ -26,4 +28,28 @@ public static class StringExtensions { return true.ToString().Equals(str, StringComparison.OrdinalIgnoreCase) || defaultValue; } + + public static Guid AsGuid(this string str) + { + /*str = str + .Replace("_", "/") + .Replace("-", "+"); + byte[] buffer = Convert.FromBase64String(str + "=="); + return new Guid(buffer);*/ + return Guid.Parse(str); + } + + public static Guid? AsGuidNull(this string str) + { + /*str = str + .Replace("_", "/") + .Replace("-", "+"); + byte[] buffer = Convert.FromBase64String(str + "=="); + return new Guid(buffer);*/ + if (Guid.TryParse(str, out var guid)) + { + return guid; + } + return null; + } } \ No newline at end of file diff --git a/MyOffice.Core/Helpers/JsonHelper.cs b/MyOffice.Core/Helpers/JsonHelper.cs new file mode 100644 index 0000000..100f7bc --- /dev/null +++ b/MyOffice.Core/Helpers/JsonHelper.cs @@ -0,0 +1,31 @@ +namespace MyOffice.Core.Helpers +{ + using System.Text.Json; + using System.Text.Json.Serialization; + + public static class JsonHelper + { + public static string ToJson(this object entity, JsonSerializerOptions? options = null) + { + options ??= new JsonSerializerOptions + { + MaxDepth = 0, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + ReferenceHandler = ReferenceHandler.IgnoreCycles, + WriteIndented = true, + }; + return JsonSerializer.Serialize(entity, options); + } + } + + /*public class CustomIgnoreReferenceHandler : ReferenceHandler + { + //public CustomIgnoreReferenceHandler() => HandlingStrategy = ReferenceHandlingStrategy.IgnoreCycles; + public CustomIgnoreReferenceHandler() + { + new HandlingStrategy { } = true; + } + + public override ReferenceResolver CreateResolver() => new IgnoreReferenceResolver(); + }*/ +} diff --git a/MyOffice.Data.Models/Accounts/Account.cs b/MyOffice.Data.Models/Accounts/Account.cs index e1068b4..cb5d404 100644 --- a/MyOffice.Data.Models/Accounts/Account.cs +++ b/MyOffice.Data.Models/Accounts/Account.cs @@ -1,70 +1,22 @@ -namespace MyOffice.Data.Models.Account; +namespace MyOffice.Data.Models.Accounts; -using MyOffice.Data.Models.Users; - -public class CurrencyGlobal -{ - public string Id { get; set; } - public string Name { get; set; } - public string ShortName { get; set; } - public IEnumerable? Currencies { get; set; } - public IEnumerable? Accounts { get; set; } -} - -public class Currency -{ - public Guid Id { get; set; } - public string CurrencyGlobalId { get; set; } - public CurrencyGlobal? CurrencyGlobal { get; set; } - public Guid UserId { get; set; } - public User? User { get; set; } - - public string Name { get; set; } - public string ShortName { get; set; } - public IEnumerable? Rates { get; set; } -} - -public class CurrencyRate -{ - public int Id { get; set; } - public Guid CurrencyId { get; set; } - public Currency? Currency { get; set; } - public DateTime DateTime { get; set; } - public decimal Rate { get; set; } -} +using Currencies; public class Account { public Guid Id { get; set; } - public string CurrencyGlobalId { get; set; } + public string CurrencyGlobalId { get; set; } = null!; public CurrencyGlobal? CurrencyGlobal { get; set; } - public string Name { get; set; } - public IEnumerable AccessRights { get; set; } - public IEnumerable Motions { get; set; } + public string Name { get; set; } = null!; + public IEnumerable? AccessRights { get; set; } + public IEnumerable? Motions { get; set; } + public IEnumerable? Categories { get; set; } } -public class AccountAccess +public class AccountDetailed { - public int Id { get; set; } - public Guid AccountId { get; set; } - public Account? Account { get; set; } - public Guid UserId { get; set; } - public User? User { get; set; } - - public bool IsAllowRead { get; set; } - public bool IsAllowWrite { get; set; } - public bool IsAllowManage { get; set; } -} - -public class AccountMotion -{ - public long Id { get; set; } - public DateTime CreatedOn { get; set; } - public DateTime DateTime { get; set; } - public Guid AccountId { get; set; } - public Account? Account { get; set; } - public Guid UserId { get; set; } - public User? User { get; set; } - public decimal AmountIn { get; set; } - public decimal AmountOut { get; set; } + public Account Account { get; set; } = null!; + public decimal TotalPlus { get; set; } + public decimal TotalMinus { get; set; } + public decimal Rest => TotalPlus - TotalMinus; } \ No newline at end of file diff --git a/MyOffice.Data.Models/Accounts/AccountAccess.cs b/MyOffice.Data.Models/Accounts/AccountAccess.cs new file mode 100644 index 0000000..9514ac3 --- /dev/null +++ b/MyOffice.Data.Models/Accounts/AccountAccess.cs @@ -0,0 +1,16 @@ +namespace MyOffice.Data.Models.Accounts; + +using MyOffice.Data.Models.Users; + +public class AccountAccess +{ + public int Id { get; set; } + public Guid AccountId { get; set; } + public Account? Account { get; set; } + public Guid UserId { get; set; } + public User? User { get; set; } + + public bool IsAllowRead { get; set; } + public bool IsAllowWrite { get; set; } + public bool IsAllowManage { get; set; } +} \ No newline at end of file diff --git a/MyOffice.Data.Models/Accounts/AccountAccountCategory.cs b/MyOffice.Data.Models/Accounts/AccountAccountCategory.cs new file mode 100644 index 0000000..3ede78a --- /dev/null +++ b/MyOffice.Data.Models/Accounts/AccountAccountCategory.cs @@ -0,0 +1,10 @@ +namespace MyOffice.Data.Models.Accounts; + +public class AccountAccountCategory +{ + public int Id { get; set; } + public Guid AccountId { get; set; } + public Account Account { get; set; } = null!; + public Guid CategoryId { get; set; } + public AccountCategory Category { get; set; } = null!; +} \ No newline at end of file diff --git a/MyOffice.Data.Models/Accounts/AccountCategory.cs b/MyOffice.Data.Models/Accounts/AccountCategory.cs new file mode 100644 index 0000000..dc445b9 --- /dev/null +++ b/MyOffice.Data.Models/Accounts/AccountCategory.cs @@ -0,0 +1,12 @@ +namespace MyOffice.Data.Models.Accounts; + +using MyOffice.Data.Models.Users; + +public class AccountCategory +{ + public Guid Id { get; set; } + public Guid UserId { get; set; } + public User? User { get; set; } + public string Name { get; set; } = null!; + public IEnumerable? Accounts { get; set; } +} \ No newline at end of file diff --git a/MyOffice.Data.Models/Accounts/AccountMotion.cs b/MyOffice.Data.Models/Accounts/AccountMotion.cs new file mode 100644 index 0000000..750b635 --- /dev/null +++ b/MyOffice.Data.Models/Accounts/AccountMotion.cs @@ -0,0 +1,17 @@ +namespace MyOffice.Data.Models.Accounts; + +using MyOffice.Data.Models.Motions; + +public class AccountMotion +{ + public long Id { get; set; } + public DateTime CreatedOn { get; set; } + public DateTime DateTime { get; set; } + public int MotionId { get; set; } + public MotionAccount Motion { get; set; } = null!; + public Guid AccountId { get; set; } + public Account Account { get; set; } = null!; + public string? Description { get; set; } + public decimal AmountPlus { get; set; } + public decimal AmountMinus { get; set; } +} diff --git a/MyOffice.Data.Models/Currencies/Currency.cs b/MyOffice.Data.Models/Currencies/Currency.cs new file mode 100644 index 0000000..ce67776 --- /dev/null +++ b/MyOffice.Data.Models/Currencies/Currency.cs @@ -0,0 +1,16 @@ +namespace MyOffice.Data.Models.Currencies; + +using MyOffice.Data.Models.Users; + +public class Currency +{ + public Guid Id { get; set; } + public string CurrencyGlobalId { get; set; } = null!; + public CurrencyGlobal? CurrencyGlobal { get; set; } + public Guid UserId { get; set; } + public User? User { get; set; } + + public string Name { get; set; } = null!; + public string ShortName { get; set; } = null!; + public IEnumerable? Rates { get; set; } +} \ No newline at end of file diff --git a/MyOffice.Data.Models/Currencies/CurrencyGlobal.cs b/MyOffice.Data.Models/Currencies/CurrencyGlobal.cs new file mode 100644 index 0000000..87df8d9 --- /dev/null +++ b/MyOffice.Data.Models/Currencies/CurrencyGlobal.cs @@ -0,0 +1,13 @@ +namespace MyOffice.Data.Models.Currencies; + +using MyOffice.Data.Models.Accounts; + +public class CurrencyGlobal +{ + public string Id { get; set; } = null!; + public string Name { get; set; } = null!; + public string Symbol { get; set; } = null!; + public int DefaultQuantity { get; set; } + public IEnumerable? Currencies { get; set; } + public IEnumerable? Accounts { get; set; } +} \ No newline at end of file diff --git a/MyOffice.Data.Models/Currencies/CurrencyRate.cs b/MyOffice.Data.Models/Currencies/CurrencyRate.cs new file mode 100644 index 0000000..9df18be --- /dev/null +++ b/MyOffice.Data.Models/Currencies/CurrencyRate.cs @@ -0,0 +1,11 @@ +namespace MyOffice.Data.Models.Currencies; + +public class CurrencyRate +{ + public int Id { get; set; } + public Guid CurrencyId { get; set; } + public Currency? Currency { get; set; } + public DateTime DateTime { get; set; } + public int Quantity { get; set; } + public decimal Rate { get; set; } +} \ No newline at end of file diff --git a/MyOffice.Data.Models/Motions/MotionAccount.cs b/MyOffice.Data.Models/Motions/MotionAccount.cs new file mode 100644 index 0000000..de1f480 --- /dev/null +++ b/MyOffice.Data.Models/Motions/MotionAccount.cs @@ -0,0 +1,13 @@ +namespace MyOffice.Data.Models.Motions; + +using Accounts; + +public class MotionAccount +{ + public int Id { get; set; } + public Guid CategoryId { get; set; } + public MotionCategory Category { get; set; } = null!; + public Guid MotionGlobalId { get; set; } + public MotionGlobal MotionGlobal { get; set; } = null!; + public IEnumerable Motions { get; set; } = null!; +} \ No newline at end of file diff --git a/MyOffice.Data.Models/Motions/MotionCategory.cs b/MyOffice.Data.Models/Motions/MotionCategory.cs new file mode 100644 index 0000000..c5d9119 --- /dev/null +++ b/MyOffice.Data.Models/Motions/MotionCategory.cs @@ -0,0 +1,12 @@ +namespace MyOffice.Data.Models.Motions; + +using Users; + +public class MotionCategory +{ + public Guid Id { get; set; } + public Guid UserId { get; set; } + public User User { get; set; } = null!; + public string Name { get; set; } = null!; + public IEnumerable Motions { get; set; } = null!; +} \ No newline at end of file diff --git a/MyOffice.Data.Models/Motions/MotionGlobal.cs b/MyOffice.Data.Models/Motions/MotionGlobal.cs new file mode 100644 index 0000000..8d72678 --- /dev/null +++ b/MyOffice.Data.Models/Motions/MotionGlobal.cs @@ -0,0 +1,8 @@ +namespace MyOffice.Data.Models.Motions; + +public class MotionGlobal +{ + public Guid Id { get; set; } + public string Name { get; set; } = null!; + public IEnumerable Motions { get; set; } = null!; +} \ No newline at end of file diff --git a/MyOffice.Data.Models/Users/User.cs b/MyOffice.Data.Models/Users/User.cs index 7d72731..330bf79 100644 --- a/MyOffice.Data.Models/Users/User.cs +++ b/MyOffice.Data.Models/Users/User.cs @@ -1,9 +1,16 @@ namespace MyOffice.Data.Models.Users; -using Account; +using Accounts; +using Currencies; +using Motions; public class User { + public User() + { + CurrencyId = "USD"; + } + public Guid Id { get; set; } public string UserName { get; set; } = null!; public string Email { get; set; } = null!; @@ -15,5 +22,11 @@ public class User public bool IsEmailConfirmed { get; set; } public IEnumerable? UserClaims { get; set; } + public string CurrencyId { get; set; } + public CurrencyGlobal? Currency { get; set; } public IEnumerable? Currencies { get; set; } + public IEnumerable? AccountAccess { get; set; } + public IEnumerable? AccountMotions { get; set; } + public IEnumerable? AccountCategories { get; set; } + public IEnumerable? MotionCategories { get; set; } } \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Account/AccountAccountCategoryRepository.cs b/MyOffice.Data.Repositories/Account/AccountAccountCategoryRepository.cs new file mode 100644 index 0000000..a9d6791 --- /dev/null +++ b/MyOffice.Data.Repositories/Account/AccountAccountCategoryRepository.cs @@ -0,0 +1,21 @@ +namespace MyOffice.Data.Repositories.Account; + +using Microsoft.EntityFrameworkCore; +using Models.Accounts; + +public class AccountAccountCategoryRepository : AppRepository, IAccountAccountCategoryRepository +{ + public List Get(Guid userId, Guid accountId, Guid categoryId) + { + return _context.AccountAccountCategories + .Include(x => x.Account) + .Include(x => x.Category) + .Where(x => x.AccountId == accountId && x.CategoryId == categoryId && x.Category.UserId == userId) + .ToList(); + } + + public bool Remove(AccountAccountCategory accountAccountCategory) + { + return RemoveBase(accountAccountCategory) > 0; + } +} \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Account/AccountCategoryRepository.cs b/MyOffice.Data.Repositories/Account/AccountCategoryRepository.cs new file mode 100644 index 0000000..bccedc7 --- /dev/null +++ b/MyOffice.Data.Repositories/Account/AccountCategoryRepository.cs @@ -0,0 +1,38 @@ +namespace MyOffice.Data.Repositories.Account; + +using Microsoft.EntityFrameworkCore; +using Models.Accounts; +using MyOffice.Data.Repositories; + +public class AccountCategoryRepository : AppRepository, IAccountCategoryRepository +{ + public List GetAll(Guid userId) + { + return _context.AccountCategories + .Include(x => x.Accounts) + .Where(x => x.UserId == userId) + .ToList(); + } + + public bool Add(AccountCategory accountCategory) + { + return AddBase(accountCategory) > 0; + } + + public AccountCategory? Get(Guid userId, Guid id) + { + return _context.AccountCategories + .Include(x => x.Accounts) + .FirstOrDefault(x => x.Id == id && x.UserId == userId); + } + + public bool Update(AccountCategory accountCategory) + { + return UpdateBase(accountCategory) > 0; + } + + public bool Remove(AccountCategory accountCategory) + { + return RemoveBase(accountCategory) > 0; + } +} \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Account/AccountMotionRepository.cs b/MyOffice.Data.Repositories/Account/AccountMotionRepository.cs new file mode 100644 index 0000000..542468c --- /dev/null +++ b/MyOffice.Data.Repositories/Account/AccountMotionRepository.cs @@ -0,0 +1,11 @@ +namespace MyOffice.Data.Repositories.Account; + +using Models.Accounts; + +public class AccountMotionRepository : AppRepository, IAccountMotionRepository +{ + public bool Add(AccountMotion accountMotion) + { + return AddBase(accountMotion) > 0; + } +} \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Account/AccountRepository.cs b/MyOffice.Data.Repositories/Account/AccountRepository.cs new file mode 100644 index 0000000..4d08dde --- /dev/null +++ b/MyOffice.Data.Repositories/Account/AccountRepository.cs @@ -0,0 +1,75 @@ +namespace MyOffice.Data.Repositories.Account; + +using Microsoft.EntityFrameworkCore; +using Models.Accounts; +using MyOffice.Data.Repositories; + +public class AccountRepository : AppRepository, IAccountRepository +{ + public List GetAll(Guid userId) + { + return _context.Accounts! + .Include(x => x.CurrencyGlobal) + .Include(x => x.Categories)! + .ThenInclude(x => x.Category) + .Include(x => x.AccessRights)! + .ThenInclude(x => x.User) + .Where(x => x.AccessRights!.Any(a => a.UserId == userId)) + .ToList(); + } + + public List GetByCategory(Guid userId, Guid categoryId) + { + return _context.Accounts! + .Include(x => x.CurrencyGlobal) + .Include(x => x.Categories)! + .ThenInclude(x => x.Category) + .Include(x => x.AccessRights)! + .ThenInclude(x => x.User) + .Where(x => x.Categories!.Any(c => c.CategoryId == categoryId) && x.AccessRights!.Any(a => a.UserId == userId)) + .ToList(); + } + + public List GetByCategoryDetailed(Guid userId, Guid categoryId) + { + return _context.Accounts! + .Include(x => x.CurrencyGlobal) + .Include(x => x.Categories)! + .ThenInclude(x => x.Category) + .Include(x => x.AccessRights)! + .ThenInclude(x => x.User) + .Where(x => x.Categories!.Any(c => c.CategoryId == categoryId) && x.AccessRights!.Any(a => a.UserId == userId)) + .Select(x => new AccountDetailed + { + Account = x, + TotalPlus = x.Motions!.Sum(m => m.AmountPlus), + TotalMinus = x.Motions!.Sum(m => m.AmountPlus), + }) + .ToList(); + } + + public bool Add(Account account) + { + return AddBase(account) > 0; + } + + public Account? Get(Guid userId, Guid id) + { + return _context.Accounts! + .Include(x => x.Categories)! + .ThenInclude(x => x.Category) + .Include(x => x.AccessRights)! + .ThenInclude(x => x.User) + .FirstOrDefault(x => x.Id == id && x.AccessRights!.Any(r => r.UserId == userId)); + } + + public bool Update(Account account) + { + return UpdateBase(account) > 0; + } + + public bool Remove(Account account) + { + return RemoveBase(account) > 0; + } +} \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Account/IAccountAccountCategoryRepository.cs b/MyOffice.Data.Repositories/Account/IAccountAccountCategoryRepository.cs new file mode 100644 index 0000000..0d2470b --- /dev/null +++ b/MyOffice.Data.Repositories/Account/IAccountAccountCategoryRepository.cs @@ -0,0 +1,9 @@ +namespace MyOffice.Data.Repositories.Account; + +using Models.Accounts; + +public interface IAccountAccountCategoryRepository +{ + List Get(Guid userId, Guid accountId, Guid categoryId); + bool Remove(AccountAccountCategory accountAccountCategory); +} \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Account/IAccountCategoryRepository.cs b/MyOffice.Data.Repositories/Account/IAccountCategoryRepository.cs new file mode 100644 index 0000000..61315ad --- /dev/null +++ b/MyOffice.Data.Repositories/Account/IAccountCategoryRepository.cs @@ -0,0 +1,12 @@ +namespace MyOffice.Data.Repositories.Account; + +using Models.Accounts; + +public interface IAccountCategoryRepository +{ + List GetAll(Guid userId); + bool Add(AccountCategory accountCategory); + AccountCategory? Get(Guid userId, Guid id); + bool Update(AccountCategory accountCategory); + bool Remove(AccountCategory accountCategory); +} \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Account/IAccountMotionRepository.cs b/MyOffice.Data.Repositories/Account/IAccountMotionRepository.cs new file mode 100644 index 0000000..2fc94da --- /dev/null +++ b/MyOffice.Data.Repositories/Account/IAccountMotionRepository.cs @@ -0,0 +1,8 @@ +namespace MyOffice.Data.Repositories.Account; + +using Models.Accounts; + +public interface IAccountMotionRepository +{ + bool Add(AccountMotion accountMotion); +} \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Account/IAccountyRepository.cs b/MyOffice.Data.Repositories/Account/IAccountyRepository.cs new file mode 100644 index 0000000..a34a55a --- /dev/null +++ b/MyOffice.Data.Repositories/Account/IAccountyRepository.cs @@ -0,0 +1,14 @@ +namespace MyOffice.Data.Repositories.Account; + +using Models.Accounts; + +public interface IAccountRepository +{ + List GetAll(Guid userId); + List GetByCategory(Guid userId, Guid categoryId); + List GetByCategoryDetailed(Guid userId, Guid categoryId); + bool Add(Account account); + Account? Get(Guid userId, Guid id); + bool Update(Account account); + bool Remove(Account account); +} \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Currency/CurrencyGlobalRepository.cs b/MyOffice.Data.Repositories/Currency/CurrencyGlobalRepository.cs new file mode 100644 index 0000000..6d97567 --- /dev/null +++ b/MyOffice.Data.Repositories/Currency/CurrencyGlobalRepository.cs @@ -0,0 +1,11 @@ +namespace MyOffice.Data.Repositories.Currency; + +using Models.Currencies; + +public class CurrencyGlobalRepository : AppRepository, ICurrencyGlobalRepository +{ + public List GetAll() + { + return _context.CurrencyGlobals.ToList(); + } +} \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Currency/CurrencyRateRepository.cs b/MyOffice.Data.Repositories/Currency/CurrencyRateRepository.cs new file mode 100644 index 0000000..d937517 --- /dev/null +++ b/MyOffice.Data.Repositories/Currency/CurrencyRateRepository.cs @@ -0,0 +1,29 @@ +namespace MyOffice.Data.Repositories.Currency; + +using Models.Currencies; + +public class CurrencyRateRepository : AppRepository, ICurrencyRateRepository +{ + public List GetLastRates(Guid currencyId, int count = 1) + { + return _context.CurrencyRates + .Where(x => x.CurrencyId == currencyId) + .OrderByDescending(x => x.DateTime) + .ThenByDescending(x => x.Id) + .Take(count) + .ToList(); + } + + public bool AddRate(CurrencyRate currencyRate) + { + return this.AddBase(currencyRate) > 0; + } + + public List GetAtDate(Guid currencyId, DateTime date) + { + return _context.CurrencyRates + .Where(x => x.CurrencyId == currencyId && x.DateTime == date) + .ToList(); + + } +} \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Currency/CurrencyRepository.cs b/MyOffice.Data.Repositories/Currency/CurrencyRepository.cs new file mode 100644 index 0000000..7b86e2c --- /dev/null +++ b/MyOffice.Data.Repositories/Currency/CurrencyRepository.cs @@ -0,0 +1,41 @@ +namespace MyOffice.Data.Repositories.Currency; + +using Microsoft.EntityFrameworkCore; +using Models.Currencies; +using MyOffice.Data.Repositories; + +public class CurrencyRepository : AppRepository, ICurrencyRepository +{ + public List GetAll(Guid userId) + { + return _context.Currencies + .Include(x => x.CurrencyGlobal) + .Where(x => x.UserId == userId) + .ToList(); + } + + public Currency? Get(Guid userId, Guid id) + { + return _context.Currencies.FirstOrDefault(x => x.Id == id && x.UserId == userId); + } + + public Currency? GetByGlobalCurrency(Guid userId, string globalCurrencyId) + { + return _context.Currencies.FirstOrDefault(x => x.UserId == userId && x.CurrencyGlobalId == globalCurrencyId); + } + + public bool Add(Currency currency) + { + return AddBase(currency) > 0; + } + + public bool Update(Currency currency) + { + return UpdateBase(currency) > 0; + } + + public bool Remove(Currency currency) + { + return RemoveBase(currency) > 0; + } +} \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Currency/ICurrencyGlobalRepository.cs b/MyOffice.Data.Repositories/Currency/ICurrencyGlobalRepository.cs new file mode 100644 index 0000000..0d9f090 --- /dev/null +++ b/MyOffice.Data.Repositories/Currency/ICurrencyGlobalRepository.cs @@ -0,0 +1,8 @@ +namespace MyOffice.Data.Repositories.Currency; + +using Models.Currencies; + +public interface ICurrencyGlobalRepository +{ + List GetAll(); +} \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Currency/ICurrencyRateRepository.cs b/MyOffice.Data.Repositories/Currency/ICurrencyRateRepository.cs new file mode 100644 index 0000000..144a9f8 --- /dev/null +++ b/MyOffice.Data.Repositories/Currency/ICurrencyRateRepository.cs @@ -0,0 +1,10 @@ +namespace MyOffice.Data.Repositories.Currency; + +using Models.Currencies; + +public interface ICurrencyRateRepository +{ + List GetLastRates(Guid currencyId, int count = 1); + bool AddRate(CurrencyRate currencyRate); + List GetAtDate(Guid currencyId, DateTime date); +} \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Currency/ICurrencyRepository.cs b/MyOffice.Data.Repositories/Currency/ICurrencyRepository.cs new file mode 100644 index 0000000..e7d4493 --- /dev/null +++ b/MyOffice.Data.Repositories/Currency/ICurrencyRepository.cs @@ -0,0 +1,13 @@ +namespace MyOffice.Data.Repositories.Currency; + +using Models.Currencies; + +public interface ICurrencyRepository +{ + List GetAll(Guid userId); + Currency? Get(Guid userId, Guid id); + Currency? GetByGlobalCurrency(Guid userId, string globalCurrencyId); + bool Add(Currency currency); + bool Update(Currency currency); + bool Remove(Currency currency); +} \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Motion/IMotionCategoryRepository.cs b/MyOffice.Data.Repositories/Motion/IMotionCategoryRepository.cs new file mode 100644 index 0000000..7638261 --- /dev/null +++ b/MyOffice.Data.Repositories/Motion/IMotionCategoryRepository.cs @@ -0,0 +1,12 @@ +namespace MyOffice.Data.Repositories.Motion; + +using Models.Motions; + +public interface IMotionCategoryRepository +{ + List GetAll(Guid userId); + bool Add(MotionCategory accountCategory); + MotionCategory? Get(Guid userId, Guid id); + bool Update(MotionCategory accountCategory); + bool Remove(MotionCategory accountCategory); +} \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Motion/IMotionGlobalRepository.cs b/MyOffice.Data.Repositories/Motion/IMotionGlobalRepository.cs new file mode 100644 index 0000000..2dc30c8 --- /dev/null +++ b/MyOffice.Data.Repositories/Motion/IMotionGlobalRepository.cs @@ -0,0 +1,10 @@ +namespace MyOffice.Data.Repositories.Motion; + +using Models.Motions; + +public interface IMotionGlobalRepository +{ + MotionGlobal? Get(Guid id); + MotionGlobal? GetByName(string name); + bool Add(MotionGlobal motionGlobal); +} \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Motion/IMotionsRepository.cs b/MyOffice.Data.Repositories/Motion/IMotionsRepository.cs new file mode 100644 index 0000000..87357ca --- /dev/null +++ b/MyOffice.Data.Repositories/Motion/IMotionsRepository.cs @@ -0,0 +1,13 @@ +namespace MyOffice.Data.Repositories.Motion; + +using Models.Motions; + +public interface IMotionRepository +{ + List GetAll(Guid userId); + List GetByCategory(Guid userId, Guid categoryId); + + MotionAccount? GetByGlobal(Guid userId, Guid globalMotionId); + bool Add(MotionAccount motionAccount); + bool Update(MotionAccount motionAccount); +} \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Motion/MotionCategoryRepository.cs b/MyOffice.Data.Repositories/Motion/MotionCategoryRepository.cs new file mode 100644 index 0000000..e2977eb --- /dev/null +++ b/MyOffice.Data.Repositories/Motion/MotionCategoryRepository.cs @@ -0,0 +1,37 @@ +namespace MyOffice.Data.Repositories.Motion; + +using Microsoft.EntityFrameworkCore; +using Models.Motions; + +public class MotionCategoryRepository : AppRepository, IMotionCategoryRepository +{ + public List GetAll(Guid userId) + { + return _context.MotionCategories + .Include(x => x.Motions) + .Where(x => x.UserId == userId) + .ToList(); + } + + public bool Add(MotionCategory motionCategory) + { + return AddBase(motionCategory) > 0; + } + + public MotionCategory? Get(Guid userId, Guid id) + { + return _context.MotionCategories + .Include(x => x.Motions) + .FirstOrDefault(x => x.Id == id && x.UserId == userId); + } + + public bool Update(MotionCategory motionCategory) + { + return UpdateBase(motionCategory) > 0; + } + + public bool Remove(MotionCategory motionCategory) + { + return RemoveBase(motionCategory) > 0; + } +} \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Motion/MotionGlobalRepository.cs b/MyOffice.Data.Repositories/Motion/MotionGlobalRepository.cs new file mode 100644 index 0000000..1fc149a --- /dev/null +++ b/MyOffice.Data.Repositories/Motion/MotionGlobalRepository.cs @@ -0,0 +1,21 @@ +namespace MyOffice.Data.Repositories.Motion; + +using Models.Motions; + +public class MotionGlobalRepository : AppRepository, IMotionGlobalRepository +{ + public MotionGlobal? Get(Guid id) + { + return _context.GlobalMotions.FirstOrDefault(x => x.Id == id); + } + + public MotionGlobal? GetByName(string name) + { + return _context.GlobalMotions.FirstOrDefault(x => x.Name == name); + } + + public bool Add(MotionGlobal motionGlobal) + { + return AddBase(motionGlobal) > 0; + } +} \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Motion/MotionRepository.cs b/MyOffice.Data.Repositories/Motion/MotionRepository.cs new file mode 100644 index 0000000..132d352 --- /dev/null +++ b/MyOffice.Data.Repositories/Motion/MotionRepository.cs @@ -0,0 +1,46 @@ +namespace MyOffice.Data.Repositories.Motion; + +using Microsoft.EntityFrameworkCore; +using Models.Motions; + +public class MotionRepository : AppRepository, IMotionRepository +{ + public List GetAll(Guid userId) + { + return _context.Motions + .Include(x => x.Motions) + .Include(x => x.Category) + .Include(x => x.MotionGlobal) + .Where(x => x.Category.UserId == userId) + .ToList(); + } + + public List GetByCategory(Guid userId, Guid categoryId) + { + return _context.Motions + .Include(x => x.Motions) + .Include(x => x.Category) + .Include(x => x.MotionGlobal) + .Where(x => x.Category.UserId == userId && x.CategoryId == categoryId) + .ToList(); + } + + public MotionAccount? GetByGlobal(Guid userId, Guid globalMotionId) + { + return _context.Motions + .Include(x => x.Motions) + .Include(x => x.Category) + .Include(x => x.MotionGlobal) + .FirstOrDefault(x => x.Category.UserId == userId && x.MotionGlobalId == globalMotionId); + } + + public bool Update(MotionAccount motionAccount) + { + return base.UpdateBase(motionAccount) > 0; + } + + public bool Add(MotionAccount motionAccount) + { + return base.AddBase(motionAccount) > 0; + } +} \ No newline at end of file diff --git a/MyOffice.Data.Repositories/RepositoryBase.cs b/MyOffice.Data.Repositories/RepositoryBase.cs index bcabf2f..2e6eff2 100644 --- a/MyOffice.Data.Repositories/RepositoryBase.cs +++ b/MyOffice.Data.Repositories/RepositoryBase.cs @@ -39,30 +39,34 @@ public class RepositoryBase where TEntity : class } - protected async Task GetAsync(Guid id) + protected async Task GetBaseAsync(Guid id) { return await _context.Set().FindAsync(id); } - protected async Task AddAsync(TEntity entity) + protected async Task AddBaseAsync(TEntity entity) { - await _context.Set().AddAsync(entity); + //await _context.Set().AddAsync(entity); + await _context.AddAsync(entity); return await SaveChangesAsync(); } - protected int Add(TEntity entity) + protected int AddBase(TEntity entity) { - _context.Set().Add(entity); + //_context.Set().Add(entity); + _context.Add(entity); return SaveChanges(); } - protected int Remove(TEntity entity) + protected int RemoveBase(TEntity entity) { _context.Set().Remove(entity); + _context.Entry(entity).State = EntityState.Deleted; + return SaveChanges(); } - protected async Task UpdateAsync(TEntity entity) + protected async Task UpdateBaseAsync(TEntity entity) { _context.Attach(entity); _context.Entry(entity).State = EntityState.Modified; @@ -70,9 +74,11 @@ public class RepositoryBase where TEntity : class return await SaveChangesAsync(); } - protected int Update(TEntity entity) + protected int UpdateBase(TEntity entity) { _context.Attach(entity); + _context.Entry(entity).State = EntityState.Modified; + return SaveChanges(); } } \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Users/UserExternalRepository.cs b/MyOffice.Data.Repositories/Users/UserExternalRepository.cs index 6ef84e8..9e145e0 100644 --- a/MyOffice.Data.Repositories/Users/UserExternalRepository.cs +++ b/MyOffice.Data.Repositories/Users/UserExternalRepository.cs @@ -8,12 +8,12 @@ public class UserExternalRepository : AppRepository, IUserExternal { public async Task AddUserExternalAsync(UserExternal userExternal) { - return await AddAsync(userExternal); + return await AddBaseAsync(userExternal); } public int AddUserExternal(UserExternal userExternal) { - return Add(userExternal); + return AddBase(userExternal); } public async Task AddUserExternalsAsync(IEnumerable claims) @@ -93,6 +93,6 @@ public class UserExternalRepository : AppRepository, IUserExternal public void RemoveUserExternal(UserExternal userExternal) { - Remove(userExternal); + RemoveBase(userExternal); } } \ No newline at end of file diff --git a/MyOffice.Data.Repositories/Users/UserRepository.cs b/MyOffice.Data.Repositories/Users/UserRepository.cs index 555bfca..bfd3e45 100644 --- a/MyOffice.Data.Repositories/Users/UserRepository.cs +++ b/MyOffice.Data.Repositories/Users/UserRepository.cs @@ -8,7 +8,7 @@ public class UserRepository : AppRepository, IUserRepository { public async Task GetUserAsync(Guid id) { - return await GetAsync(id); + return await GetBaseAsync(id); } public async Task GetByUserUserNameAsync(string userName) @@ -23,11 +23,11 @@ public class UserRepository : AppRepository, IUserRepository public async Task AddUserAsync(User user) { - return await AddAsync(user); + return await AddBaseAsync(user); } public async Task UpdateUserAsync(User user) { - return await UpdateAsync(user); + return await UpdateBaseAsync(user); } } \ No newline at end of file diff --git a/MyOffice.DbContext/AppDbContext.cs b/MyOffice.DbContext/AppDbContext.cs index 8b00dd1..41d54ab 100644 --- a/MyOffice.DbContext/AppDbContext.cs +++ b/MyOffice.DbContext/AppDbContext.cs @@ -1,6 +1,8 @@ namespace MyOffice.DbContext; -using Data.Models.Account; +using Data.Models.Accounts; +using Data.Models.Currencies; +using Data.Models.Motions; using Microsoft.EntityFrameworkCore; using Data.Models.Users; @@ -29,6 +31,19 @@ public class AppDbContext : DbContext public DbSet Users { get; set; } = null!; public DbSet UserClaims { get; set; } = null!; + public DbSet CurrencyGlobals { get; set; } = null!; + public DbSet Currencies { get; set; } = null!; + public DbSet CurrencyRates { get; set; } = null!; + public DbSet AccountCategories { get; set; } = null!; + public DbSet Accounts { get; set; } = null!; + public DbSet AccountAccountCategories { get; set; } = null!; + public DbSet AccountAccesses { get; set; } = null!; + + public DbSet GlobalMotions { get; set; } = null!; + public DbSet MotionCategories { get; set; } = null!; + public DbSet Motions { get; set; } = null!; + //public DbSet AccountMotions { get; set; } = null!; + protected override void OnModelCreating(ModelBuilder modelBuilder) { var noCaseCollation = _noCaseCollation[_provider]; @@ -59,12 +74,22 @@ public class AppDbContext : DbContext .WithMany(x => x.UserClaims) .HasForeignKey(x => x.UserId); + UserCreating(modelBuilder); CurrencyCreating(modelBuilder); AccountCreating(modelBuilder); + MotionsCreating(modelBuilder); base.OnModelCreating(modelBuilder); } + private void UserCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity() + .HasOne(x => x.Currency) + .WithMany() + .HasForeignKey(x => x.CurrencyId); + } + private void CurrencyCreating(ModelBuilder modelBuilder) { modelBuilder.Entity() @@ -103,6 +128,12 @@ public class AppDbContext : DbContext modelBuilder.Entity() .HasKey(x => x.Id); + modelBuilder.Entity() + .HasKey(x => x.Id); + + modelBuilder.Entity() + .HasKey(x => x.Id); + modelBuilder.Entity() .HasOne(x => x.CurrencyGlobal) .WithMany(x => x.Accounts) @@ -115,7 +146,64 @@ public class AppDbContext : DbContext modelBuilder.Entity() .HasOne(x => x.User) - .WithMany(x => x.AccessRights) + .WithMany(x => x.AccountAccess) + .HasForeignKey(x => x.UserId); + + modelBuilder.Entity() + .HasOne(x => x.Account) + .WithMany(x => x.Motions) .HasForeignKey(x => x.AccountId); + + modelBuilder.Entity() + .HasOne(x => x.User) + .WithMany(x => x.AccountCategories) + .HasForeignKey(x => x.UserId); + + modelBuilder.Entity() + .HasOne(x => x.Account) + .WithMany(x => x.Categories) + .HasForeignKey(x => x.AccountId); + + modelBuilder.Entity() + .HasOne(x => x.Category) + .WithMany(x => x.Accounts) + .HasForeignKey(x => x.CategoryId); + } + + private void MotionsCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity() + .HasKey(x => x.Id); + modelBuilder.Entity() + .HasKey(x => x.Id); + modelBuilder.Entity() + .HasKey(x => x.Id); + modelBuilder.Entity() + .HasKey(x => x.Id); + + modelBuilder.Entity() + .HasOne(x => x.User) + .WithMany(x => x.MotionCategories) + .HasForeignKey(x => x.UserId); + + modelBuilder.Entity() + .HasOne(x => x.Category) + .WithMany(x => x.Motions) + .HasForeignKey(x => x.CategoryId); + + modelBuilder.Entity() + .HasOne(x => x.MotionGlobal) + .WithMany(x => x.Motions) + .HasForeignKey(x => x.MotionGlobalId); + + /*modelBuilder.Entity() + .HasOne(x => x.Motion) + .WithMany(x => x.Motions) + .HasForeignKey(x => x.MotionId); + + modelBuilder.Entity() + .HasOne(x => x.Account) + .WithMany(x => x.Motions) + .HasForeignKey(x => x.AccountId);*/ } } \ No newline at end of file diff --git a/MyOffice.DbContext/RepositoryInitializer.cs b/MyOffice.DbContext/RepositoryInitializer.cs index 9bfc49b..b8b1ff5 100644 --- a/MyOffice.DbContext/RepositoryInitializer.cs +++ b/MyOffice.DbContext/RepositoryInitializer.cs @@ -1,5 +1,6 @@ namespace MyOffice.DbContext; +using Data.Models.Currencies; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; @@ -17,10 +18,34 @@ public class RepositoryInitializer var db = AppDbContextFactory.Instance.CreateDbContext(); db.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; - //db.Database.EnsureCreated(); db.Database.Migrate(); + Prefill(db); } public static ConnectionConfiguration ConnectionString { get; internal set; } = null!; public static IServiceCollection Services { get; internal set; } = null!; + + private static void Prefill(AppDbContext dbContext) + { + // CurrencyGlobals + var predefinedCurrencyGlobals = new List() + { + new() { Id = "UAH", DefaultQuantity = 1, Symbol = "₴", Name = "Ukrainian hryvnias" }, + new() { Id = "USD", DefaultQuantity = 1, Symbol = "$", Name = "US Dollar" }, + new() { Id = "EUR", DefaultQuantity = 1, Symbol = "€", Name = "Euros" }, + new() { Id = "GBP", DefaultQuantity = 1, Symbol = "£", Name = "British pounds sterling" }, + new() { Id = "RUB", DefaultQuantity = 10, Symbol = "₽", Name = "Russia Ruble" }, + }; + + var currencyGlobals = dbContext.CurrencyGlobals.ToList(); + foreach (var predefined in predefinedCurrencyGlobals) + { + if (currencyGlobals.FirstOrDefault(x => x.Id == predefined.Id) == null) + { + dbContext.CurrencyGlobals.Add(predefined); + } + } + + dbContext.SaveChanges(); + } } \ No newline at end of file diff --git a/MyOffice.Migration.Postgres/Migrations/20230429063332_Host.Designer.cs b/MyOffice.Migration.Postgres/Migrations/20230429063332_Host.Designer.cs new file mode 100644 index 0000000..71d01a3 --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230429063332_Host.Designer.cs @@ -0,0 +1,386 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MyOffice.DbContext; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20230429063332_Host")] + partial class Host + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:CollationDefinition:my_ci_collation", "en-u-ks-primary,en-u-ks-primary,icu,False") + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.AccountAccess", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("IsAllowManage") + .HasColumnType("boolean"); + + b.Property("IsAllowRead") + .HasColumnType("boolean"); + + b.Property("IsAllowWrite") + .HasColumnType("boolean"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountAccesses"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.AccountMotion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("AmountIn") + .HasColumnType("numeric"); + + b.Property("AmountOut") + .HasColumnType("numeric"); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountMotions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Currency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.HasIndex("UserId"); + + b.ToTable("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.CurrencyGlobal", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("CurrencyGlobals"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.CurrencyRate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CurrencyId") + .HasColumnType("uuid"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Rate") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("CurrencyRates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("FirstName") + .HasColumnType("text"); + + b.Property("FullName") + .HasColumnType("text"); + + b.Property("IsEmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LastName") + .HasColumnType("text"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("Phone") + .HasColumnType("text"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("ExternalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Provider") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserClaims"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Account", b => + { + b.HasOne("MyOffice.Data.Models.Account.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Accounts") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.AccountAccess", b => + { + b.HasOne("MyOffice.Data.Models.Account.Account", "Account") + .WithMany("AccessRights") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountAccess") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.AccountMotion", b => + { + b.HasOne("MyOffice.Data.Models.Account.Account", "Account") + .WithMany("Motions") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountMotions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Currency", b => + { + b.HasOne("MyOffice.Data.Models.Account.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Currencies") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("Currencies") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.CurrencyRate", b => + { + b.HasOne("MyOffice.Data.Models.Account.Currency", "Currency") + .WithMany("Rates") + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Account", b => + { + b.Navigation("AccessRights"); + + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Currency", b => + { + b.Navigation("Rates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.CurrencyGlobal", b => + { + b.Navigation("Accounts"); + + b.Navigation("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Navigation("AccountAccess"); + + b.Navigation("AccountMotions"); + + b.Navigation("Currencies"); + + b.Navigation("UserClaims"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230429063332_Host.cs b/MyOffice.Migration.Postgres/Migrations/20230429063332_Host.cs new file mode 100644 index 0000000..137be0e --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230429063332_Host.cs @@ -0,0 +1,217 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + /// + public partial class Host : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "CurrencyGlobals", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + ShortName = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CurrencyGlobals", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Accounts", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + CurrencyGlobalId = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Accounts", x => x.Id); + table.ForeignKey( + name: "FK_Accounts_CurrencyGlobals_CurrencyGlobalId", + column: x => x.CurrencyGlobalId, + principalTable: "CurrencyGlobals", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Currencies", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + CurrencyGlobalId = table.Column(type: "text", nullable: false), + UserId = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false), + ShortName = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Currencies", x => x.Id); + table.ForeignKey( + name: "FK_Currencies_CurrencyGlobals_CurrencyGlobalId", + column: x => x.CurrencyGlobalId, + principalTable: "CurrencyGlobals", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Currencies_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AccountAccesses", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + AccountId = table.Column(type: "uuid", nullable: false), + UserId = table.Column(type: "uuid", nullable: false), + IsAllowRead = table.Column(type: "boolean", nullable: false), + IsAllowWrite = table.Column(type: "boolean", nullable: false), + IsAllowManage = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AccountAccesses", x => x.Id); + table.ForeignKey( + name: "FK_AccountAccesses_Accounts_AccountId", + column: x => x.AccountId, + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AccountAccesses_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AccountMotions", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + CreatedOn = table.Column(type: "timestamp with time zone", nullable: false), + DateTime = table.Column(type: "timestamp with time zone", nullable: false), + AccountId = table.Column(type: "uuid", nullable: false), + UserId = table.Column(type: "uuid", nullable: false), + AmountIn = table.Column(type: "numeric", nullable: false), + AmountOut = table.Column(type: "numeric", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AccountMotions", x => x.Id); + table.ForeignKey( + name: "FK_AccountMotions_Accounts_AccountId", + column: x => x.AccountId, + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AccountMotions_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "CurrencyRates", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + CurrencyId = table.Column(type: "uuid", nullable: false), + DateTime = table.Column(type: "timestamp with time zone", nullable: false), + Rate = table.Column(type: "numeric", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CurrencyRates", x => x.Id); + table.ForeignKey( + name: "FK_CurrencyRates_Currencies_CurrencyId", + column: x => x.CurrencyId, + principalTable: "Currencies", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AccountAccesses_AccountId", + table: "AccountAccesses", + column: "AccountId"); + + migrationBuilder.CreateIndex( + name: "IX_AccountAccesses_UserId", + table: "AccountAccesses", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AccountMotions_AccountId", + table: "AccountMotions", + column: "AccountId"); + + migrationBuilder.CreateIndex( + name: "IX_AccountMotions_UserId", + table: "AccountMotions", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Accounts_CurrencyGlobalId", + table: "Accounts", + column: "CurrencyGlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_Currencies_CurrencyGlobalId", + table: "Currencies", + column: "CurrencyGlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_Currencies_UserId", + table: "Currencies", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_CurrencyRates_CurrencyId", + table: "CurrencyRates", + column: "CurrencyId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AccountAccesses"); + + migrationBuilder.DropTable( + name: "AccountMotions"); + + migrationBuilder.DropTable( + name: "CurrencyRates"); + + migrationBuilder.DropTable( + name: "Accounts"); + + migrationBuilder.DropTable( + name: "Currencies"); + + migrationBuilder.DropTable( + name: "CurrencyGlobals"); + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230429090658_user_currency.Designer.cs b/MyOffice.Migration.Postgres/Migrations/20230429090658_user_currency.Designer.cs new file mode 100644 index 0000000..f46e32d --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230429090658_user_currency.Designer.cs @@ -0,0 +1,407 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MyOffice.DbContext; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20230429090658_user_currency")] + partial class usercurrency + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:CollationDefinition:my_ci_collation", "en-u-ks-primary,en-u-ks-primary,icu,False") + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.AccountAccess", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("IsAllowManage") + .HasColumnType("boolean"); + + b.Property("IsAllowRead") + .HasColumnType("boolean"); + + b.Property("IsAllowWrite") + .HasColumnType("boolean"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountAccesses"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.AccountMotion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("AmountIn") + .HasColumnType("numeric"); + + b.Property("AmountOut") + .HasColumnType("numeric"); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountMotions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Currency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.HasIndex("UserId"); + + b.ToTable("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.CurrencyGlobal", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Symbol") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("CurrencyGlobals"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.CurrencyRate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CurrencyId") + .HasColumnType("uuid"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Rate") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("CurrencyRates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("FirstName") + .HasColumnType("text"); + + b.Property("FullName") + .HasColumnType("text"); + + b.Property("IsEmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LastName") + .HasColumnType("text"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("Phone") + .HasColumnType("text"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("ExternalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Provider") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserClaims"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Account", b => + { + b.HasOne("MyOffice.Data.Models.Account.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Accounts") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.AccountAccess", b => + { + b.HasOne("MyOffice.Data.Models.Account.Account", "Account") + .WithMany("AccessRights") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountAccess") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.AccountMotion", b => + { + b.HasOne("MyOffice.Data.Models.Account.Account", "Account") + .WithMany("Motions") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountMotions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Currency", b => + { + b.HasOne("MyOffice.Data.Models.Account.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Currencies") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("Currencies") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.CurrencyRate", b => + { + b.HasOne("MyOffice.Data.Models.Account.Currency", "Currency") + .WithMany("Rates") + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.HasOne("MyOffice.Data.Models.Account.CurrencyGlobal", "Currency") + .WithMany() + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Account", b => + { + b.Navigation("AccessRights"); + + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Currency", b => + { + b.Navigation("Rates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.CurrencyGlobal", b => + { + b.Navigation("Accounts"); + + b.Navigation("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Navigation("AccountAccess"); + + b.Navigation("AccountMotions"); + + b.Navigation("Currencies"); + + b.Navigation("UserClaims"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230429090658_user_currency.cs b/MyOffice.Migration.Postgres/Migrations/20230429090658_user_currency.cs new file mode 100644 index 0000000..f74dea3 --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230429090658_user_currency.cs @@ -0,0 +1,61 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + /// + public partial class usercurrency : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "CurrencyId", + table: "Users", + type: "text", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "Symbol", + table: "CurrencyGlobals", + type: "text", + nullable: false, + defaultValue: ""); + + migrationBuilder.CreateIndex( + name: "IX_Users_CurrencyId", + table: "Users", + column: "CurrencyId"); + + migrationBuilder.AddForeignKey( + name: "FK_Users_CurrencyGlobals_CurrencyId", + table: "Users", + column: "CurrencyId", + principalTable: "CurrencyGlobals", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Users_CurrencyGlobals_CurrencyId", + table: "Users"); + + migrationBuilder.DropIndex( + name: "IX_Users_CurrencyId", + table: "Users"); + + migrationBuilder.DropColumn( + name: "CurrencyId", + table: "Users"); + + migrationBuilder.DropColumn( + name: "Symbol", + table: "CurrencyGlobals"); + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230429092104_currency_shortname.Designer.cs b/MyOffice.Migration.Postgres/Migrations/20230429092104_currency_shortname.Designer.cs new file mode 100644 index 0000000..028f7f9 --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230429092104_currency_shortname.Designer.cs @@ -0,0 +1,403 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MyOffice.DbContext; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20230429092104_currency_shortname")] + partial class currencyshortname + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:CollationDefinition:my_ci_collation", "en-u-ks-primary,en-u-ks-primary,icu,False") + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.AccountAccess", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("IsAllowManage") + .HasColumnType("boolean"); + + b.Property("IsAllowRead") + .HasColumnType("boolean"); + + b.Property("IsAllowWrite") + .HasColumnType("boolean"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountAccesses"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.AccountMotion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("AmountIn") + .HasColumnType("numeric"); + + b.Property("AmountOut") + .HasColumnType("numeric"); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountMotions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Currency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.HasIndex("UserId"); + + b.ToTable("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.CurrencyGlobal", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Symbol") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("CurrencyGlobals"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.CurrencyRate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CurrencyId") + .HasColumnType("uuid"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Rate") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("CurrencyRates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("FirstName") + .HasColumnType("text"); + + b.Property("FullName") + .HasColumnType("text"); + + b.Property("IsEmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LastName") + .HasColumnType("text"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("Phone") + .HasColumnType("text"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("ExternalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Provider") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserClaims"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Account", b => + { + b.HasOne("MyOffice.Data.Models.Account.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Accounts") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.AccountAccess", b => + { + b.HasOne("MyOffice.Data.Models.Account.Account", "Account") + .WithMany("AccessRights") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountAccess") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.AccountMotion", b => + { + b.HasOne("MyOffice.Data.Models.Account.Account", "Account") + .WithMany("Motions") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountMotions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Currency", b => + { + b.HasOne("MyOffice.Data.Models.Account.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Currencies") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("Currencies") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.CurrencyRate", b => + { + b.HasOne("MyOffice.Data.Models.Account.Currency", "Currency") + .WithMany("Rates") + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.HasOne("MyOffice.Data.Models.Account.CurrencyGlobal", "Currency") + .WithMany() + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Account", b => + { + b.Navigation("AccessRights"); + + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Currency", b => + { + b.Navigation("Rates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.CurrencyGlobal", b => + { + b.Navigation("Accounts"); + + b.Navigation("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Navigation("AccountAccess"); + + b.Navigation("AccountMotions"); + + b.Navigation("Currencies"); + + b.Navigation("UserClaims"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230429092104_currency_shortname.cs b/MyOffice.Migration.Postgres/Migrations/20230429092104_currency_shortname.cs new file mode 100644 index 0000000..52fc1b2 --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230429092104_currency_shortname.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + /// + public partial class currencyshortname : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ShortName", + table: "Currencies"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ShortName", + table: "Currencies", + type: "text", + nullable: false, + defaultValue: ""); + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230429092950_gcurrency_shortname.Designer.cs b/MyOffice.Migration.Postgres/Migrations/20230429092950_gcurrency_shortname.Designer.cs new file mode 100644 index 0000000..9846731 --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230429092950_gcurrency_shortname.Designer.cs @@ -0,0 +1,403 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MyOffice.DbContext; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20230429092950_gcurrency_shortname")] + partial class gcurrencyshortname + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:CollationDefinition:my_ci_collation", "en-u-ks-primary,en-u-ks-primary,icu,False") + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.AccountAccess", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("IsAllowManage") + .HasColumnType("boolean"); + + b.Property("IsAllowRead") + .HasColumnType("boolean"); + + b.Property("IsAllowWrite") + .HasColumnType("boolean"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountAccesses"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.AccountMotion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("AmountIn") + .HasColumnType("numeric"); + + b.Property("AmountOut") + .HasColumnType("numeric"); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountMotions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Currency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.HasIndex("UserId"); + + b.ToTable("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.CurrencyGlobal", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Symbol") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("CurrencyGlobals"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.CurrencyRate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CurrencyId") + .HasColumnType("uuid"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Rate") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("CurrencyRates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("FirstName") + .HasColumnType("text"); + + b.Property("FullName") + .HasColumnType("text"); + + b.Property("IsEmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LastName") + .HasColumnType("text"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("Phone") + .HasColumnType("text"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("ExternalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Provider") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserClaims"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Account", b => + { + b.HasOne("MyOffice.Data.Models.Account.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Accounts") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.AccountAccess", b => + { + b.HasOne("MyOffice.Data.Models.Account.Account", "Account") + .WithMany("AccessRights") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountAccess") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.AccountMotion", b => + { + b.HasOne("MyOffice.Data.Models.Account.Account", "Account") + .WithMany("Motions") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountMotions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Currency", b => + { + b.HasOne("MyOffice.Data.Models.Account.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Currencies") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("Currencies") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.CurrencyRate", b => + { + b.HasOne("MyOffice.Data.Models.Account.Currency", "Currency") + .WithMany("Rates") + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.HasOne("MyOffice.Data.Models.Account.CurrencyGlobal", "Currency") + .WithMany() + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Account", b => + { + b.Navigation("AccessRights"); + + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.Currency", b => + { + b.Navigation("Rates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Account.CurrencyGlobal", b => + { + b.Navigation("Accounts"); + + b.Navigation("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Navigation("AccountAccess"); + + b.Navigation("AccountMotions"); + + b.Navigation("Currencies"); + + b.Navigation("UserClaims"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230429092950_gcurrency_shortname.cs b/MyOffice.Migration.Postgres/Migrations/20230429092950_gcurrency_shortname.cs new file mode 100644 index 0000000..92705d6 --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230429092950_gcurrency_shortname.cs @@ -0,0 +1,40 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + /// + public partial class gcurrencyshortname : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ShortName", + table: "CurrencyGlobals"); + + migrationBuilder.AddColumn( + name: "ShortName", + table: "Currencies", + type: "text", + nullable: false, + defaultValue: ""); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ShortName", + table: "Currencies"); + + migrationBuilder.AddColumn( + name: "ShortName", + table: "CurrencyGlobals", + type: "text", + nullable: false, + defaultValue: ""); + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230430103617_account_category.Designer.cs b/MyOffice.Migration.Postgres/Migrations/20230430103617_account_category.Designer.cs new file mode 100644 index 0000000..efee34b --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230430103617_account_category.Designer.cs @@ -0,0 +1,467 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MyOffice.DbContext; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20230430103617_account_category")] + partial class accountcategory + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:CollationDefinition:my_ci_collation", "en-u-ks-primary,en-u-ks-primary,icu,False") + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccess", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("IsAllowManage") + .HasColumnType("boolean"); + + b.Property("IsAllowRead") + .HasColumnType("boolean"); + + b.Property("IsAllowWrite") + .HasColumnType("boolean"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountAccesses"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("CategoryId"); + + b.ToTable("AccountAccountCategory"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("AccountCategory"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountMotion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("AmountIn") + .HasColumnType("numeric"); + + b.Property("AmountOut") + .HasColumnType("numeric"); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountMotions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.Currency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.HasIndex("UserId"); + + b.ToTable("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.CurrencyGlobal", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Symbol") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("CurrencyGlobals"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.CurrencyRate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CurrencyId") + .HasColumnType("uuid"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Rate") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("CurrencyRates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("FirstName") + .HasColumnType("text"); + + b.Property("FullName") + .HasColumnType("text"); + + b.Property("IsEmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LastName") + .HasColumnType("text"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("Phone") + .HasColumnType("text"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("ExternalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Provider") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserClaims"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.HasOne("MyOffice.Data.Models.Currency.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Accounts") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccess", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("AccessRights") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountAccess") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccountCategory", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.AccountCategory", "Category") + .WithMany("Accounts") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("Categories") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountMotion", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("Motions") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountMotions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.Currency", b => + { + b.HasOne("MyOffice.Data.Models.Currency.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Currencies") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("Currencies") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.CurrencyRate", b => + { + b.HasOne("MyOffice.Data.Models.Currency.Currency", "Currency") + .WithMany("Rates") + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.HasOne("MyOffice.Data.Models.Currency.CurrencyGlobal", "Currency") + .WithMany() + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.Navigation("AccessRights"); + + b.Navigation("Categories"); + + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.Currency", b => + { + b.Navigation("Rates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.CurrencyGlobal", b => + { + b.Navigation("Accounts"); + + b.Navigation("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Navigation("AccountAccess"); + + b.Navigation("AccountMotions"); + + b.Navigation("Currencies"); + + b.Navigation("UserClaims"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230430103617_account_category.cs b/MyOffice.Migration.Postgres/Migrations/20230430103617_account_category.cs new file mode 100644 index 0000000..a3cedb2 --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230430103617_account_category.cs @@ -0,0 +1,74 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + /// + public partial class accountcategory : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "AccountCategory", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AccountCategory", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AccountAccountCategory", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + AccountId = table.Column(type: "uuid", nullable: false), + CategoryId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AccountAccountCategory", x => x.Id); + table.ForeignKey( + name: "FK_AccountAccountCategory_AccountCategory_AccountId", + column: x => x.AccountId, + principalTable: "AccountCategory", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AccountAccountCategory_Accounts_CategoryId", + column: x => x.CategoryId, + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AccountAccountCategory_AccountId", + table: "AccountAccountCategory", + column: "AccountId"); + + migrationBuilder.CreateIndex( + name: "IX_AccountAccountCategory_CategoryId", + table: "AccountAccountCategory", + column: "CategoryId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AccountAccountCategory"); + + migrationBuilder.DropTable( + name: "AccountCategory"); + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230601100601_CurrencyQuantity.Designer.cs b/MyOffice.Migration.Postgres/Migrations/20230601100601_CurrencyQuantity.Designer.cs new file mode 100644 index 0000000..40fd601 --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230601100601_CurrencyQuantity.Designer.cs @@ -0,0 +1,473 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MyOffice.DbContext; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20230601100601_CurrencyQuantity")] + partial class CurrencyQuantity + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:CollationDefinition:my_ci_collation", "en-u-ks-primary,en-u-ks-primary,icu,False") + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccess", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("IsAllowManage") + .HasColumnType("boolean"); + + b.Property("IsAllowRead") + .HasColumnType("boolean"); + + b.Property("IsAllowWrite") + .HasColumnType("boolean"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountAccesses"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("CategoryId"); + + b.ToTable("AccountAccountCategory"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("AccountCategory"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountMotion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("AmountIn") + .HasColumnType("numeric"); + + b.Property("AmountOut") + .HasColumnType("numeric"); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountMotions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.Currency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("DefaultQuantity") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.HasIndex("UserId"); + + b.ToTable("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.CurrencyGlobal", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Symbol") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("CurrencyGlobals"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.CurrencyRate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CurrencyId") + .HasColumnType("uuid"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("Rate") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("CurrencyRates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("FirstName") + .HasColumnType("text"); + + b.Property("FullName") + .HasColumnType("text"); + + b.Property("IsEmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LastName") + .HasColumnType("text"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("Phone") + .HasColumnType("text"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("ExternalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Provider") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserClaims"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.HasOne("MyOffice.Data.Models.Currency.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Accounts") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccess", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("AccessRights") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountAccess") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccountCategory", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.AccountCategory", "Category") + .WithMany("Accounts") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("Categories") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountMotion", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("Motions") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountMotions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.Currency", b => + { + b.HasOne("MyOffice.Data.Models.Currency.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Currencies") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("Currencies") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.CurrencyRate", b => + { + b.HasOne("MyOffice.Data.Models.Currency.Currency", "Currency") + .WithMany("Rates") + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.HasOne("MyOffice.Data.Models.Currency.CurrencyGlobal", "Currency") + .WithMany() + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.Navigation("AccessRights"); + + b.Navigation("Categories"); + + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.Currency", b => + { + b.Navigation("Rates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.CurrencyGlobal", b => + { + b.Navigation("Accounts"); + + b.Navigation("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Navigation("AccountAccess"); + + b.Navigation("AccountMotions"); + + b.Navigation("Currencies"); + + b.Navigation("UserClaims"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230601100601_CurrencyQuantity.cs b/MyOffice.Migration.Postgres/Migrations/20230601100601_CurrencyQuantity.cs new file mode 100644 index 0000000..edfa9a7 --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230601100601_CurrencyQuantity.cs @@ -0,0 +1,40 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + /// + public partial class CurrencyQuantity : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Quantity", + table: "CurrencyRates", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "DefaultQuantity", + table: "Currencies", + type: "integer", + nullable: false, + defaultValue: 0); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Quantity", + table: "CurrencyRates"); + + migrationBuilder.DropColumn( + name: "DefaultQuantity", + table: "Currencies"); + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230601100833_CurrencyQuantity2.Designer.cs b/MyOffice.Migration.Postgres/Migrations/20230601100833_CurrencyQuantity2.Designer.cs new file mode 100644 index 0000000..7304ea3 --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230601100833_CurrencyQuantity2.Designer.cs @@ -0,0 +1,473 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MyOffice.DbContext; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20230601100833_CurrencyQuantity2")] + partial class CurrencyQuantity2 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:CollationDefinition:my_ci_collation", "en-u-ks-primary,en-u-ks-primary,icu,False") + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccess", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("IsAllowManage") + .HasColumnType("boolean"); + + b.Property("IsAllowRead") + .HasColumnType("boolean"); + + b.Property("IsAllowWrite") + .HasColumnType("boolean"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountAccesses"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("CategoryId"); + + b.ToTable("AccountAccountCategory"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("AccountCategory"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountMotion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("AmountIn") + .HasColumnType("numeric"); + + b.Property("AmountOut") + .HasColumnType("numeric"); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountMotions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.Currency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.HasIndex("UserId"); + + b.ToTable("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.CurrencyGlobal", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("DefaultQuantity") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Symbol") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("CurrencyGlobals"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.CurrencyRate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CurrencyId") + .HasColumnType("uuid"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("Rate") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("CurrencyRates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("FirstName") + .HasColumnType("text"); + + b.Property("FullName") + .HasColumnType("text"); + + b.Property("IsEmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LastName") + .HasColumnType("text"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("Phone") + .HasColumnType("text"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("ExternalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Provider") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserClaims"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.HasOne("MyOffice.Data.Models.Currency.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Accounts") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccess", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("AccessRights") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountAccess") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccountCategory", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.AccountCategory", "Category") + .WithMany("Accounts") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("Categories") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountMotion", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("Motions") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountMotions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.Currency", b => + { + b.HasOne("MyOffice.Data.Models.Currency.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Currencies") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("Currencies") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.CurrencyRate", b => + { + b.HasOne("MyOffice.Data.Models.Currency.Currency", "Currency") + .WithMany("Rates") + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.HasOne("MyOffice.Data.Models.Currency.CurrencyGlobal", "Currency") + .WithMany() + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.Navigation("AccessRights"); + + b.Navigation("Categories"); + + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.Currency", b => + { + b.Navigation("Rates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.CurrencyGlobal", b => + { + b.Navigation("Accounts"); + + b.Navigation("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Navigation("AccountAccess"); + + b.Navigation("AccountMotions"); + + b.Navigation("Currencies"); + + b.Navigation("UserClaims"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230601100833_CurrencyQuantity2.cs b/MyOffice.Migration.Postgres/Migrations/20230601100833_CurrencyQuantity2.cs new file mode 100644 index 0000000..636b207 --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230601100833_CurrencyQuantity2.cs @@ -0,0 +1,40 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + /// + public partial class CurrencyQuantity2 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "DefaultQuantity", + table: "Currencies"); + + migrationBuilder.AddColumn( + name: "DefaultQuantity", + table: "CurrencyGlobals", + type: "integer", + nullable: false, + defaultValue: 0); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "DefaultQuantity", + table: "CurrencyGlobals"); + + migrationBuilder.AddColumn( + name: "DefaultQuantity", + table: "Currencies", + type: "integer", + nullable: false, + defaultValue: 0); + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230601121013_AccountCategories.Designer.cs b/MyOffice.Migration.Postgres/Migrations/20230601121013_AccountCategories.Designer.cs new file mode 100644 index 0000000..87169e7 --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230601121013_AccountCategories.Designer.cs @@ -0,0 +1,491 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MyOffice.DbContext; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20230601121013_AccountCategories")] + partial class AccountCategories + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:CollationDefinition:my_ci_collation", "en-u-ks-primary,en-u-ks-primary,icu,False") + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccess", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("IsAllowManage") + .HasColumnType("boolean"); + + b.Property("IsAllowRead") + .HasColumnType("boolean"); + + b.Property("IsAllowWrite") + .HasColumnType("boolean"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountAccesses"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("CategoryId"); + + b.ToTable("AccountAccountCategories"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AccountCategories"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountMotion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("AmountIn") + .HasColumnType("numeric"); + + b.Property("AmountOut") + .HasColumnType("numeric"); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountMotions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.Currency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.HasIndex("UserId"); + + b.ToTable("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.CurrencyGlobal", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("DefaultQuantity") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Symbol") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("CurrencyGlobals"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.CurrencyRate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CurrencyId") + .HasColumnType("uuid"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("Rate") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("CurrencyRates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("FirstName") + .HasColumnType("text"); + + b.Property("FullName") + .HasColumnType("text"); + + b.Property("IsEmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LastName") + .HasColumnType("text"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("Phone") + .HasColumnType("text"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("ExternalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Provider") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserClaims"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.HasOne("MyOffice.Data.Models.Currency.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Accounts") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccess", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("AccessRights") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountAccess") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccountCategory", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.AccountCategory", "Category") + .WithMany("Accounts") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("Categories") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountCategories") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountMotion", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("Motions") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountMotions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.Currency", b => + { + b.HasOne("MyOffice.Data.Models.Currency.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Currencies") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("Currencies") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.CurrencyRate", b => + { + b.HasOne("MyOffice.Data.Models.Currency.Currency", "Currency") + .WithMany("Rates") + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.HasOne("MyOffice.Data.Models.Currency.CurrencyGlobal", "Currency") + .WithMany() + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.Navigation("AccessRights"); + + b.Navigation("Categories"); + + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.Currency", b => + { + b.Navigation("Rates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.CurrencyGlobal", b => + { + b.Navigation("Accounts"); + + b.Navigation("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Navigation("AccountAccess"); + + b.Navigation("AccountCategories"); + + b.Navigation("AccountMotions"); + + b.Navigation("Currencies"); + + b.Navigation("UserClaims"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230601121013_AccountCategories.cs b/MyOffice.Migration.Postgres/Migrations/20230601121013_AccountCategories.cs new file mode 100644 index 0000000..1b88fb7 --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230601121013_AccountCategories.cs @@ -0,0 +1,171 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + /// + public partial class AccountCategories : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_AccountAccountCategory_AccountCategory_AccountId", + table: "AccountAccountCategory"); + + migrationBuilder.DropForeignKey( + name: "FK_AccountAccountCategory_Accounts_CategoryId", + table: "AccountAccountCategory"); + + migrationBuilder.DropPrimaryKey( + name: "PK_AccountCategory", + table: "AccountCategory"); + + migrationBuilder.DropPrimaryKey( + name: "PK_AccountAccountCategory", + table: "AccountAccountCategory"); + + migrationBuilder.RenameTable( + name: "AccountCategory", + newName: "AccountCategories"); + + migrationBuilder.RenameTable( + name: "AccountAccountCategory", + newName: "AccountAccountCategories"); + + migrationBuilder.RenameIndex( + name: "IX_AccountAccountCategory_CategoryId", + table: "AccountAccountCategories", + newName: "IX_AccountAccountCategories_CategoryId"); + + migrationBuilder.RenameIndex( + name: "IX_AccountAccountCategory_AccountId", + table: "AccountAccountCategories", + newName: "IX_AccountAccountCategories_AccountId"); + + migrationBuilder.AddColumn( + name: "UserId", + table: "AccountCategories", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddPrimaryKey( + name: "PK_AccountCategories", + table: "AccountCategories", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_AccountAccountCategories", + table: "AccountAccountCategories", + column: "Id"); + + migrationBuilder.CreateIndex( + name: "IX_AccountCategories_UserId", + table: "AccountCategories", + column: "UserId"); + + migrationBuilder.AddForeignKey( + name: "FK_AccountAccountCategories_AccountCategories_AccountId", + table: "AccountAccountCategories", + column: "AccountId", + principalTable: "AccountCategories", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_AccountAccountCategories_Accounts_CategoryId", + table: "AccountAccountCategories", + column: "CategoryId", + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_AccountCategories_Users_UserId", + table: "AccountCategories", + column: "UserId", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_AccountAccountCategories_AccountCategories_AccountId", + table: "AccountAccountCategories"); + + migrationBuilder.DropForeignKey( + name: "FK_AccountAccountCategories_Accounts_CategoryId", + table: "AccountAccountCategories"); + + migrationBuilder.DropForeignKey( + name: "FK_AccountCategories_Users_UserId", + table: "AccountCategories"); + + migrationBuilder.DropPrimaryKey( + name: "PK_AccountCategories", + table: "AccountCategories"); + + migrationBuilder.DropIndex( + name: "IX_AccountCategories_UserId", + table: "AccountCategories"); + + migrationBuilder.DropPrimaryKey( + name: "PK_AccountAccountCategories", + table: "AccountAccountCategories"); + + migrationBuilder.DropColumn( + name: "UserId", + table: "AccountCategories"); + + migrationBuilder.RenameTable( + name: "AccountCategories", + newName: "AccountCategory"); + + migrationBuilder.RenameTable( + name: "AccountAccountCategories", + newName: "AccountAccountCategory"); + + migrationBuilder.RenameIndex( + name: "IX_AccountAccountCategories_CategoryId", + table: "AccountAccountCategory", + newName: "IX_AccountAccountCategory_CategoryId"); + + migrationBuilder.RenameIndex( + name: "IX_AccountAccountCategories_AccountId", + table: "AccountAccountCategory", + newName: "IX_AccountAccountCategory_AccountId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_AccountCategory", + table: "AccountCategory", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_AccountAccountCategory", + table: "AccountAccountCategory", + column: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_AccountAccountCategory_AccountCategory_AccountId", + table: "AccountAccountCategory", + column: "AccountId", + principalTable: "AccountCategory", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_AccountAccountCategory_Accounts_CategoryId", + table: "AccountAccountCategory", + column: "CategoryId", + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230609062452_AccountCategoriesFix.Designer.cs b/MyOffice.Migration.Postgres/Migrations/20230609062452_AccountCategoriesFix.Designer.cs new file mode 100644 index 0000000..4c5d711 --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230609062452_AccountCategoriesFix.Designer.cs @@ -0,0 +1,491 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MyOffice.DbContext; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20230609062452_AccountCategoriesFix")] + partial class AccountCategoriesFix + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:CollationDefinition:my_ci_collation", "en-u-ks-primary,en-u-ks-primary,icu,False") + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccess", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("IsAllowManage") + .HasColumnType("boolean"); + + b.Property("IsAllowRead") + .HasColumnType("boolean"); + + b.Property("IsAllowWrite") + .HasColumnType("boolean"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountAccesses"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("CategoryId"); + + b.ToTable("AccountAccountCategories"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AccountCategories"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountMotion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("AmountIn") + .HasColumnType("numeric"); + + b.Property("AmountOut") + .HasColumnType("numeric"); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountMotions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.Currency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.HasIndex("UserId"); + + b.ToTable("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.CurrencyGlobal", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("DefaultQuantity") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Symbol") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("CurrencyGlobals"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.CurrencyRate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CurrencyId") + .HasColumnType("uuid"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("Rate") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("CurrencyRates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("FirstName") + .HasColumnType("text"); + + b.Property("FullName") + .HasColumnType("text"); + + b.Property("IsEmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LastName") + .HasColumnType("text"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("Phone") + .HasColumnType("text"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("ExternalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Provider") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserClaims"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.HasOne("MyOffice.Data.Models.Currency.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Accounts") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccess", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("AccessRights") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountAccess") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccountCategory", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("Categories") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Accounts.AccountCategory", "Category") + .WithMany("Accounts") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountCategories") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountMotion", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("Motions") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountMotions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.Currency", b => + { + b.HasOne("MyOffice.Data.Models.Currency.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Currencies") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("Currencies") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.CurrencyRate", b => + { + b.HasOne("MyOffice.Data.Models.Currency.Currency", "Currency") + .WithMany("Rates") + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.HasOne("MyOffice.Data.Models.Currency.CurrencyGlobal", "Currency") + .WithMany() + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.Navigation("AccessRights"); + + b.Navigation("Categories"); + + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.Currency", b => + { + b.Navigation("Rates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currency.CurrencyGlobal", b => + { + b.Navigation("Accounts"); + + b.Navigation("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Navigation("AccountAccess"); + + b.Navigation("AccountCategories"); + + b.Navigation("AccountMotions"); + + b.Navigation("Currencies"); + + b.Navigation("UserClaims"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230609062452_AccountCategoriesFix.cs b/MyOffice.Migration.Postgres/Migrations/20230609062452_AccountCategoriesFix.cs new file mode 100644 index 0000000..cece476 --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230609062452_AccountCategoriesFix.cs @@ -0,0 +1,66 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + /// + public partial class AccountCategoriesFix : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_AccountAccountCategories_AccountCategories_AccountId", + table: "AccountAccountCategories"); + + migrationBuilder.DropForeignKey( + name: "FK_AccountAccountCategories_Accounts_CategoryId", + table: "AccountAccountCategories"); + + migrationBuilder.AddForeignKey( + name: "FK_AccountAccountCategories_AccountCategories_CategoryId", + table: "AccountAccountCategories", + column: "CategoryId", + principalTable: "AccountCategories", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_AccountAccountCategories_Accounts_AccountId", + table: "AccountAccountCategories", + column: "AccountId", + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_AccountAccountCategories_AccountCategories_CategoryId", + table: "AccountAccountCategories"); + + migrationBuilder.DropForeignKey( + name: "FK_AccountAccountCategories_Accounts_AccountId", + table: "AccountAccountCategories"); + + migrationBuilder.AddForeignKey( + name: "FK_AccountAccountCategories_AccountCategories_AccountId", + table: "AccountAccountCategories", + column: "AccountId", + principalTable: "AccountCategories", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_AccountAccountCategories_Accounts_CategoryId", + table: "AccountAccountCategories", + column: "CategoryId", + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230611145152_Motion.Designer.cs b/MyOffice.Migration.Postgres/Migrations/20230611145152_Motion.Designer.cs new file mode 100644 index 0000000..51042cc --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230611145152_Motion.Designer.cs @@ -0,0 +1,606 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MyOffice.DbContext; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20230611145152_Motion")] + partial class Motion + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:CollationDefinition:my_ci_collation", "en-u-ks-primary,en-u-ks-primary,icu,False") + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccess", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("IsAllowManage") + .HasColumnType("boolean"); + + b.Property("IsAllowRead") + .HasColumnType("boolean"); + + b.Property("IsAllowWrite") + .HasColumnType("boolean"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountAccesses"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("CategoryId"); + + b.ToTable("AccountAccountCategories"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AccountCategories"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountMotion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("AmountMinus") + .HasColumnType("numeric"); + + b.Property("AmountPlus") + .HasColumnType("numeric"); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("MotionId") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("MotionId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountMotions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.Currency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.HasIndex("UserId"); + + b.ToTable("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.CurrencyGlobal", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("DefaultQuantity") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Symbol") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("CurrencyGlobals"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.CurrencyRate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CurrencyId") + .HasColumnType("uuid"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("Rate") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("CurrencyRates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("MotionGlobalId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.HasIndex("MotionGlobalId"); + + b.ToTable("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("MotionCategories"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionGlobal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("GlobalMotions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("FirstName") + .HasColumnType("text"); + + b.Property("FullName") + .HasColumnType("text"); + + b.Property("IsEmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LastName") + .HasColumnType("text"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("Phone") + .HasColumnType("text"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("ExternalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Provider") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserClaims"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.HasOne("MyOffice.Data.Models.Currencies.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Accounts") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccess", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("AccessRights") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountAccess") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccountCategory", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("Categories") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Accounts.AccountCategory", "Category") + .WithMany("Accounts") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountCategories") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountMotion", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("Motions") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Motions.MotionAccount", "Motion") + .WithMany("Motions") + .HasForeignKey("MotionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", null) + .WithMany("AccountMotions") + .HasForeignKey("UserId"); + + b.Navigation("Account"); + + b.Navigation("Motion"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.Currency", b => + { + b.HasOne("MyOffice.Data.Models.Currencies.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Currencies") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("Currencies") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.CurrencyRate", b => + { + b.HasOne("MyOffice.Data.Models.Currencies.Currency", "Currency") + .WithMany("Rates") + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionAccount", b => + { + b.HasOne("MyOffice.Data.Models.Motions.MotionCategory", "Category") + .WithMany("Motions") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Motions.MotionGlobal", "MotionGlobal") + .WithMany("Motions") + .HasForeignKey("MotionGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + + b.Navigation("MotionGlobal"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionCategory", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("MotionCategories") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.HasOne("MyOffice.Data.Models.Currencies.CurrencyGlobal", "Currency") + .WithMany() + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.Navigation("AccessRights"); + + b.Navigation("Categories"); + + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.Currency", b => + { + b.Navigation("Rates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.CurrencyGlobal", b => + { + b.Navigation("Accounts"); + + b.Navigation("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionAccount", b => + { + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionCategory", b => + { + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionGlobal", b => + { + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Navigation("AccountAccess"); + + b.Navigation("AccountCategories"); + + b.Navigation("AccountMotions"); + + b.Navigation("Currencies"); + + b.Navigation("MotionCategories"); + + b.Navigation("UserClaims"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230611145152_Motion.cs b/MyOffice.Migration.Postgres/Migrations/20230611145152_Motion.cs new file mode 100644 index 0000000..889370f --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230611145152_Motion.cs @@ -0,0 +1,213 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + /// + public partial class Motion : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_AccountMotions_Users_UserId", + table: "AccountMotions"); + + migrationBuilder.RenameColumn( + name: "AmountOut", + table: "AccountMotions", + newName: "AmountPlus"); + + migrationBuilder.RenameColumn( + name: "AmountIn", + table: "AccountMotions", + newName: "AmountMinus"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "AccountMotions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AddColumn( + name: "Description", + table: "AccountMotions", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "MotionId", + table: "AccountMotions", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.CreateTable( + name: "GlobalMotions", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GlobalMotions", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "MotionCategories", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + UserId = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MotionCategories", x => x.Id); + table.ForeignKey( + name: "FK_MotionCategories_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Motions", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + CategoryId = table.Column(type: "uuid", nullable: false), + MotionGlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Motions", x => x.Id); + table.ForeignKey( + name: "FK_Motions_GlobalMotions_MotionGlobalId", + column: x => x.MotionGlobalId, + principalTable: "GlobalMotions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Motions_MotionCategories_CategoryId", + column: x => x.CategoryId, + principalTable: "MotionCategories", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AccountMotions_MotionId", + table: "AccountMotions", + column: "MotionId"); + + migrationBuilder.CreateIndex( + name: "IX_MotionCategories_UserId", + table: "MotionCategories", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Motions_CategoryId", + table: "Motions", + column: "CategoryId"); + + migrationBuilder.CreateIndex( + name: "IX_Motions_MotionGlobalId", + table: "Motions", + column: "MotionGlobalId"); + + migrationBuilder.AddForeignKey( + name: "FK_AccountMotions_Motions_MotionId", + table: "AccountMotions", + column: "MotionId", + principalTable: "Motions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_AccountMotions_Users_UserId", + table: "AccountMotions", + column: "UserId", + principalTable: "Users", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_AccountMotions_Motions_MotionId", + table: "AccountMotions"); + + migrationBuilder.DropForeignKey( + name: "FK_AccountMotions_Users_UserId", + table: "AccountMotions"); + + migrationBuilder.DropTable( + name: "Motions"); + + migrationBuilder.DropTable( + name: "GlobalMotions"); + + migrationBuilder.DropTable( + name: "MotionCategories"); + + migrationBuilder.DropIndex( + name: "IX_AccountMotions_MotionId", + table: "AccountMotions"); + + migrationBuilder.DropColumn( + name: "Description", + table: "AccountMotions"); + + migrationBuilder.DropColumn( + name: "MotionId", + table: "AccountMotions"); + + migrationBuilder.RenameColumn( + name: "AmountPlus", + table: "AccountMotions", + newName: "AmountOut"); + + migrationBuilder.RenameColumn( + name: "AmountMinus", + table: "AccountMotions", + newName: "AmountIn"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "AccountMotions", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "AccountMotions", + type: "bigint", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid") + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + migrationBuilder.AddForeignKey( + name: "FK_AccountMotions_Users_UserId", + table: "AccountMotions", + column: "UserId", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230614175616_MotionCategoryFix.Designer.cs b/MyOffice.Migration.Postgres/Migrations/20230614175616_MotionCategoryFix.Designer.cs new file mode 100644 index 0000000..603f9c7 --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230614175616_MotionCategoryFix.Designer.cs @@ -0,0 +1,609 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MyOffice.DbContext; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20230614175616_MotionCategoryFix")] + partial class MotionCategoryFix + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:CollationDefinition:my_ci_collation", "en-u-ks-primary,en-u-ks-primary,icu,False") + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccess", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("IsAllowManage") + .HasColumnType("boolean"); + + b.Property("IsAllowRead") + .HasColumnType("boolean"); + + b.Property("IsAllowWrite") + .HasColumnType("boolean"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountAccesses"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("CategoryId"); + + b.ToTable("AccountAccountCategories"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AccountCategories"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountMotion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("AmountMinus") + .HasColumnType("numeric"); + + b.Property("AmountPlus") + .HasColumnType("numeric"); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("MotionId") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("MotionId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountMotions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.Currency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.HasIndex("UserId"); + + b.ToTable("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.CurrencyGlobal", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("DefaultQuantity") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Symbol") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("CurrencyGlobals"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.CurrencyRate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CurrencyId") + .HasColumnType("uuid"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("Rate") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("CurrencyRates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("MotionGlobalId") + .IsRequired() + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.HasIndex("MotionGlobalId"); + + b.ToTable("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("MotionCategories"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionGlobal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("GlobalMotions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("FirstName") + .HasColumnType("text"); + + b.Property("FullName") + .HasColumnType("text"); + + b.Property("IsEmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LastName") + .HasColumnType("text"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("Phone") + .HasColumnType("text"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("ExternalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Provider") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserClaims"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.HasOne("MyOffice.Data.Models.Currencies.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Accounts") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccess", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("AccessRights") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountAccess") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccountCategory", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("Categories") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Accounts.AccountCategory", "Category") + .WithMany("Accounts") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountCategories") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountMotion", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("Motions") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Motions.MotionAccount", "Motion") + .WithMany("Motions") + .HasForeignKey("MotionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", null) + .WithMany("AccountMotions") + .HasForeignKey("UserId"); + + b.Navigation("Account"); + + b.Navigation("Motion"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.Currency", b => + { + b.HasOne("MyOffice.Data.Models.Currencies.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Currencies") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("Currencies") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.CurrencyRate", b => + { + b.HasOne("MyOffice.Data.Models.Currencies.Currency", "Currency") + .WithMany("Rates") + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionAccount", b => + { + b.HasOne("MyOffice.Data.Models.Motions.MotionCategory", "Category") + .WithMany("Motions") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Motions.MotionGlobal", "MotionGlobal") + .WithMany("Motions") + .HasForeignKey("MotionGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + + b.Navigation("MotionGlobal"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionCategory", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("MotionCategories") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.HasOne("MyOffice.Data.Models.Currencies.CurrencyGlobal", "Currency") + .WithMany() + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.Navigation("AccessRights"); + + b.Navigation("Categories"); + + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.Currency", b => + { + b.Navigation("Rates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.CurrencyGlobal", b => + { + b.Navigation("Accounts"); + + b.Navigation("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionAccount", b => + { + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionCategory", b => + { + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionGlobal", b => + { + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Navigation("AccountAccess"); + + b.Navigation("AccountCategories"); + + b.Navigation("AccountMotions"); + + b.Navigation("Currencies"); + + b.Navigation("MotionCategories"); + + b.Navigation("UserClaims"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230614175616_MotionCategoryFix.cs b/MyOffice.Migration.Postgres/Migrations/20230614175616_MotionCategoryFix.cs new file mode 100644 index 0000000..cbedbe1 --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230614175616_MotionCategoryFix.cs @@ -0,0 +1,38 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + /// + public partial class MotionCategoryFix : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + /*migrationBuilder.AlterColumn( + name: "Id", + table: "AccountMotions", + type: "bigint", + nullable: false, + oldClrType: typeof(Guid), + oldType: "uuid") + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);*/ + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + /*migrationBuilder.AlterColumn( + name: "Id", + table: "AccountMotions", + type: "uuid", + nullable: false, + oldClrType: typeof(long), + oldType: "bigint") + .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);*/ + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230614181358_MotionCategoryFix2.Designer.cs b/MyOffice.Migration.Postgres/Migrations/20230614181358_MotionCategoryFix2.Designer.cs new file mode 100644 index 0000000..0b80ae7 --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230614181358_MotionCategoryFix2.Designer.cs @@ -0,0 +1,606 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MyOffice.DbContext; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20230614181358_MotionCategoryFix2")] + partial class MotionCategoryFix2 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:CollationDefinition:my_ci_collation", "en-u-ks-primary,en-u-ks-primary,icu,False") + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccess", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("IsAllowManage") + .HasColumnType("boolean"); + + b.Property("IsAllowRead") + .HasColumnType("boolean"); + + b.Property("IsAllowWrite") + .HasColumnType("boolean"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountAccesses"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("CategoryId"); + + b.ToTable("AccountAccountCategories"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AccountCategories"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountMotion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("AmountMinus") + .HasColumnType("numeric"); + + b.Property("AmountPlus") + .HasColumnType("numeric"); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("MotionId") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("MotionId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountMotions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.Currency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.HasIndex("UserId"); + + b.ToTable("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.CurrencyGlobal", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("DefaultQuantity") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Symbol") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("CurrencyGlobals"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.CurrencyRate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CurrencyId") + .HasColumnType("uuid"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("Rate") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("CurrencyRates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("MotionGlobalId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.HasIndex("MotionGlobalId"); + + b.ToTable("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("MotionCategories"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionGlobal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("GlobalMotions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("FirstName") + .HasColumnType("text"); + + b.Property("FullName") + .HasColumnType("text"); + + b.Property("IsEmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LastName") + .HasColumnType("text"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("Phone") + .HasColumnType("text"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("ExternalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Provider") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserClaims"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.HasOne("MyOffice.Data.Models.Currencies.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Accounts") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccess", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("AccessRights") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountAccess") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccountCategory", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("Categories") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Accounts.AccountCategory", "Category") + .WithMany("Accounts") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountCategories") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountMotion", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("Motions") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Motions.MotionAccount", "Motion") + .WithMany("Motions") + .HasForeignKey("MotionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", null) + .WithMany("AccountMotions") + .HasForeignKey("UserId"); + + b.Navigation("Account"); + + b.Navigation("Motion"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.Currency", b => + { + b.HasOne("MyOffice.Data.Models.Currencies.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Currencies") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("Currencies") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.CurrencyRate", b => + { + b.HasOne("MyOffice.Data.Models.Currencies.Currency", "Currency") + .WithMany("Rates") + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionAccount", b => + { + b.HasOne("MyOffice.Data.Models.Motions.MotionCategory", "Category") + .WithMany("Motions") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Motions.MotionGlobal", "MotionGlobal") + .WithMany("Motions") + .HasForeignKey("MotionGlobalId"); + + b.Navigation("Category"); + + b.Navigation("MotionGlobal"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionCategory", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("MotionCategories") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.HasOne("MyOffice.Data.Models.Currencies.CurrencyGlobal", "Currency") + .WithMany() + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.Navigation("AccessRights"); + + b.Navigation("Categories"); + + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.Currency", b => + { + b.Navigation("Rates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.CurrencyGlobal", b => + { + b.Navigation("Accounts"); + + b.Navigation("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionAccount", b => + { + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionCategory", b => + { + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionGlobal", b => + { + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Navigation("AccountAccess"); + + b.Navigation("AccountCategories"); + + b.Navigation("AccountMotions"); + + b.Navigation("Currencies"); + + b.Navigation("MotionCategories"); + + b.Navigation("UserClaims"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230614181358_MotionCategoryFix2.cs b/MyOffice.Migration.Postgres/Migrations/20230614181358_MotionCategoryFix2.cs new file mode 100644 index 0000000..615579e --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230614181358_MotionCategoryFix2.cs @@ -0,0 +1,60 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + /// + public partial class MotionCategoryFix2 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Motions_GlobalMotions_MotionGlobalId", + table: "Motions"); + + migrationBuilder.AlterColumn( + name: "MotionGlobalId", + table: "Motions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AddForeignKey( + name: "FK_Motions_GlobalMotions_MotionGlobalId", + table: "Motions", + column: "MotionGlobalId", + principalTable: "GlobalMotions", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Motions_GlobalMotions_MotionGlobalId", + table: "Motions"); + + migrationBuilder.AlterColumn( + name: "MotionGlobalId", + table: "Motions", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AddForeignKey( + name: "FK_Motions_GlobalMotions_MotionGlobalId", + table: "Motions", + column: "MotionGlobalId", + principalTable: "GlobalMotions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230614183224_MotionCategoryFix3.Designer.cs b/MyOffice.Migration.Postgres/Migrations/20230614183224_MotionCategoryFix3.Designer.cs new file mode 100644 index 0000000..dde6dec --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230614183224_MotionCategoryFix3.Designer.cs @@ -0,0 +1,608 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MyOffice.DbContext; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20230614183224_MotionCategoryFix3")] + partial class MotionCategoryFix3 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:CollationDefinition:my_ci_collation", "en-u-ks-primary,en-u-ks-primary,icu,False") + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccess", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("IsAllowManage") + .HasColumnType("boolean"); + + b.Property("IsAllowRead") + .HasColumnType("boolean"); + + b.Property("IsAllowWrite") + .HasColumnType("boolean"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountAccesses"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("CategoryId"); + + b.ToTable("AccountAccountCategories"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AccountCategories"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountMotion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("AmountMinus") + .HasColumnType("numeric"); + + b.Property("AmountPlus") + .HasColumnType("numeric"); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("MotionId") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("MotionId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountMotions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.Currency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.HasIndex("UserId"); + + b.ToTable("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.CurrencyGlobal", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("DefaultQuantity") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Symbol") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("CurrencyGlobals"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.CurrencyRate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CurrencyId") + .HasColumnType("uuid"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("Rate") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("CurrencyRates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("MotionGlobalId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.HasIndex("MotionGlobalId"); + + b.ToTable("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("MotionCategories"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionGlobal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("GlobalMotions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("FirstName") + .HasColumnType("text"); + + b.Property("FullName") + .HasColumnType("text"); + + b.Property("IsEmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LastName") + .HasColumnType("text"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("Phone") + .HasColumnType("text"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("ExternalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Provider") + .IsRequired() + .HasColumnType("text") + .UseCollation("my_ci_collation"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserClaims"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.HasOne("MyOffice.Data.Models.Currencies.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Accounts") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccess", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("AccessRights") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountAccess") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccountCategory", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("Categories") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Accounts.AccountCategory", "Category") + .WithMany("Accounts") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountCategories") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountMotion", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("Motions") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Motions.MotionAccount", "Motion") + .WithMany("Motions") + .HasForeignKey("MotionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", null) + .WithMany("AccountMotions") + .HasForeignKey("UserId"); + + b.Navigation("Account"); + + b.Navigation("Motion"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.Currency", b => + { + b.HasOne("MyOffice.Data.Models.Currencies.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Currencies") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("Currencies") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.CurrencyRate", b => + { + b.HasOne("MyOffice.Data.Models.Currencies.Currency", "Currency") + .WithMany("Rates") + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionAccount", b => + { + b.HasOne("MyOffice.Data.Models.Motions.MotionCategory", "Category") + .WithMany("Motions") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Motions.MotionGlobal", "MotionGlobal") + .WithMany("Motions") + .HasForeignKey("MotionGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + + b.Navigation("MotionGlobal"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionCategory", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("MotionCategories") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.HasOne("MyOffice.Data.Models.Currencies.CurrencyGlobal", "Currency") + .WithMany() + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.Navigation("AccessRights"); + + b.Navigation("Categories"); + + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.Currency", b => + { + b.Navigation("Rates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.CurrencyGlobal", b => + { + b.Navigation("Accounts"); + + b.Navigation("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionAccount", b => + { + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionCategory", b => + { + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionGlobal", b => + { + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.Navigation("AccountAccess"); + + b.Navigation("AccountCategories"); + + b.Navigation("AccountMotions"); + + b.Navigation("Currencies"); + + b.Navigation("MotionCategories"); + + b.Navigation("UserClaims"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/20230614183224_MotionCategoryFix3.cs b/MyOffice.Migration.Postgres/Migrations/20230614183224_MotionCategoryFix3.cs new file mode 100644 index 0000000..ce4ef32 --- /dev/null +++ b/MyOffice.Migration.Postgres/Migrations/20230614183224_MotionCategoryFix3.cs @@ -0,0 +1,60 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MyOffice.Migrations.Postgres.Migrations +{ + /// + public partial class MotionCategoryFix3 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Motions_GlobalMotions_MotionGlobalId", + table: "Motions"); + + migrationBuilder.AlterColumn( + name: "MotionGlobalId", + table: "Motions", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AddForeignKey( + name: "FK_Motions_GlobalMotions_MotionGlobalId", + table: "Motions", + column: "MotionGlobalId", + principalTable: "GlobalMotions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Motions_GlobalMotions_MotionGlobalId", + table: "Motions"); + + migrationBuilder.AlterColumn( + name: "MotionGlobalId", + table: "Motions", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AddForeignKey( + name: "FK_Motions_GlobalMotions_MotionGlobalId", + table: "Motions", + column: "MotionGlobalId", + principalTable: "GlobalMotions", + principalColumn: "Id"); + } + } +} diff --git a/MyOffice.Migration.Postgres/Migrations/AppDbContextModelSnapshot.cs b/MyOffice.Migration.Postgres/Migrations/AppDbContextModelSnapshot.cs index 0a84170..bf74d8e 100644 --- a/MyOffice.Migration.Postgres/Migrations/AppDbContextModelSnapshot.cs +++ b/MyOffice.Migration.Postgres/Migrations/AppDbContextModelSnapshot.cs @@ -1,9 +1,9 @@ // using System; -using MyOffice.DbContext; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MyOffice.DbContext; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable @@ -23,12 +23,291 @@ namespace MyOffice.Migrations.Postgres.Migrations NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccess", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("IsAllowManage") + .HasColumnType("boolean"); + + b.Property("IsAllowRead") + .HasColumnType("boolean"); + + b.Property("IsAllowWrite") + .HasColumnType("boolean"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountAccesses"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("CategoryId"); + + b.ToTable("AccountAccountCategories"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AccountCategories"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountMotion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("AmountMinus") + .HasColumnType("numeric"); + + b.Property("AmountPlus") + .HasColumnType("numeric"); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("MotionId") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("MotionId"); + + b.HasIndex("UserId"); + + b.ToTable("AccountMotions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.Currency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CurrencyGlobalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyGlobalId"); + + b.HasIndex("UserId"); + + b.ToTable("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.CurrencyGlobal", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("DefaultQuantity") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Symbol") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("CurrencyGlobals"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.CurrencyRate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CurrencyId") + .HasColumnType("uuid"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("Rate") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.HasIndex("CurrencyId"); + + b.ToTable("CurrencyRates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("MotionGlobalId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.HasIndex("MotionGlobalId"); + + b.ToTable("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("MotionCategories"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionGlobal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("GlobalMotions"); + }); + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid"); + b.Property("CurrencyId") + .IsRequired() + .HasColumnType("text"); + b.Property("Email") .IsRequired() .HasColumnType("text") @@ -60,6 +339,8 @@ namespace MyOffice.Migrations.Postgres.Migrations b.HasKey("Id"); + b.HasIndex("CurrencyId"); + b.ToTable("Users"); }); @@ -98,6 +379,160 @@ namespace MyOffice.Migrations.Postgres.Migrations b.ToTable("UserClaims"); }); + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.HasOne("MyOffice.Data.Models.Currencies.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Accounts") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccess", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("AccessRights") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountAccess") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountAccountCategory", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("Categories") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Accounts.AccountCategory", "Category") + .WithMany("Accounts") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("AccountCategories") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountMotion", b => + { + b.HasOne("MyOffice.Data.Models.Accounts.Account", "Account") + .WithMany("Motions") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Motions.MotionAccount", "Motion") + .WithMany("Motions") + .HasForeignKey("MotionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", null) + .WithMany("AccountMotions") + .HasForeignKey("UserId"); + + b.Navigation("Account"); + + b.Navigation("Motion"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.Currency", b => + { + b.HasOne("MyOffice.Data.Models.Currencies.CurrencyGlobal", "CurrencyGlobal") + .WithMany("Currencies") + .HasForeignKey("CurrencyGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("Currencies") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurrencyGlobal"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.CurrencyRate", b => + { + b.HasOne("MyOffice.Data.Models.Currencies.Currency", "Currency") + .WithMany("Rates") + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionAccount", b => + { + b.HasOne("MyOffice.Data.Models.Motions.MotionCategory", "Category") + .WithMany("Motions") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MyOffice.Data.Models.Motions.MotionGlobal", "MotionGlobal") + .WithMany("Motions") + .HasForeignKey("MotionGlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + + b.Navigation("MotionGlobal"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionCategory", b => + { + b.HasOne("MyOffice.Data.Models.Users.User", "User") + .WithMany("MotionCategories") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => + { + b.HasOne("MyOffice.Data.Models.Currencies.CurrencyGlobal", "Currency") + .WithMany() + .HasForeignKey("CurrencyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Currency"); + }); + modelBuilder.Entity("MyOffice.Data.Models.Users.UserExternal", b => { b.HasOne("MyOffice.Data.Models.Users.User", "User") @@ -109,8 +544,59 @@ namespace MyOffice.Migrations.Postgres.Migrations b.Navigation("User"); }); + modelBuilder.Entity("MyOffice.Data.Models.Accounts.Account", b => + { + b.Navigation("AccessRights"); + + b.Navigation("Categories"); + + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Accounts.AccountCategory", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.Currency", b => + { + b.Navigation("Rates"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Currencies.CurrencyGlobal", b => + { + b.Navigation("Accounts"); + + b.Navigation("Currencies"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionAccount", b => + { + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionCategory", b => + { + b.Navigation("Motions"); + }); + + modelBuilder.Entity("MyOffice.Data.Models.Motions.MotionGlobal", b => + { + b.Navigation("Motions"); + }); + modelBuilder.Entity("MyOffice.Data.Models.Users.User", b => { + b.Navigation("AccountAccess"); + + b.Navigation("AccountCategories"); + + b.Navigation("AccountMotions"); + + b.Navigation("Currencies"); + + b.Navigation("MotionCategories"); + b.Navigation("UserClaims"); }); #pragma warning restore 612, 618 diff --git a/MyOffice.SPA/angular.json b/MyOffice.SPA/angular.json index 6e87b16..2a76c77 100644 --- a/MyOffice.SPA/angular.json +++ b/MyOffice.SPA/angular.json @@ -82,7 +82,8 @@ }, "defaultConfiguration": "development", "options": { - "proxyConfig": "src/proxy.conf.js" + "proxyConfig": "src/proxy.conf.js", + "port": 4300 } }, "extract-i18n": { diff --git a/MyOffice.SPA/package.json b/MyOffice.SPA/package.json index 6d770dd..a6496ce 100644 --- a/MyOffice.SPA/package.json +++ b/MyOffice.SPA/package.json @@ -4,8 +4,7 @@ "scripts": { "ng": "ng", "start": "ng serve", - "start-ssl": - "ng serve --ssl --ssl-cert %APPDATA%\\ASP.NET\\https\\%npm_package_name%.pem --ssl-key %APPDATA%\\ASP.NET\\https\\%npm_package_name%.key", + "start-ssl": "ng serve --ssl --ssl-cert %APPDATA%\\ASP.NET\\https\\%npm_package_name%.pem --ssl-key %APPDATA%\\ASP.NET\\https\\%npm_package_name%.key", "build": "ng build", "watch": "ng build --watch --configuration development", "test": "ng test", @@ -26,6 +25,7 @@ "@angular/platform-browser": "^15.2.0", "@angular/platform-browser-dynamic": "^15.2.0", "@angular/router": "^15.2.0", + "@auth0/auth0-angular": "^2.0.2", "@ckeditor/ckeditor5-angular": "^5.1.0", "@ckeditor/ckeditor5-build-classic": "^36.0.1", "@danielmoncada/angular-datetime-picker": "^15.0.2", @@ -44,11 +44,10 @@ "@swimlane/ngx-charts": "^20.1.2", "@swimlane/ngx-datatable": "^20.1.0", "@types/d3-shape": "^3.1.1", - "angular-oauth2-oidc": "^15.0.1", "angular-auth-oidc-client": "^15.0.3", - "@auth0/auth0-angular": "^2.0.2", "angular-feather": "^6.5.0", "angular-gauge": "^4.0.0", + "angular-oauth2-oidc": "^15.0.1", "apexcharts": "^3.37.0", "bootstrap": "^5.2.3", "browser-sync": "^2.27.5", @@ -59,6 +58,7 @@ "ng-apexcharts": "^1.7.4", "ng-image-fullscreen-view": "^3.0.3", "ng2-charts": "^4.1.1", + "ngx-currency": "^3.0.0", "ngx-dropzone-wrapper": "^13.0.0", "ngx-echarts": "^15.0.1", "ngx-gauge": "^7.0.0", diff --git a/MyOffice.SPA/src/app/api-routes.ts b/MyOffice.SPA/src/app/api-routes.ts index de957c2..87d7473 100644 --- a/MyOffice.SPA/src/app/api-routes.ts +++ b/MyOffice.SPA/src/app/api-routes.ts @@ -1,7 +1,30 @@ -export enum ApiRoutes { - UserRegister = '/api/user/register', - UserLogin = '/api/user/login', - UserProfile = '/api/user/profile', - UserAttach = '/api/user/attach', - UserDeattach = '/api/user/deattach', +export class ApiRoutes { + static UserRegister = '/api/user/register'; + static UserLogin = '/api/user/login'; + static UserProfile = '/api/user/profile'; + static UserAttach = '/api/user/attach'; + static UserDeattach = '/api/user/deattach'; + + static GeneralCurrencies = '/api/general/currencies'; + static SettingsCurrencies = '/api/settings/currencies'; + static SettingsCurrenciesRate = '/api/settings/currencies/:id/rate'; + + static SettingsAccountCategories = '/api/settings/account-categories'; + static SettingsAccountCategory = '/api/settings/account-categories/:id'; + + static SettingsAccounts = '/api/settings/accounts'; + static SettingsAccount = '/api/settings/accounts/:id'; + static SettingsAccountAccountCategory = '/api/settings/accounts/:id/category/:categoryId'; + + static SettingsMotionCategories = '/api/settings/motion-categories'; + static SettingsMotionCategory = '/api/settings/motion-categories/:id'; + + static SettingsMotions = '/api/settings/motions'; + static SettingsMotion = '/api/settings/motions/:id'; + + static Accounts = '/api/accounts'; + static Account = '/api/accounts/:id'; + + static Motions = '/api/accounts/:id/motions'; + static Motion = '/api/accounts/:id/motions/:motionId'; } diff --git a/MyOffice.SPA/src/app/app.module.ts b/MyOffice.SPA/src/app/app.module.ts index 9f28e44..9a93330 100644 --- a/MyOffice.SPA/src/app/app.module.ts +++ b/MyOffice.SPA/src/app/app.module.ts @@ -25,6 +25,7 @@ import { AuthLayoutComponent } from './layout/app-layout/auth-layout/auth-layout import { MainLayoutComponent } from './layout/app-layout/main-layout/main-layout.component'; import { ErrorInterceptor } from './core/interceptor/error.interceptor'; import { JwtInterceptor } from './core/interceptor/jwt.interceptor'; +import { UpdateDateHttpInterceptor } from './core/interceptor/update.date.http.interceptor '; export function createTranslateLoader(http: HttpClient) { return new TranslateHttpLoader(http, 'assets/i18n/', '.json'); @@ -63,6 +64,7 @@ export function createTranslateLoader(http: HttpClient) { { provide: LocationStrategy, useClass: HashLocationStrategy }, { provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true }, { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true }, + { provide: HTTP_INTERCEPTORS, useClass: UpdateDateHttpInterceptor, multi: true }, ], bootstrap: [AppComponent], }) diff --git a/MyOffice.SPA/src/app/authentication/signin/signin.component.html b/MyOffice.SPA/src/app/authentication/signin/signin.component.html index 3c38680..186cd40 100644 --- a/MyOffice.SPA/src/app/authentication/signin/signin.component.html +++ b/MyOffice.SPA/src/app/authentication/signin/signin.component.html @@ -73,7 +73,7 @@