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}} -