From 98253526f7825ac2da962d4e8e0f23cdff185c9e Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 2 Dec 2020 19:45:00 +0000 Subject: [PATCH] --- .vscode/launch.json | 2 +- server/AyaNova/Controllers/UserController.cs | 32 +++++++++++++++++++- server/AyaNova/util/Seeder.cs | 14 ++++++--- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 8fd97968..0e2049e9 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -53,7 +53,7 @@ "AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles", "AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles", "AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles", - "AYANOVA_SERVER_TEST_MODE": "true", + "AYANOVA_SERVER_TEST_MODE": "false", "AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small", "AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7", "AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\" diff --git a/server/AyaNova/Controllers/UserController.cs b/server/AyaNova/Controllers/UserController.cs index 8e4dd4e7..2ba4003d 100644 --- a/server/AyaNova/Controllers/UserController.cs +++ b/server/AyaNova/Controllers/UserController.cs @@ -271,7 +271,7 @@ namespace AyaNova.Api.Controllers /// /// Customer contact users [HttpGet("customer-contacts/{customerId}")] - public async Task GetClientContactList(long customerId) + public async Task GetCustomerContactList(long customerId) { if (!serverState.IsOpen) return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); @@ -295,6 +295,36 @@ namespace AyaNova.Api.Controllers return Ok(ApiOkResponse.Response(ret)); } + /// + /// Get list of HeadOffice Contact Users + /// (Rights to HeadOffice object required) + /// + /// HeadOffice contact users + [HttpGet("head-office-contacts/{headofficeId}")] + public async Task GetHeadOfficeContactList(long headofficeId) + { + if (!serverState.IsOpen) + return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); + + if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.HeadOffice)) + return StatusCode(403, new ApiNotAuthorizedResponse()); + + var ret = await ct.User.Include(o => o.UserOptions).Where(z => z.UserType == UserType.HeadOffice && z.HeadOfficeId == headofficeId).Select(z => new + { + Id = z.Id, + Active = z.Active, + Name = z.Name, + UserType = z.UserType, + LastLogin = z.LastLogin, + EmailAddress = z.UserOptions.EmailAddress, + Phone1 = z.UserOptions.Phone1, + Phone2 = z.UserOptions.Phone2, + Phone3 = z.UserOptions.Phone3 + + }).ToListAsync(); + return Ok(ApiOkResponse.Response(ret)); + } + /// diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs index 47ddd43a..ee3c2c91 100644 --- a/server/AyaNova/util/Seeder.cs +++ b/server/AyaNova/util/Seeder.cs @@ -285,7 +285,7 @@ namespace AyaNova.Util //CUSTOMERS await GenSeedCustomerAsync(log, 500); - //HEAD-OFFICES + //HEAD-OFFICES await GenSeedHeadOfficeAsync(log, 20); //PERF @@ -359,7 +359,7 @@ namespace AyaNova.Util //CUSTOMERS await GenSeedCustomerAsync(log, 5000); - //HEAD-OFFICES + //HEAD-OFFICES await GenSeedHeadOfficeAsync(log, 30); //PERF @@ -433,7 +433,7 @@ namespace AyaNova.Util //CUSTOMERS await GenSeedCustomerAsync(log, 20000); - //HEAD-OFFICES + //HEAD-OFFICES await GenSeedHeadOfficeAsync(log, 40); //PERF @@ -586,8 +586,12 @@ namespace AyaNova.Util - public async Task GenSeedUserAsync(ILogger log, int count, AuthorizationRoles roles, UserType userType, - bool active = true, string login = null, string password = null, long translationId = 0, List tags = null, long? vendorId = null, long? customerId = null, long? headofficeId = null) + public async Task GenSeedUserAsync( + ILogger log, int count, AuthorizationRoles roles, UserType userType, + bool active = true, string login = null, string password = null, + long translationId = 0, List tags = null, + long? vendorId = null, long? customerId = null, long? headofficeId = null + ) { if (translationId == 0) translationId = ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID;