From 0a6199adeaf43c48c9f8a234893ada41f30d58ea Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 30 Apr 2021 21:28:13 +0000 Subject: [PATCH] --- .vscode/launch.json | 2 +- .../AyaNova/Controllers/CustomerController.cs | 56 ++++++++++--------- server/AyaNova/util/Seeder.cs | 12 ++++ 3 files changed, 42 insertions(+), 28 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 0e2049e9..8fd97968 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": "false", + "AYANOVA_SERVER_TEST_MODE": "true", "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/CustomerController.cs b/server/AyaNova/Controllers/CustomerController.cs index 8b0a7e72..314705ad 100644 --- a/server/AyaNova/Controllers/CustomerController.cs +++ b/server/AyaNova/Controllers/CustomerController.cs @@ -169,11 +169,12 @@ namespace AyaNova.Api.Controllers } /// - /// Get billing address for this customer + /// Get addresses of interest for Customer id provided + /// (postal, physical, headoffice postal if billheadoffice=true) /// /// - /// Billing address (including headoffice if bill to head office = true) - [HttpGet("bill-to-address/{id}")] + /// Multiple addresses + [HttpGet("address/{id}")] public async Task GetCustomerBillToAddress([FromRoute] long id) { if (!serverState.IsOpen) @@ -193,34 +194,35 @@ namespace AyaNova.Api.Controllers return Ok(ApiOkResponse.Response(new { - customer = new PostalAddressRecord(cust.PostAddress, cust.PostCity, cust.PostRegion, cust.PostCountry, cust.PostCode), - headoffice = (head == null ? new PostalAddressRecord(head.PostAddress, head.PostCity, head.PostRegion, head.PostCountry, head.PostCode) : new PostalAddressRecord("", "", "", "", "")) + customerpost = new PostalAddressRecord(cust.PostAddress, cust.PostCity, cust.PostRegion, cust.PostCountry, cust.PostCode), + customerphys = new AddressRecord(cust.Address, cust.City, cust.Region, cust.Country, cust.Latitude, cust.Longitude), + headofficepost = (head == null ? new PostalAddressRecord(head.PostAddress, head.PostCity, head.PostRegion, head.PostCountry, head.PostCode) : new PostalAddressRecord("", "", "", "", "")) })); } - /// - /// Get service (physical) address for this customer - /// - /// - /// Service address - [HttpGet("service-address/{id}")] - public async Task GetCustomerServiceAddress([FromRoute] long id) - { - if (!serverState.IsOpen) - return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); - if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.Customer)) - return StatusCode(403, new ApiNotAuthorizedResponse()); - if (!ModelState.IsValid) - return BadRequest(new ApiErrorResponse(ModelState)); - var cust = await ct.Customer.AsNoTracking().Where(x => x.Id == id).FirstOrDefaultAsync(); - if (cust == null) - return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND)); + // /// + // /// Get service (physical) address for this customer + // /// + // /// + // /// Service address + // [HttpGet("service-address/{id}")] + // public async Task GetCustomerServiceAddress([FromRoute] long id) + // { + // if (!serverState.IsOpen) + // return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); + // if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.Customer)) + // return StatusCode(403, new ApiNotAuthorizedResponse()); + // if (!ModelState.IsValid) + // return BadRequest(new ApiErrorResponse(ModelState)); + // var cust = await ct.Customer.AsNoTracking().Where(x => x.Id == id).FirstOrDefaultAsync(); + // if (cust == null) + // return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND)); - return Ok(ApiOkResponse.Response(new - { - customer = new AddressRecord(cust.Address, cust.City, cust.Region, cust.Country, cust.Latitude, cust.Longitude) - })); - } + // return Ok(ApiOkResponse.Response(new + // { + // customer = new AddressRecord(cust.Address, cust.City, cust.Region, cust.Country, cust.Latitude, cust.Longitude) + // })); + // } diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs index 14032d20..ab070ecc 100644 --- a/server/AyaNova/util/Seeder.cs +++ b/server/AyaNova/util/Seeder.cs @@ -1373,6 +1373,12 @@ namespace AyaNova.Util o.Region = Fake.Address.State(); o.Country = Fake.Address.Country(); + o.PostAddress = Fake.Address.StreetAddress(); + o.PostCity = o.City; + o.PostRegion = o.Region; + o.PostCountry = o.Country; + o.PostCode = Fake.Address.ZipCode(); + o.Phone1 = Fake.Phone.PhoneNumber(); o.Phone2 = Fake.Phone.PhoneNumber(); o.Phone3 = Fake.Phone.PhoneNumber(); @@ -1438,6 +1444,12 @@ namespace AyaNova.Util o.Region = Fake.Address.State(); o.Country = Fake.Address.Country(); + o.PostAddress = Fake.Address.StreetAddress(); + o.PostCity = o.City; + o.PostRegion = o.Region; + o.PostCountry = o.Country; + o.PostCode = Fake.Address.ZipCode(); + o.Phone1 = Fake.Phone.PhoneNumber(); o.Phone2 = Fake.Phone.PhoneNumber(); o.Phone3 = Fake.Phone.PhoneNumber();