Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
- Application permission handling and administration
- Emedia management
- Promenade navigation management
- Card renewal requests

### Changed
- Default to only logging Warnings for Microsoft and System namespaces
Expand Down
7 changes: 7 additions & 0 deletions ocuda.sln
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlideUploader", "src\SlideU
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Models", "src\Models\Models.csproj", "{C01EBE34-9964-4CED-A775-4D2139443132}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PolarisHelper", "src\PolarisHelper\PolarisHelper.csproj", "{E11E3598-BE6D-C9D8-D480-4EE48E7F4120}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -171,6 +173,10 @@ Global
{C01EBE34-9964-4CED-A775-4D2139443132}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C01EBE34-9964-4CED-A775-4D2139443132}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C01EBE34-9964-4CED-A775-4D2139443132}.Release|Any CPU.Build.0 = Release|Any CPU
{E11E3598-BE6D-C9D8-D480-4EE48E7F4120}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E11E3598-BE6D-C9D8-D480-4EE48E7F4120}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E11E3598-BE6D-C9D8-D480-4EE48E7F4120}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E11E3598-BE6D-C9D8-D480-4EE48E7F4120}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -199,6 +205,7 @@ Global
{28C9B95E-DD9B-458B-86EC-37B265D66181} = {1C0384E0-C8AD-46D9-9319-C75D67E6474E}
{0DF031C8-95B2-48D1-ACD9-01E56B10F3D6} = {FC70E8FE-76E9-4D23-8D85-F219DD8BAC37}
{C01EBE34-9964-4CED-A775-4D2139443132} = {FC70E8FE-76E9-4D23-8D85-F219DD8BAC37}
{E11E3598-BE6D-C9D8-D480-4EE48E7F4120} = {FC70E8FE-76E9-4D23-8D85-F219DD8BAC37}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E2592F73-781B-49DC-8020-540473F814F7}
Expand Down
13 changes: 13 additions & 0 deletions src/Models/AddressLookupResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Collections.Generic;

namespace Ocuda.Models
{
public class AddressLookupResult
{
public string Error { get; set; }
public IEnumerable<string> Residents { get; set; }
public string PostalCode { get; set; }
public string StreetAddress1 { get; set; }
public bool Success { get; set; }
}
}
1 change: 1 addition & 0 deletions src/Models/Customer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class Customer
public DateTime? AddressVerificationDate { get; set; }
public DateTime? BirthDate { get; set; }
public string BlockingNotes { get; set; }
public double ChargeBalance { get; set; }
public int CustomerCodeId { get; set; }
public string CustomerIdNumber { get; set; }
public string EmailAddress { get; set; }
Expand Down
8 changes: 8 additions & 0 deletions src/Models/CustomerBlock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Ocuda.Models
{
public class CustomerBlock
{
public int? BlockId { get; set; }
public string Description { get; set; }
}
}
63 changes: 63 additions & 0 deletions src/Ops.Controllers/ApiController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
using System.Web;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Ocuda.Models;
using Ocuda.Ops.Controllers.Areas.ContentManagement;
using Ocuda.Ops.Models;
using Ocuda.Ops.Models.Entities;
Expand All @@ -20,36 +25,47 @@ public class ApiController : Controller
private readonly IApiKeyService _apiKeyService;
private readonly IAuthorizationService _authorizationService;
private readonly IDigitalDisplayService _digitalDisplayService;
private readonly HttpClient _httpClient;
private readonly ILdapService _ldapService;
private readonly ILogger _logger;
private readonly IPermissionGroupService _permissionGroupService;
private readonly ISiteSettingService _siteSettingService;
private readonly IUserService _userService;

public ApiController(IApiKeyService apiKeyService,
IAuthorizationService authorizationService,
IDigitalDisplayService digitalDisplayService,
HttpClient httpClient,
ILdapService ldapService,
ILogger<ApiController> logger,
IPermissionGroupService permissionGroupService,
ISiteSettingService siteSettingService,
IUserService userService)
{
ArgumentNullException.ThrowIfNull(apiKeyService);
ArgumentNullException.ThrowIfNull(authorizationService);
ArgumentNullException.ThrowIfNull(digitalDisplayService);
ArgumentNullException.ThrowIfNull(httpClient);
ArgumentNullException.ThrowIfNull(ldapService);
ArgumentNullException.ThrowIfNull(logger);
ArgumentNullException.ThrowIfNull(permissionGroupService);
ArgumentNullException.ThrowIfNull(siteSettingService);
ArgumentNullException.ThrowIfNull(userService);

_apiKeyService = apiKeyService;
_authorizationService = authorizationService;
_digitalDisplayService = digitalDisplayService;
_httpClient = httpClient;
_ldapService = ldapService;
_logger = logger;
_permissionGroupService = permissionGroupService;
_siteSettingService = siteSettingService;
_userService = userService;
}

public static string Name
{ get { return "Api"; } }

private static JsonResponse ErrorJobResult(string message)
{
return new JsonResponse
Expand All @@ -60,6 +76,53 @@ private static JsonResponse ErrorJobResult(string message)
};
}

public async Task<AddressLookupResult> AddressLookup(string address, string zip)
{
var addressLookupPath = await _siteSettingService.GetSettingStringAsync(Models
.Keys
.SiteSetting
.CardRenewal
.AddressLookupUrl);

var queryParams = new Dictionary<string, string>
{
{ nameof(address), HttpUtility.UrlEncode(address) },
{ nameof(zip), HttpUtility.UrlEncode(zip) }
};
var parameterString = string.Join('&', queryParams.Select(_ => $"{_.Key}={_.Value}"));

var queryUri = new UriBuilder(addressLookupPath) { Query = parameterString }.Uri;

using var response = await _httpClient.GetAsync(queryUri);

if (response.IsSuccessStatusCode)
{
using var responseStream = await response.Content.ReadAsStreamAsync();

try
{
return await JsonSerializer.DeserializeAsync<AddressLookupResult>(
responseStream,
new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
});
}
catch (JsonException jex)
{
_logger.LogError(jex, "Error decoding JSON: {ErrorMessage}", jex.Message);
}
}
else
{
_logger.LogError("Address lookup returned status code {StatusCode} for parameters {Parameters}",
response.StatusCode,
parameterString);
}

return null;
}

#region Slide Upload

[HttpPost("[action]")]
Expand Down
Loading
Loading