From 045f60e37318357a592ab0fe6e37d774aa765d23 Mon Sep 17 00:00:00 2001 From: Alexandr Sulimov Date: Fri, 1 Dec 2023 20:47:42 +0200 Subject: [PATCH] fix --- .gitignore | 3 + MyOffice.Core/Interfaces/IDataModel.cs | 6 + MyOffice.Core/Interfaces/IDataModelDto.cs | 6 + MyOffice.Data.Models/Accounts/Account.cs | 5 +- .../Account/AccountRepository.cs | 10 +- MyOffice.SPA/src/app/model/account.model.ts | 1 + .../settings/account/account.component.html | 2 +- .../pages/settings/item/item.component.html | 9 + .../app/pages/settings/item/item.component.ts | 2 + .../Account/AccountService.Access.cs | 176 +++++ .../Account/AccountService.Account.cs | 209 +++++ .../Account/AccountService.AccountCategory.cs | 114 +++ .../Account/AccountService.Motion.cs | 178 +++++ MyOffice.Services/Account/AccountService.cs | 733 ++---------------- .../Account/Domain/AccountAccessDto.cs | 45 +- .../Account/Domain/AccountDetailedDto.cs | 16 +- .../Account/Domain/AccountDto.cs | 76 +- .../Account/Domain/ItemCategoryDto.cs | 7 +- MyOffice.Services/Account/Domain/UserDto.cs | 6 +- MyOffice.Services/Currency/CurrencyService.cs | 4 +- .../Currency/Domain/CurrencyDto.cs | 11 +- .../Currency/Domain/CurrencyRateDto.cs | 2 +- .../Currency/Domain/CurrencyWithRateDto.cs | 4 +- MyOffice.Services/Item/ItemService.cs | 1 - .../Mapper/AccountServiceProfile.cs | 21 - .../Mapper/AutomapperExtensions.cs | 17 + MyOffice.Services/Mapper/BaseMappingAction.cs | 12 + MyOffice.Services/Mapper/BaseProfile.cs | 13 + MyOffice.Services/MyOffice.Services.csproj | 1 - MyOffice.Web/Controllers/BaseApiController.cs | 1 - .../SettingsAccountCategoryController.cs | 121 +++ .../Controllers/SettingsAccountController.cs | 96 +-- MyOffice.Web/Infrastructure/RouteHelper.cs | 50 ++ .../Models/Account/AccessRightsViewModel.cs | 33 +- .../Account/AccountCategoryViewModel.cs | 2 +- .../Models/Account/AccountViewModel.cs | 126 ++- .../Models/Account/AccountViewModelProfile.cs | 40 +- MyOffice.Web/Models/User/UserViewModel.cs | 32 +- MyOffice.Web/Program.cs | 6 +- 39 files changed, 1252 insertions(+), 945 deletions(-) create mode 100644 MyOffice.Core/Interfaces/IDataModel.cs create mode 100644 MyOffice.Core/Interfaces/IDataModelDto.cs create mode 100644 MyOffice.Services/Account/AccountService.Access.cs create mode 100644 MyOffice.Services/Account/AccountService.Account.cs create mode 100644 MyOffice.Services/Account/AccountService.AccountCategory.cs create mode 100644 MyOffice.Services/Account/AccountService.Motion.cs create mode 100644 MyOffice.Services/Mapper/AutomapperExtensions.cs create mode 100644 MyOffice.Services/Mapper/BaseMappingAction.cs create mode 100644 MyOffice.Services/Mapper/BaseProfile.cs create mode 100644 MyOffice.Web/Controllers/SettingsAccountCategoryController.cs create mode 100644 MyOffice.Web/Infrastructure/RouteHelper.cs diff --git a/.gitignore b/.gitignore index d5a3311..79bb074 100644 --- a/.gitignore +++ b/.gitignore @@ -359,6 +359,8 @@ MigrationBackup/ # Ionide (cross platform F# VS Code tools) working folder .ionide/ +.vscode/ + /MyOffice.SPA/.vscode /MyOffice.SPA/dist/ /MyOffice.SPA/src/environments/environment.ts @@ -382,3 +384,4 @@ package-lock.json /MyOffice.Shared/appsettings.shared.Production.json /linux_deploy_mybank.bat /linux_deploy_office.bat +linux_deploy_office_public.bat diff --git a/MyOffice.Core/Interfaces/IDataModel.cs b/MyOffice.Core/Interfaces/IDataModel.cs new file mode 100644 index 0000000..586eae7 --- /dev/null +++ b/MyOffice.Core/Interfaces/IDataModel.cs @@ -0,0 +1,6 @@ +namespace MyOffice.Core; + +public interface IDataModel +{ + +} diff --git a/MyOffice.Core/Interfaces/IDataModelDto.cs b/MyOffice.Core/Interfaces/IDataModelDto.cs new file mode 100644 index 0000000..073a84b --- /dev/null +++ b/MyOffice.Core/Interfaces/IDataModelDto.cs @@ -0,0 +1,6 @@ +namespace MyOffice.Core; + +public interface IDataModelDto where TSource : IDataModel +{ + +} diff --git a/MyOffice.Data.Models/Accounts/Account.cs b/MyOffice.Data.Models/Accounts/Account.cs index 0375ef9..9048af0 100644 --- a/MyOffice.Data.Models/Accounts/Account.cs +++ b/MyOffice.Data.Models/Accounts/Account.cs @@ -1,9 +1,10 @@ namespace MyOffice.Data.Models.Accounts; using Currencies; +using MyOffice.Core; using MyOffice.Data.Models.Users; -public class Account +public class Account: IDataModel { public Guid Id { get; set; } public string CurrencyGlobalId { get; set; } = null!; @@ -17,7 +18,7 @@ public class Account public IEnumerable? Invites { get; set; } } -public class AccountDetailed +public class AccountDetailed: IDataModel { public Account Account { get; set; } = null!; public decimal TotalPlus { get; set; } diff --git a/MyOffice.Data.Repositories/Account/AccountRepository.cs b/MyOffice.Data.Repositories/Account/AccountRepository.cs index 3feedab..8471be0 100644 --- a/MyOffice.Data.Repositories/Account/AccountRepository.cs +++ b/MyOffice.Data.Repositories/Account/AccountRepository.cs @@ -21,11 +21,15 @@ public class AccountRepository : AppRepository, IAccountRepository { return _context.Accounts! .Include(x => x.CurrencyGlobal) - .Include(x => x.Categories!.Where(x => x.Category.UserId == userId))! + // categories created with current user + .Include(x => x.Categories!.Where(c => c.Category.UserId == userId))! .ThenInclude(x => x.Category) - .Include(x => x.AccessRights)! + // access rights created with current user + .Include(x => x.AccessRights!.Where(a => a.OwnerId == userId))! .ThenInclude(x => x.User) - .Include(x => x.Motions)! + // require only one motions to check if can to delete account + .Include(x => x.Motions!.Take(1))! + // only accounts with access to current user .Where(x => x.AccessRights!.Any(a => a.UserId == userId)) .ToList(); } diff --git a/MyOffice.SPA/src/app/model/account.model.ts b/MyOffice.SPA/src/app/model/account.model.ts index 4e4cf5d..f617014 100644 --- a/MyOffice.SPA/src/app/model/account.model.ts +++ b/MyOffice.SPA/src/app/model/account.model.ts @@ -7,6 +7,7 @@ export interface AccountModel { currencyId?: string, currencyName?: string, type?: string, + allowWrite: boolean, allowDelete: boolean, allowManage: boolean, categories?: AccountCategoryModel[], diff --git a/MyOffice.SPA/src/app/pages/settings/account/account.component.html b/MyOffice.SPA/src/app/pages/settings/account/account.component.html index bdca80e..7f820bc 100644 --- a/MyOffice.SPA/src/app/pages/settings/account/account.component.html +++ b/MyOffice.SPA/src/app/pages/settings/account/account.component.html @@ -38,7 +38,7 @@ {{account.currencyId}} {{account.type}} -