Skip to content

Commit

Permalink
More class to struct conversion cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
uncheckederror committed Nov 1, 2024
1 parent 0595508 commit c3bc1c7
Show file tree
Hide file tree
Showing 15 changed files with 117 additions and 120 deletions.
82 changes: 41 additions & 41 deletions NumberSearch.DataAccess/FusionPBX/DestinationDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,49 @@

namespace NumberSearch.DataAccess.FusionPBX
{
public class DestinationDetails
public readonly record struct DestinationDetails(
string destination_uuid,
string dialplan_uuid,
object fax_uuid,
string domain_uuid,
string destination_type,
string destination_number,
string destination_number_regex,
object destination_caller_id_name,
object destination_caller_id_number,
object destination_cid_name_prefix,
string destination_context,
object destination_record,
object destination_accountcode,
string destination_app,
string destination_data,
[property: JsonConverter(typeof(BooleanConverter))]
bool destination_enabled,
string destination_description,
string destination_prefix,
string destination_type_voice,
string destination_type_fax,
string destination_type_text,
string destination_alternate_app,
string destination_alternate_data,
string destination_trunk_prefix,
string destination_area_code,
string destination_condition_field,
string destination_hold_music,
string user_uuid,
string group_uuid,
string destination_type_emergency,
string destination_order,
string destination_distinctive_ring,
string destination_conditions,
DestinationDetails.DestinationAction[] destination_actions,
string insert_date,
string insert_user,
string update_date,
string update_user)
{
public string domain_uuid { get; set; } = string.Empty;
public string destination_uuid { get; set; } = string.Empty;
public string dialplan_uuid { get; set; } = string.Empty;
public object fax_uuid { get; set; } = string.Empty;
public string destination_type { get; set; } = string.Empty;
public string destination_number { get; set; } = string.Empty;
public string destination_number_regex { get; set; } = string.Empty;
public object destination_caller_id_name { get; set; } = string.Empty;
public object destination_caller_id_number { get; set; } = string.Empty;
public object destination_cid_name_prefix { get; set; } = string.Empty;
public string destination_context { get; set; } = string.Empty;
public object destination_record { get; set; } = string.Empty;
public object destination_accountcode { get; set; } = string.Empty;
public string destination_app { get; set; } = string.Empty;
public string destination_data { get; set; } = string.Empty;
[JsonConverter(typeof(BooleanConverter))]
public bool destination_enabled { get; set; } = false;
public string destination_description { get; set; } = string.Empty;
public string destination_prefix { get; set; } = string.Empty;
public string destination_type_voice { get; set; } = string.Empty;
public string destination_type_fax { get; set; } = string.Empty;
public string destination_type_text { get; set; } = string.Empty;
public string destination_alternate_app { get; set; } = string.Empty;
public string destination_alternate_data { get; set; } = string.Empty;
public string destination_trunk_prefix { get; set; } = string.Empty;
public string destination_area_code { get; set; } = string.Empty;
public string destination_condition_field { get; set; } = string.Empty;
public string destination_hold_music { get; set; } = string.Empty;
public string user_uuid { get; set; } = string.Empty;
public string group_uuid { get; set; } = string.Empty;
public string destination_type_emergency { get; set; } = string.Empty;
public string destination_order { get; set; } = string.Empty;
public string destination_distinctive_ring { get; set; } = string.Empty;
public string destination_conditions { get; set; } = string.Empty;
public DestinationAction[] destination_actions { get; set; } = [];
public string insert_date { get; set; } = string.Empty;
public string insert_user { get; set; } = string.Empty;
public string update_date { get; set; } = string.Empty;
public string update_user { get; set; } = string.Empty;

public readonly record struct DestinationAction(string destination_app,string destination_data);
public readonly record struct DestinationAction(string destination_app, string destination_data);

public static async Task<DestinationDetails> GetByDialedNumberAsync(ReadOnlyMemory<char> dialedNumber, ReadOnlyMemory<char> username, ReadOnlyMemory<char> password)
{
Expand Down
4 changes: 2 additions & 2 deletions NumberSearch.DataAccess/Models/Email.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using System.IO;
using System.Threading.Tasks;

namespace NumberSearch.DataAccess
namespace NumberSearch.DataAccess.Models
{
public class Email
{
Expand Down Expand Up @@ -146,7 +146,7 @@ public async Task<bool> SendEmailAsync(string username, string password)
{
var icsFile = Path.Combine(AppContext.BaseDirectory, "acceleratenetworks.ics");

System.IO.File.WriteAllText(icsFile, CalendarInvite);
File.WriteAllText(icsFile, CalendarInvite);

builder.Attachments.Add(icsFile);
}
Expand Down
8 changes: 4 additions & 4 deletions NumberSearch.Ingest/Orders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public static async Task<bool> DailyBriefingEmailAsync(Owned.SMSRouteChange[] sm

output.Append("<p>Have a great day, hombre! 🤠</p>");

var notificationEmail = new Email
var notificationEmail = new DataAccess.Models.Email
{
PrimaryEmailAddress = appConfig.EmailDan.ToString(),
CarbonCopy = appConfig.EmailTom.ToString(),
Expand Down Expand Up @@ -394,7 +394,7 @@ public async static Task CheckForQuoteConversionsAsync(ReadOnlyMemory<char> post
var invoiceStatus = convertedInvoice.status_id is "4" ? "paid" : "approved";
var checkUpdate = await order.PutAsync(postgresql.ToString());
string name = string.IsNullOrWhiteSpace(order.BusinessName) ? $"{order.FirstName} {order.LastName}" : order.BusinessName;
var message = new Email
var message = new DataAccess.Models.Email
{
SalesEmailAddress = string.IsNullOrWhiteSpace(order.SalesEmail) ? string.Empty : order.SalesEmail,
PrimaryEmailAddress = "[email protected]",
Expand Down Expand Up @@ -461,7 +461,7 @@ public async static Task CheckForQuoteConversionsAsync(ReadOnlyMemory<char> post
var checkUpdate = await order.PutAsync(postgresql.ToString());
string name = string.IsNullOrWhiteSpace(order.BusinessName) ? $"{order.FirstName} {order.LastName}" : order.BusinessName;
var invoiceStatus = convertedInvoice.status_id is "4" ? "paid" : "converted from a quote";
var message = new Email
var message = new DataAccess.Models.Email
{
SalesEmailAddress = string.IsNullOrWhiteSpace(order.SalesEmail) ? string.Empty : order.SalesEmail,
PrimaryEmailAddress = "[email protected]",
Expand Down Expand Up @@ -567,7 +567,7 @@ public async static Task CheckForInvoicePaymentAsync(ReadOnlyMemory<char> postgr
if (order.DateUpfrontInvoicePaid is not null && upfrontInvoice.status_id is "4")
{
string name = string.IsNullOrWhiteSpace(order.BusinessName) ? $"{order.FirstName} {order.LastName}" : order.BusinessName;
var message = new Email
var message = new DataAccess.Models.Email
{
SalesEmailAddress = string.IsNullOrWhiteSpace(order.SalesEmail) ? string.Empty : order.SalesEmail,
PrimaryEmailAddress = "[email protected]",
Expand Down
Loading

0 comments on commit c3bc1c7

Please sign in to comment.