Skip to content

Commit

Permalink
Updated the tests and worked on #473.
Browse files Browse the repository at this point in the history
  • Loading branch information
uncheckederror committed Oct 31, 2024
1 parent 418dc2b commit cafcffc
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
14 changes: 8 additions & 6 deletions NumberSearch.DataAccess/Models/PortRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class PortRequest
public DateTime? DateUpdated { get; set; }
public string VendorSubmittedTo { get; set; } = string.Empty;
public string BulkVSId { get; set; } = string.Empty;
public string UnparsedAddress { get; set; } = string.Empty;

/// <summary>
/// Get all of the Port Requests from the database.
Expand All @@ -54,7 +55,7 @@ public static async Task<IEnumerable<PortRequest>> GetAllAsync(string connection
await using var connection = new NpgsqlConnection(connectionString);

return await connection
.QueryAsync<PortRequest>("SELECT \"PortRequestId\", \"OrderId\", \"Address\", \"Address2\", \"City\", \"State\", \"Zip\", \"BillingPhone\", \"LocationType\", \"BusinessContact\", \"BusinessName\", \"ProviderAccountNumber\", \"ProviderPIN\", \"PartialPort\", \"PartialPortDescription\", \"WirelessNumber\", \"CallerId\", \"BillImagePath\", \"BillImageFileType\", \"DateSubmitted\", \"ResidentialFirstName\", \"ResidentialLastName\", \"TeliId\", \"RequestStatus\", \"Completed\", \"DateCompleted\", \"DateUpdated\", \"VendorSubmittedTo\", \"BulkVSId\" FROM public.\"PortRequests\"")
.QueryAsync<PortRequest>("SELECT \"PortRequestId\", \"OrderId\", \"Address\", \"Address2\", \"City\", \"State\", \"Zip\", \"BillingPhone\", \"LocationType\", \"BusinessContact\", \"BusinessName\", \"ProviderAccountNumber\", \"ProviderPIN\", \"PartialPort\", \"PartialPortDescription\", \"WirelessNumber\", \"CallerId\", \"BillImagePath\", \"BillImageFileType\", \"DateSubmitted\", \"ResidentialFirstName\", \"ResidentialLastName\", \"TeliId\", \"RequestStatus\", \"Completed\", \"DateCompleted\", \"DateUpdated\", \"VendorSubmittedTo\", \"BulkVSId\", \"UnparsedAddress\" FROM public.\"PortRequests\"")
.ConfigureAwait(false);
}

Expand All @@ -70,7 +71,7 @@ public static async Task<IEnumerable<PortRequest>> GetAllAsync(string connection
await using var connection = new NpgsqlConnection(connectionString);

return await connection
.QueryFirstOrDefaultAsync<PortRequest>("SELECT \"PortRequestId\", \"OrderId\", \"Address\", \"Address2\", \"City\", \"State\", \"Zip\", \"BillingPhone\", \"LocationType\", \"BusinessContact\", \"BusinessName\", \"ProviderAccountNumber\", \"ProviderPIN\", \"PartialPort\", \"PartialPortDescription\", \"WirelessNumber\", \"CallerId\", \"BillImagePath\", \"BillImageFileType\", \"DateSubmitted\", \"ResidentialFirstName\", \"ResidentialLastName\", \"TeliId\", \"RequestStatus\", \"Completed\", \"DateCompleted\", \"DateUpdated\", \"VendorSubmittedTo\", \"BulkVSId\" FROM public.\"PortRequests\" WHERE \"OrderId\" = @orderId",
.QueryFirstOrDefaultAsync<PortRequest>("SELECT \"PortRequestId\", \"OrderId\", \"Address\", \"Address2\", \"City\", \"State\", \"Zip\", \"BillingPhone\", \"LocationType\", \"BusinessContact\", \"BusinessName\", \"ProviderAccountNumber\", \"ProviderPIN\", \"PartialPort\", \"PartialPortDescription\", \"WirelessNumber\", \"CallerId\", \"BillImagePath\", \"BillImageFileType\", \"DateSubmitted\", \"ResidentialFirstName\", \"ResidentialLastName\", \"TeliId\", \"RequestStatus\", \"Completed\", \"DateCompleted\", \"DateUpdated\", \"VendorSubmittedTo\", \"BulkVSId\", \"UnparsedAddress\" FROM public.\"PortRequests\" WHERE \"OrderId\" = @orderId",
new { orderId })
.ConfigureAwait(false);
}
Expand All @@ -87,9 +88,9 @@ public async Task<bool> PostAsync(string connectionString)
await using var connection = new NpgsqlConnection(connectionString);

var result = await connection
.ExecuteAsync("INSERT INTO public.\"PortRequests\"(\"PortRequestId\", \"OrderId\", \"Address\", \"Address2\", \"City\", \"State\", \"Zip\", \"BillingPhone\", \"LocationType\", \"BusinessContact\", \"BusinessName\", \"ProviderAccountNumber\", \"ProviderPIN\", \"PartialPort\", \"PartialPortDescription\", \"WirelessNumber\", \"CallerId\", \"BillImagePath\", \"BillImageFileType\", \"DateSubmitted\", \"ResidentialFirstName\", \"ResidentialLastName\", \"TeliId\", \"RequestStatus\", \"Completed\", \"DateCompleted\", \"DateUpdated\", \"VendorSubmittedTo\", \"BulkVSId\") " +
"VALUES(@PortRequestId, @OrderId, @Address, @Address2, @City, @State, @Zip, @BillingPhone, @LocationType, @BusinessContact, @BusinessName, @ProviderAccountNumber, @ProviderPIN, @PartialPort, @PartialPortDescription, @WirelessNumber, @CallerId, @BillImagePath, @BillImageFileType, @DateSubmitted, @ResidentialFirstName, @ResidentialLastName, @TeliId, @RequestStatus, @Completed, @DateCompleted, @DateUpdated, @VendorSubmittedTo, @BulkVSId)",
new { PortRequestId, OrderId, Address, Address2, City, State, Zip, BillingPhone, LocationType, BusinessContact, BusinessName, ProviderAccountNumber, ProviderPIN, PartialPort, PartialPortDescription, WirelessNumber, CallerId, BillImagePath, BillImageFileType, DateSubmitted, ResidentialFirstName, ResidentialLastName, TeliId, RequestStatus, Completed, DateCompleted, DateUpdated, VendorSubmittedTo, BulkVSId })
.ExecuteAsync("INSERT INTO public.\"PortRequests\"(\"PortRequestId\", \"OrderId\", \"Address\", \"Address2\", \"City\", \"State\", \"Zip\", \"BillingPhone\", \"LocationType\", \"BusinessContact\", \"BusinessName\", \"ProviderAccountNumber\", \"ProviderPIN\", \"PartialPort\", \"PartialPortDescription\", \"WirelessNumber\", \"CallerId\", \"BillImagePath\", \"BillImageFileType\", \"DateSubmitted\", \"ResidentialFirstName\", \"ResidentialLastName\", \"TeliId\", \"RequestStatus\", \"Completed\", \"DateCompleted\", \"DateUpdated\", \"VendorSubmittedTo\", \"BulkVSId\", \"UnparsedAddress\") " +
"VALUES(@PortRequestId, @OrderId, @Address, @Address2, @City, @State, @Zip, @BillingPhone, @LocationType, @BusinessContact, @BusinessName, @ProviderAccountNumber, @ProviderPIN, @PartialPort, @PartialPortDescription, @WirelessNumber, @CallerId, @BillImagePath, @BillImageFileType, @DateSubmitted, @ResidentialFirstName, @ResidentialLastName, @TeliId, @RequestStatus, @Completed, @DateCompleted, @DateUpdated, @VendorSubmittedTo, @BulkVSId, @UnparsedAddress)",
new { PortRequestId, OrderId, Address, Address2, City, State, Zip, BillingPhone, LocationType, BusinessContact, BusinessName, ProviderAccountNumber, ProviderPIN, PartialPort, PartialPortDescription, WirelessNumber, CallerId, BillImagePath, BillImageFileType, DateSubmitted, ResidentialFirstName, ResidentialLastName, TeliId, RequestStatus, Completed, DateCompleted, DateUpdated, VendorSubmittedTo, BulkVSId, UnparsedAddress })
.ConfigureAwait(false);

if (result == 1)
Expand Down Expand Up @@ -117,7 +118,7 @@ public async Task<bool> PutAsync(string connectionString)
"\"ProviderAccountNumber\" = @ProviderAccountNumber, \"ProviderPIN\" = @ProviderPIN, \"PartialPort\" = @PartialPort, \"PartialPortDescription\" = @PartialPortDescription, " +
"\"WirelessNumber\" = @WirelessNumber, \"CallerId\" = @CallerId, \"BillImagePath\" = @BillImagePath, \"BillImageFileType\" = @BillImageFileType, \"DateSubmitted\" = @DateSubmitted, " +
"\"ResidentialFirstName\" = @ResidentialFirstName, \"ResidentialLastName\" = @ResidentialLastName, \"TeliId\" = @TeliId, \"RequestStatus\" = @RequestStatus, \"Completed\" = @Completed, " +
"\"DateCompleted\" = @DateCompleted, \"DateUpdated\" = @DateUpdated, \"VendorSubmittedTo\" = @VendorSubmittedTo, \"BulkVSId\" = @BulkVSId WHERE \"PortRequestId\" = @PortRequestId",
"\"DateCompleted\" = @DateCompleted, \"DateUpdated\" = @DateUpdated, \"VendorSubmittedTo\" = @VendorSubmittedTo, \"BulkVSId\" = @BulkVSId, \"UnparsedAddress\" = @UnparsedAddress WHERE \"PortRequestId\" = @PortRequestId",
new
{
OrderId,
Expand Down Expand Up @@ -148,6 +149,7 @@ public async Task<bool> PutAsync(string connectionString)
DateUpdated,
VendorSubmittedTo,
BulkVSId,
UnparsedAddress,
PortRequestId
})
.ConfigureAwait(false);
Expand Down
12 changes: 6 additions & 6 deletions NumberSearch.Mvc/Controllers/PortingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,16 @@ public async Task<IActionResult> AddPortingInformationAsync(PortRequest portRequ

// Format the address information
Log.Information($"[Port Request] Parsing address data from {portRequest.Address}");
if (portRequest is not null && !string.IsNullOrWhiteSpace(portRequest.Address))
if (portRequest is not null && !string.IsNullOrWhiteSpace(portRequest.UnparsedAddress) && portRequest.UnparsedAddress != existing.UnparsedAddress)
{
existing.Address = portRequest.Address;
var addressParts = portRequest.Address.Split(", ");
var addressParts = portRequest.UnparsedAddress.Split(", ");
if (addressParts.Length > 4)
{
existing.Address = addressParts[0];
existing.City = addressParts[1];
existing.State = addressParts[2];
existing.Zip = addressParts[3];
portRequest.UnparsedAddress = portRequest.UnparsedAddress;
Log.Information($"[Port Request] Address: {existing.Address} City: {existing.City} State: {existing.State} Zip: {existing.Zip}");
}
else
Expand Down Expand Up @@ -361,10 +361,10 @@ public async Task<IActionResult> AddPortingInformationAsync(PortRequest portRequ


// Format the address information
Log.Information($"[Port Request] Parsing address data from {portRequest.Address}");
if (portRequest is not null && !string.IsNullOrWhiteSpace(portRequest.Address))
Log.Information($"[Port Request] Parsing address data from {portRequest.UnparsedAddress}");
if (portRequest is not null && !string.IsNullOrWhiteSpace(portRequest.UnparsedAddress))
{
var addressParts = portRequest.Address.Split(", ");
var addressParts = portRequest.UnparsedAddress.Split(", ");
if (addressParts.Length > 4)
{
portRequest.Address = addressParts[0];
Expand Down
4 changes: 2 additions & 2 deletions NumberSearch.Mvc/Views/Cart/Success.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@
<div class="mb-3" id="searchForm">
<label for="address">Service Address</label>
@{
var address = string.IsNullOrWhiteSpace(Model?.PortRequest?.Address) ? Model?.Order?.UnparsedAddress : Model?.PortRequest?.Address;
var address = string.IsNullOrWhiteSpace(Model?.PortRequest?.UnparsedAddress) ? Model?.Order?.UnparsedAddress : Model?.PortRequest?.UnparsedAddress;
}
<input asp-for="PortRequest.Address" type="text" value="@address" class="form-control" id="address" placeholder="5432 5th Ave" pattern=".+[,].+" oninput="handleSearchQuery(this)" onfocus="handleSearchQuery(this)" list="addressOptions" autocomplete="off" data-toggle="dropdown" required>
<input asp-for="PortRequest.UnparsedAddress" type="text" value="@address" class="form-control" id="address" placeholder="5432 5th Ave" pattern=".+[,].+" oninput="handleSearchQuery(this)" onfocus="handleSearchQuery(this)" list="addressOptions" autocomplete="off" data-toggle="dropdown" required>
<ul class="list-group" role="menu" aria-labelledby="menu1" id="addressOptions">
</ul>
<small class="text-muted">
Expand Down
18 changes: 9 additions & 9 deletions NumberSearch.Tests/Integration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -592,16 +592,16 @@ public async Task FirstComGetSMSEnableTestAsync()
output.WriteLine(JsonSerializer.Serialize(result));
}

//[Fact]
//public async Task FirstComGetRouteSMSToEPIDTestAsync()
//{
// var result = await FirstCom.FirstPointComSMS.RouteSMSToEPIDByDialedNumberAsync("12069574634", 265, pComNetCredentials.Username, pComNetCredentials.Password);
[Fact]
public async Task FirstComGetRouteSMSToEPIDTestAsync()
{
var result = await FirstCom.FirstPointComSMS.RouteSMSToEPIDByDialedNumberAsync("12069574634", 265, pComNetCredentials.Username, pComNetCredentials.Password);

// Assert.NotNull(result);
// Assert.True(result.text is "Routed OK!");
// Assert.True(result.code is 0);
// output.WriteLine(JsonSerializer.Serialize(result));
//}
Assert.NotNull(result);
Assert.True(result.text is "Routed OK!");
Assert.True(result.code is 0);
output.WriteLine(JsonSerializer.Serialize(result));
}

[Fact]
public async Task BulkVSRESTNpaNxxGetAsyncTestAsync()
Expand Down

0 comments on commit cafcffc

Please sign in to comment.