Skip to content

Commit

Permalink
Fixed a bunch of warnings and updated the nuget packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
uncheckederror committed Oct 26, 2024
1 parent 2182943 commit f106416
Show file tree
Hide file tree
Showing 45 changed files with 403 additions and 550 deletions.
49 changes: 25 additions & 24 deletions Messaging.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ private async Task<HttpClient> GetHttpClientWithValidBearerTokenAsync()
};

var response = await _httpClient.PostAsJsonAsync("/login", authRequest);
var x = await response.Content.ReadAsStringAsync();
// For debugging.
//var x = await response.Content.ReadAsStringAsync();

var authCredentials = await response.Content.ReadFromJsonAsync<AccessTokenResponse>();
_httpClient.DefaultRequestHeaders.Authorization = new("Bearer", authCredentials?.AccessToken ?? string.Empty);
Expand All @@ -93,7 +94,7 @@ public async Task RegisterAClientAsync()
Assert.True(data.Registered);
Assert.Equal("12063333341", data.DialedNumber);
Assert.Equal("https://sms.callpipe.com/swagger/index.html", data.CallbackUrl);
Assert.True(!string.IsNullOrWhiteSpace(data.Message));
Assert.False(string.IsNullOrWhiteSpace(data.Message));

// Verify that the newly registered client exists.
response = await _httpClient.GetAsync("/client?asDialed=12063333341");
Expand Down Expand Up @@ -284,10 +285,10 @@ public async Task IncompleteRequest()
{
string route = "/api/inbound/1pcom";

var stringContent = new FormUrlEncodedContent(new[]
{
var stringContent = new FormUrlEncodedContent(
[
new KeyValuePair<string, string>(string.Empty, string.Empty),
});
]);

var response = await _httpClient.PostAsync($"{route}", stringContent);
_output.WriteLine(await response.Content.ReadAsStringAsync());
Expand All @@ -309,12 +310,12 @@ public async Task SMSGroupMessage()
string route = "/api/inbound/1pcom";
string token = "okereeduePeiquah3yaemohGhae0ie";

var stringContent = new FormUrlEncodedContent(new[]
{
var stringContent = new FormUrlEncodedContent(
[
new KeyValuePair<string, string>("msisdn", "12068589312"),
new KeyValuePair<string, string>("to", "12068589313,12068589313,15036622288,97167"),
new KeyValuePair<string, string>("message", "screams in javascript"),
});
]);

response = await _httpClient.PostAsync($"{route}?token={token}", stringContent);
_output.WriteLine(await response.Content.ReadAsStringAsync());
Expand All @@ -329,13 +330,13 @@ public async Task CorrectlyFormattedMessageForUnregisteredClientAsync()
string route = "/api/inbound/1pcom";
string token = "okereeduePeiquah3yaemohGhae0ie";

var stringContent = new FormUrlEncodedContent(new[]
{
var stringContent = new FormUrlEncodedContent(
[
new KeyValuePair<string, string>("msisdn", "12065579450"),
new KeyValuePair<string, string>("to", "12068589311"),
new KeyValuePair<string, string>("message", "Hello, this is 1stPoint SMS :D"),

});
]);

var response = await _httpClient.PostAsync($"{route}?token={token}", stringContent);

Expand All @@ -360,12 +361,12 @@ public async Task GroupSMSMessageAsync()
string route = "/api/inbound/1pcom";
string token = "okereeduePeiquah3yaemohGhae0ie";

var stringContent = new FormUrlEncodedContent(new[]
{
var stringContent = new FormUrlEncodedContent(
[
new KeyValuePair<string, string>("msisdn", "12065579450"),
new KeyValuePair<string, string>("to", "12068589312,12068589310"),
new KeyValuePair<string, string>("message", "Hello, this is 1stPoint SMS :D"),
});
]);

response = await _httpClient.PostAsync($"{route}?token={token}", stringContent);

Expand All @@ -390,12 +391,12 @@ public async Task CenturyLinkBillingMessageAsync()
string route = "/api/inbound/1pcom";
string token = "okereeduePeiquah3yaemohGhae0ie";

var stringContent = new FormUrlEncodedContent(new[]
{
var stringContent = new FormUrlEncodedContent(
[
new KeyValuePair<string, string>("msisdn", "67378"),
new KeyValuePair<string, string>("to", "12068589310"),
new KeyValuePair<string, string>("message", "CenturyLink: Payment to be applied on 05/05/2023. Text HELP for help, NOREMINDER to stop pay alerts, STOP to stop all alerts. Msg&data rates may apply."),
});
]);

response = await _httpClient.PostAsync($"{route}?token={token}", stringContent);

Expand All @@ -413,21 +414,21 @@ public async Task BadFromNumberAsync()
var _httpClient = await GetHttpClientWithValidBearerTokenAsync();
var registrationRequest = new RegistrationRequest() { CallbackUrl = "https://sms.callpipe.com/message/forward/test", ClientSecret = "thisisatest", DialedNumber = "12068991741" };
var response = await _httpClient.PostAsJsonAsync("/client/register", registrationRequest);
var x = await response.Content.ReadAsStringAsync();
//var x = await response.Content.ReadAsStringAsync();
var data = await response.Content.ReadFromJsonAsync<RegistrationResponse>();
Assert.NotNull(data);
Assert.True(data.Registered);

string route = "/api/inbound/1pcom";
string token = "okereeduePeiquah3yaemohGhae0ie";

var stringContent = new FormUrlEncodedContent(new[]
{
var stringContent = new FormUrlEncodedContent(
[
new KeyValuePair<string, string>("msisdn", "110000011909"),
new KeyValuePair<string, string>("to", "12068991741"),
new KeyValuePair<string, string>("timezone", "EST"),
new KeyValuePair<string, string>("message", "Verizon:+DO+NOT+Share+this+Forgot+Password+code.+A+Verizon+representative+will+NEVER+call+you+or+text+you+for+this+code.+Code+059089."),
});
]);

response = await _httpClient.PostAsync($"{route}?token={token}", stringContent);

Expand All @@ -451,14 +452,14 @@ public async Task MMSMessageAsync()
string route = "/1pcom/inbound/MMS";
string token = "okereeduePeiquah3yaemohGhae0ie";

var stringContent = new FormUrlEncodedContent(new[]
{
var stringContent = new FormUrlEncodedContent(
[
new KeyValuePair<string, string>("msisdn", "12066320575"),
new KeyValuePair<string, string>("to", "12066320575"),
new KeyValuePair<string, string>("message", "{\r\n\"authkey\":\"bbdd4df0-1da0-4c5d-be9e-a94b75513c91\",\r\n\"encoding\":\"native\",\r\n\"files\":\"part-002.txt,\",\r\n\"recip\":\"12068589310,\",\r\n\"url\":\"https://mmsc01.1pcom.net/MMS_Pickup?msgid=ce808f729db2413498ef722333badb2b\"\r\n}"),
new KeyValuePair<string, string>("remote", "12066320575"),
new KeyValuePair<string, string>("host", "12066320575"),
});
]);

response = await _httpClient.PostAsync($"{route}?token={token}", stringContent);

Expand Down
2 changes: 1 addition & 1 deletion Messaging/Messaging.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<PackageReference Include="PhoneNumbersNA" Version="1.0.14" />
<PackageReference Include="prometheus-net" Version="8.2.1" />
<PackageReference Include="prometheus-net.AspNetCore" Version="8.2.1" />
<PackageReference Include="Serilog" Version="4.0.2" />
<PackageReference Include="Serilog" Version="4.1.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
Expand Down
2 changes: 1 addition & 1 deletion NumberSearch.DataAccess/NumberSearch.DataAccess.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Npgsql" Version="8.0.5" />
<PackageReference Include="PhoneNumbersNA" Version="1.0.14" />
<PackageReference Include="Serilog" Version="4.0.2" />
<PackageReference Include="Serilog" Version="4.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion NumberSearch.Ingest/NumberSearch.Ingest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Serilog.Sinks.Async" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="2.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.Postgresql.Alternative" Version="4.1.1" />
Expand Down
2 changes: 1 addition & 1 deletion NumberSearch.Mvc/NumberSearch.Mvc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<PackageReference Include="Azure.Storage.Blobs" Version="12.22.2" />
<PackageReference Include="DnsClient" Version="1.8.0" />
<PackageReference Include="Ical.Net" Version="4.3.1" />
<PackageReference Include="Markdig" Version="0.37.0" />
<PackageReference Include="Markdig" Version="0.38.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.11.20">
Expand Down
17 changes: 6 additions & 11 deletions NumberSearch.Ops/Controllers/CarriersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@
namespace NumberSearch.Ops.Controllers
{
[ApiExplorerSettings(IgnoreApi = true)]
public class CarriersController : Controller
public class CarriersController(numberSearchContext context) : Controller
{
private readonly numberSearchContext _context;

public CarriersController(numberSearchContext context)
{
_context = context;
}
private readonly numberSearchContext _context = context;

[Authorize]
[HttpGet("/Carriers")]
Expand Down Expand Up @@ -84,8 +79,8 @@ public async Task<IActionResult> CreateFromLookup(Guid lookupId)
else
{
string[] carrierQuery = lookup.Lec.Split(' ');
var relatedCarriers = await _context.Carriers.Where(x => x.Lec != null && x.Lec.ToLower().Contains(carrierQuery[0].ToLower())).ToArrayAsync();
if (relatedCarriers.Any())
var relatedCarriers = await _context.Carriers.Where(x => x.Lec != null && x.Lec.Contains(carrierQuery[0], StringComparison.CurrentCultureIgnoreCase)).ToArrayAsync();
if (relatedCarriers.Length != 0)
{
return View("Create", new CreateCarrier
{
Expand Down Expand Up @@ -149,7 +144,7 @@ public async Task<IActionResult> Create([Bind("CarrierId,Ocn,Lec,Lectype,Spid,Na
}
_context.UpdateRange(relatedLookups);
await _context.SaveChangesAsync();
return View("Edit", new EditCarrier { Carrier = carrier, Lookups = relatedLookups.ToArray(), Message = $"Created a new Carrier for OCN {carrier.Ocn}!" });
return View("Edit", new EditCarrier { Carrier = carrier, Lookups = [.. relatedLookups], Message = $"Created a new Carrier for OCN {carrier.Ocn}!" });
}
return View(carrier);
}
Expand Down Expand Up @@ -208,7 +203,7 @@ public async Task<IActionResult> Edit(Guid id, [Bind("CarrierId,Ocn,Lec,Lectype,
_context.UpdateRange(relatedLookups);
await _context.SaveChangesAsync();

return View("Edit", new EditCarrier { Carrier = carrier, Lookups = relatedLookups.ToArray(), Message = $"Saved your changes to OCN {carrier.Ocn}!" });
return View("Edit", new EditCarrier { Carrier = carrier, Lookups = [.. relatedLookups], Message = $"Saved your changes to OCN {carrier.Ocn}!" });

}
catch (DbUpdateConcurrencyException)
Expand Down
54 changes: 24 additions & 30 deletions NumberSearch.Ops/Controllers/EmergencyInformationsController.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AccelerateNetworks.Operations;

using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using AccelerateNetworks.Operations;

using System;
using System.Linq;
using System.Threading.Tasks;

namespace NumberSearch.Ops.Controllers
{
public class EmergencyInformationsController : Controller
public class EmergencyInformationsController(numberSearchContext context) : Controller
{
private readonly numberSearchContext _context;

public EmergencyInformationsController(numberSearchContext context)
{
_context = context;
}

// GET: EmergencyInformations
public async Task<IActionResult> Index()
{
return _context.EmergencyInformation.OrderBy(x => x.DateIngested) != null ?
View(await _context.EmergencyInformation.ToListAsync()) :
return context.EmergencyInformation.OrderBy(x => x.DateIngested) != null ?
View(await context.EmergencyInformation.ToListAsync()) :
Problem("Entity set 'numberSearchContext.EmergencyInformations' is null.");
}

// GET: EmergencyInformations/Details/5
public async Task<IActionResult> Details(Guid? id)
{
if (id == null || _context.EmergencyInformation == null)
if (id == null || context.EmergencyInformation == null)
{
return NotFound();
}

var emergencyInformation = await _context.EmergencyInformation
var emergencyInformation = await context.EmergencyInformation
.FirstOrDefaultAsync(m => m.EmergencyInformationId == id);
if (emergencyInformation == null)
{
Expand All @@ -60,8 +54,8 @@ public async Task<IActionResult> Create([Bind("EmergencyInformationId,DialedNumb
if (ModelState.IsValid)
{
emergencyInformation.EmergencyInformationId = Guid.NewGuid();
_context.Add(emergencyInformation);
await _context.SaveChangesAsync();
context.Add(emergencyInformation);
await context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(emergencyInformation);
Expand All @@ -70,12 +64,12 @@ public async Task<IActionResult> Create([Bind("EmergencyInformationId,DialedNumb
// GET: EmergencyInformations/Edit/5
public async Task<IActionResult> Edit(Guid? id)
{
if (id == null || _context.EmergencyInformation == null)
if (id == null || context.EmergencyInformation == null)
{
return NotFound();
}

var emergencyInformation = await _context.EmergencyInformation.FindAsync(id);
var emergencyInformation = await context.EmergencyInformation.FindAsync(id);
if (emergencyInformation == null)
{
return NotFound();
Expand All @@ -99,8 +93,8 @@ public async Task<IActionResult> Edit(Guid id, [Bind("EmergencyInformationId,Dia
{
try
{
_context.Update(emergencyInformation);
await _context.SaveChangesAsync();
context.Update(emergencyInformation);
await context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
Expand All @@ -121,12 +115,12 @@ public async Task<IActionResult> Edit(Guid id, [Bind("EmergencyInformationId,Dia
// GET: EmergencyInformations/Delete/5
public async Task<IActionResult> Delete(Guid? id)
{
if (id == null || _context.EmergencyInformation == null)
if (id == null || context.EmergencyInformation == null)
{
return NotFound();
}

var emergencyInformation = await _context.EmergencyInformation
var emergencyInformation = await context.EmergencyInformation
.FirstOrDefaultAsync(m => m.EmergencyInformationId == id);
if (emergencyInformation == null)
{
Expand All @@ -141,23 +135,23 @@ public async Task<IActionResult> Delete(Guid? id)
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(Guid id)
{
if (_context.EmergencyInformation == null)
if (context.EmergencyInformation == null)
{
return Problem("Entity set 'numberSearchContext.EmergencyInformations' is null.");
}
var emergencyInformation = await _context.EmergencyInformation.FindAsync(id);
var emergencyInformation = await context.EmergencyInformation.FindAsync(id);
if (emergencyInformation != null)
{
_context.EmergencyInformation.Remove(emergencyInformation);
context.EmergencyInformation.Remove(emergencyInformation);
}

await _context.SaveChangesAsync();
await context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}

private bool EmergencyInformationExists(Guid id)
{
return (_context.EmergencyInformation?.Any(e => e.EmergencyInformationId == id)).GetValueOrDefault();
return (context.EmergencyInformation?.Any(e => e.EmergencyInformationId == id)).GetValueOrDefault();
}
}
}
Loading

0 comments on commit f106416

Please sign in to comment.