From fec17095a4a638d2e3411226e7fdea09ba2808d9 Mon Sep 17 00:00:00 2001 From: Greg Finzer Date: Wed, 16 Sep 2026 08:14:06 -0400 Subject: [PATCH] Receive text and lookup Volunteer, ContactUs, SignUp, BedRequest, and User --- BedBrigade.Common/Models/SmsQueue.cs | 9 +- ...5657_SmsQueueOtherLinkedTables.Designer.cs | 1994 +++++++++++++++++ ...0260916115657_SmsQueueOtherLinkedTables.cs | 78 + .../Migrations/DataContextModelSnapshot.cs | 22 + .../Services/ISignUpDataService.cs | 1 + BedBrigade.Data/Services/SignUpDataService.cs | 29 + .../Services/SmsQueueDataService.cs | 71 +- 7 files changed, 2199 insertions(+), 5 deletions(-) create mode 100644 BedBrigade.Data/Migrations/20260916115657_SmsQueueOtherLinkedTables.Designer.cs create mode 100644 BedBrigade.Data/Migrations/20260916115657_SmsQueueOtherLinkedTables.cs diff --git a/BedBrigade.Common/Models/SmsQueue.cs b/BedBrigade.Common/Models/SmsQueue.cs index 370fa5d8..dc356ca9 100644 --- a/BedBrigade.Common/Models/SmsQueue.cs +++ b/BedBrigade.Common/Models/SmsQueue.cs @@ -75,9 +75,12 @@ public class SmsQueue : BaseEntity, ILocationId [Required, StringLength(50)] public string ContactName { get; set; } = string.Empty; + [ForeignKey("VolunteerId")] + public Int32? VolunteerId { get; set; } + public Volunteer? Volunteer { get; set; } - - - + [ForeignKey("ContactUsId")] + public Int32? ContactUsId { get; set; } + public ContactUs? ContactUs { get; set; } } } diff --git a/BedBrigade.Data/Migrations/20260916115657_SmsQueueOtherLinkedTables.Designer.cs b/BedBrigade.Data/Migrations/20260916115657_SmsQueueOtherLinkedTables.Designer.cs new file mode 100644 index 00000000..a4f4cb1d --- /dev/null +++ b/BedBrigade.Data/Migrations/20260916115657_SmsQueueOtherLinkedTables.Designer.cs @@ -0,0 +1,1994 @@ +// +using System; +using BedBrigade.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BedBrigade.Data.Migrations +{ + [DbContext(typeof(DataContext))] + [Migration("20260916115657_SmsQueueOtherLinkedTables")] + partial class SmsQueueOtherLinkedTables + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("BedBrigade.Common.Models.BedRequest", b => + { + b.Property("BedRequestId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BedRequestId")); + + b.Property("BedType") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("City") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Contacted") + .HasColumnType("bit"); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("DeliveryDate") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("GenderAge") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Group") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastName") + .HasMaxLength(25) + .HasColumnType("nvarchar(25)"); + + b.Property("Latitude") + .HasColumnType("decimal(18,10)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("Longitude") + .HasColumnType("decimal(18,10)"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Names") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Notes") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("NumberOfBeds") + .HasColumnType("int"); + + b.Property("Phone") + .HasMaxLength(14) + .HasColumnType("nvarchar(14)"); + + b.Property("PostalCode") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("PrimaryLanguage") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Reference") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ScheduleId") + .HasColumnType("int"); + + b.Property("SpeakEnglish") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("State") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Street") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Team") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("BedRequestId"); + + b.HasIndex("Email"); + + b.HasIndex("LocationId"); + + b.HasIndex("Phone"); + + b.HasIndex("ScheduleId"); + + b.HasIndex("Status"); + + b.ToTable("BedRequests"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.Configuration", b => + { + b.Property("ConfigurationId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ConfigurationId")); + + b.Property("ConfigurationKey") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ConfigurationValue") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Encrypted") + .HasColumnType("bit"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Section") + .HasColumnType("int"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("ConfigurationId"); + + b.HasIndex("LocationId", "ConfigurationKey") + .HasDatabaseName("IX_Configuration_LocationId_ConfigurationKey"); + + b.ToTable("Configurations"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.ContactUs", b => + { + b.Property("ContactUsId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContactUsId")); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(25) + .HasColumnType("nvarchar(25)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(14) + .HasColumnType("nvarchar(14)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("ContactUsId"); + + b.HasIndex("LocationId"); + + b.HasIndex("Phone"); + + b.HasIndex("Status"); + + b.ToTable("ContactUs"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.Content", b => + { + b.Property("ContentId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContentId")); + + b.Property("ContentHtml") + .HasColumnType("nvarchar(max)"); + + b.Property("ContentType") + .HasColumnType("int"); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("MainImageFileName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("ContentId"); + + b.HasIndex("ContentType"); + + b.HasIndex("LocationId"); + + b.HasIndex("Name"); + + b.ToTable("Content"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.ContentHistory", b => + { + b.Property("ContentHistoryId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContentHistoryId")); + + b.Property("ContentHtml") + .HasColumnType("nvarchar(max)"); + + b.Property("ContentId") + .HasColumnType("int"); + + b.Property("ContentType") + .HasColumnType("int"); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("MainImageFileName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("ContentHistoryId"); + + b.ToTable("ContentHistory"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.ContentTranslation", b => + { + b.Property("ContentTranslationId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContentTranslationId")); + + b.Property("ContentHtml") + .HasColumnType("nvarchar(max)"); + + b.Property("ContentType") + .HasColumnType("int"); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Culture") + .IsRequired() + .HasMaxLength(11) + .HasColumnType("nvarchar(11)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("ContentTranslationId"); + + b.HasIndex("Culture"); + + b.HasIndex("LocationId"); + + b.HasIndex("Name"); + + b.ToTable("ContentTranslations"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.ContentTranslationQueue", b => + { + b.Property("ContentTranslationQueueId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContentTranslationQueueId")); + + b.Property("ContentId") + .HasColumnType("int"); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Culture") + .IsRequired() + .HasMaxLength(11) + .HasColumnType("nvarchar(11)"); + + b.Property("FailureMessage") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("LockDate") + .HasColumnType("datetime2"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("QueueDate") + .HasColumnType("datetime2"); + + b.Property("SentDate") + .HasColumnType("datetime2"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("ContentTranslationQueueId"); + + b.ToTable("ContentTranslationQueue"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.Donation", b => + { + b.Property("DonationId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DonationId")); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Currency") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("DonationCampaignId") + .HasColumnType("int"); + + b.Property("DonationDate") + .HasColumnType("datetime2"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("FirstName") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Gross") + .HasColumnType("decimal(18,2)"); + + b.Property("LastName") + .HasMaxLength(25) + .HasColumnType("nvarchar(25)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("PaymentProcessor") + .HasMaxLength(80) + .HasColumnType("nvarchar(80)"); + + b.Property("PaymentStatus") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TaxFormSent") + .HasColumnType("bit"); + + b.Property("TransactionFee") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("DonationId"); + + b.HasIndex("LocationId"); + + b.ToTable("Donations"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.DonationCampaign", b => + { + b.Property("DonationCampaignId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DonationCampaignId")); + + b.Property("CampaignName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("EndDate") + .HasColumnType("datetime2"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("DonationCampaignId"); + + b.ToTable("DonationCampaigns"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.EmailQueue", b => + { + b.Property("EmailQueueId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EmailQueueId")); + + b.Property("BedRequestId") + .HasColumnType("int"); + + b.Property("Body") + .IsRequired() + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("ContactUsId") + .HasColumnType("int"); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("FailureMessage") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("FirstName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("FromAddress") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("FromDisplayName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("HtmlBody") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("LockDate") + .HasColumnType("datetime2"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Priority") + .HasColumnType("int"); + + b.Property("QueueDate") + .HasColumnType("datetime2"); + + b.Property("ReplyToAddress") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SentDate") + .HasColumnType("datetime2"); + + b.Property("SignUpId") + .HasColumnType("int"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Subject") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("TargetDate") + .HasColumnType("datetime2"); + + b.Property("ToAddress") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ToDisplayName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("EmailQueueId"); + + b.HasIndex("BedRequestId"); + + b.HasIndex("ContactUsId"); + + b.HasIndex("SignUpId"); + + b.ToTable("EmailQueue"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.GeoLocationQueue", b => + { + b.Property("GeoLocationQueueId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("GeoLocationQueueId")); + + b.Property("City") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CountryCode") + .IsRequired() + .HasMaxLength(2) + .HasColumnType("nvarchar(2)"); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("FailureMessage") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("Latitude") + .HasColumnType("decimal(18,10)"); + + b.Property("LockDate") + .HasColumnType("datetime2"); + + b.Property("Longitude") + .HasColumnType("decimal(18,10)"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("PostalCode") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Priority") + .HasColumnType("int"); + + b.Property("ProcessedDate") + .HasColumnType("datetime2"); + + b.Property("QueueDate") + .HasColumnType("datetime2"); + + b.Property("State") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Street") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TableId") + .HasColumnType("int"); + + b.Property("TableName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("GeoLocationQueueId"); + + b.HasIndex("TableId", "TableName") + .HasDatabaseName("IX_GeoLocation_TableId_TableName"); + + b.ToTable("GeoLocationQueue"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.Location", b => + { + b.Property("LocationId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("LocationId")); + + b.Property("BuildAddress") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("BuildCity") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("BuildPostalCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("BuildState") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ExternalContactUs") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("ExternalContent") + .HasColumnType("bit"); + + b.Property("ExternalDonate") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("ExternalHome") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("ExternalRequestABed") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("ExternalVolunteer") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("Group") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Latitude") + .HasColumnType("decimal(18,10)"); + + b.Property("Longitude") + .HasColumnType("decimal(18,10)"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("MailingAddress") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("MailingCity") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("MailingPostalCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("MailingState") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("MetroAreaId") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Route") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("ServiceZipCodes") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("TimeZoneId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("LocationId"); + + b.ToTable("Locations"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.MetroArea", b => + { + b.Property("MetroAreaId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MetroAreaId")); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("MetroAreaId"); + + b.ToTable("MetroAreas"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.Newsletter", b => + { + b.Property("NewsletterId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("NewsletterId")); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("NewsletterId"); + + b.HasIndex("LocationId"); + + b.ToTable("Newsletters"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.Role", b => + { + b.Property("RoleId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("RoleId")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.HasKey("RoleId"); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.Schedule", b => + { + b.Property("ScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ScheduleId")); + + b.Property("Address") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("Beds") + .HasColumnType("int"); + + b.Property("City") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("DeliveryVehiclesRegistered") + .HasColumnType("int"); + + b.Property("EventDateScheduled") + .HasColumnType("datetime2"); + + b.Property("EventDurationHours") + .HasColumnType("int"); + + b.Property("EventName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("EventNote") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("EventStatus") + .HasColumnType("int"); + + b.Property("EventType") + .HasColumnType("int"); + + b.Property("GroupName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("OrganizerEmail") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("OrganizerName") + .HasMaxLength(45) + .HasColumnType("nvarchar(45)"); + + b.Property("OrganizerPhone") + .HasMaxLength(14) + .HasColumnType("nvarchar(14)"); + + b.Property("PostalCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("PrivateEvent") + .HasColumnType("bit"); + + b.Property("State") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Teams") + .HasColumnType("int"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("VolunteersMax") + .HasColumnType("int"); + + b.Property("VolunteersRegistered") + .HasColumnType("int"); + + b.HasKey("ScheduleId"); + + b.HasIndex("EventType"); + + b.HasIndex("LocationId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.SignUp", b => + { + b.Property("SignUpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SignUpId")); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("NumberOfVolunteers") + .HasColumnType("int"); + + b.Property("ScheduleId") + .HasColumnType("int"); + + b.Property("SignUpNote") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("VehicleType") + .HasColumnType("int"); + + b.Property("VolunteerId") + .HasColumnType("int"); + + b.HasKey("SignUpId"); + + b.HasIndex("LocationId"); + + b.HasIndex("ScheduleId"); + + b.HasIndex("VolunteerId"); + + b.ToTable("SignUps"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.SmsQueue", b => + { + b.Property("SmsQueueId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SmsQueueId")); + + b.Property("BedRequestId") + .HasColumnType("int"); + + b.Property("Body") + .IsRequired() + .HasMaxLength(1600) + .HasColumnType("nvarchar(1600)"); + + b.Property("ContactName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ContactType") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("ContactUsId") + .HasColumnType("int"); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("FailureMessage") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("FromPhoneNumber") + .IsRequired() + .HasMaxLength(14) + .HasColumnType("nvarchar(14)"); + + b.Property("IsRead") + .HasColumnType("bit"); + + b.Property("IsReply") + .HasColumnType("bit"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("LockDate") + .HasColumnType("datetime2"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Priority") + .HasColumnType("int"); + + b.Property("QueueDate") + .HasColumnType("datetime2"); + + b.Property("SentDate") + .HasColumnType("datetime2"); + + b.Property("SignUpId") + .HasColumnType("int"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TargetDate") + .HasColumnType("datetime2"); + + b.Property("ToPhoneNumber") + .IsRequired() + .HasMaxLength(14) + .HasColumnType("nvarchar(14)"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("VolunteerId") + .HasColumnType("int"); + + b.HasKey("SmsQueueId"); + + b.HasIndex("BedRequestId"); + + b.HasIndex("ContactUsId"); + + b.HasIndex("LocationId"); + + b.HasIndex("SignUpId"); + + b.HasIndex("ToPhoneNumber"); + + b.HasIndex("VolunteerId"); + + b.ToTable("SmsQueue"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.SpokenLanguage", b => + { + b.Property("Name") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Name"); + + b.ToTable("SpokenLanguages"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.Subscription", b => + { + b.Property("SubscriptionId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SubscriptionId")); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("NewsletterId") + .HasColumnType("int"); + + b.Property("Subscribed") + .HasColumnType("bit"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("SubscriptionId"); + + b.HasIndex("NewsletterId"); + + b.ToTable("Subscriptions"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.Template", b => + { + b.Property("TemplateId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TemplateId")); + + b.Property("ContentHtml") + .HasColumnType("nvarchar(max)"); + + b.Property("ContentType") + .HasColumnType("int"); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("TemplateId"); + + b.ToTable("Templates"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.Translation", b => + { + b.Property("TranslationId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TranslationId")); + + b.Property("Content") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Culture") + .IsRequired() + .HasMaxLength(11) + .HasColumnType("nvarchar(11)"); + + b.Property("Hash") + .IsRequired() + .HasMaxLength(88) + .HasColumnType("nvarchar(88)"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ParentId") + .HasColumnType("int"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("TranslationId"); + + b.HasIndex("Culture"); + + b.ToTable("Translations"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.TranslationQueue", b => + { + b.Property("TranslationQueueId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TranslationQueueId")); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Culture") + .IsRequired() + .HasMaxLength(11) + .HasColumnType("nvarchar(11)"); + + b.Property("FailureMessage") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("LockDate") + .HasColumnType("datetime2"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("QueueDate") + .HasColumnType("datetime2"); + + b.Property("SentDate") + .HasColumnType("datetime2"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TranslationId") + .HasColumnType("int"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("TranslationQueueId"); + + b.ToTable("TranslationQueue"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.User", b => + { + b.Property("UserName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("FailedLoginAttempts") + .HasColumnType("int"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("FkRole") + .HasColumnType("int"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(25) + .HasColumnType("nvarchar(25)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("LockoutEndUtc") + .HasColumnType("datetime2"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("MustChangePassword") + .HasColumnType("bit"); + + b.Property("PasswordHash") + .HasMaxLength(255) + .HasColumnType("varbinary(255)"); + + b.Property("PasswordSalt") + .HasMaxLength(255) + .HasColumnType("varbinary(255)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(14) + .HasColumnType("nvarchar(14)"); + + b.Property("Role") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("UserName"); + + b.HasIndex("Email"); + + b.HasIndex("LocationId"); + + b.HasIndex("Phone"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.UserPersist", b => + { + b.Property("UserName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasColumnOrder(0); + + b.Property("Grid") + .HasColumnType("int") + .HasColumnOrder(1); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("UserName", "Grid"); + + b.ToTable("UserPersist"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.Volunteer", b => + { + b.Property("VolunteerId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("VolunteerId")); + + b.Property("AttendChurch") + .HasColumnType("bit"); + + b.Property("CanYouTranslate") + .HasColumnType("int"); + + b.Property("ChurchName") + .HasMaxLength(80) + .HasColumnType("nvarchar(80)"); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Email") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Group") + .HasMaxLength(80) + .HasColumnType("nvarchar(80)"); + + b.Property("IHaveVolunteeredBefore") + .HasColumnType("bit"); + + b.Property("LastName") + .HasMaxLength(25) + .HasColumnType("nvarchar(25)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Message") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("Organization") + .HasMaxLength(80) + .HasColumnType("nvarchar(80)"); + + b.Property("OtherArea") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("OtherLanguagesSpoken") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("Phone") + .HasMaxLength(14) + .HasColumnType("nvarchar(14)"); + + b.Property("SubscribedEmail") + .HasColumnType("bit"); + + b.Property("SubscribedSms") + .HasColumnType("bit"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("VehicleDescription") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("VehicleType") + .HasColumnType("int"); + + b.Property("VolunteerArea") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("VolunteerId"); + + b.HasIndex("Email"); + + b.HasIndex("LocationId"); + + b.HasIndex("Phone"); + + b.ToTable("Volunteers"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.VolunteerFor", b => + { + b.Property("VolunteerForId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("VolunteerForId")); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("CreateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("MachineName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UpdateDate") + .HasColumnType("datetime2"); + + b.Property("UpdateUser") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("VolunteerForId"); + + b.ToTable("VolunteersFor"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.BedRequest", b => + { + b.HasOne("BedBrigade.Common.Models.Location", "Location") + .WithMany("BedRequests") + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Location"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.ContactUs", b => + { + b.HasOne("BedBrigade.Common.Models.Location", null) + .WithMany("ContactUs") + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.Content", b => + { + b.HasOne("BedBrigade.Common.Models.Location", null) + .WithMany("Contents") + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.Donation", b => + { + b.HasOne("BedBrigade.Common.Models.Location", null) + .WithMany("Donations") + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.EmailQueue", b => + { + b.HasOne("BedBrigade.Common.Models.BedRequest", "BedRequest") + .WithMany() + .HasForeignKey("BedRequestId"); + + b.HasOne("BedBrigade.Common.Models.SignUp", "ContactUs") + .WithMany() + .HasForeignKey("ContactUsId"); + + b.HasOne("BedBrigade.Common.Models.SignUp", "SignUp") + .WithMany() + .HasForeignKey("SignUpId"); + + b.Navigation("BedRequest"); + + b.Navigation("ContactUs"); + + b.Navigation("SignUp"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.Schedule", b => + { + b.HasOne("BedBrigade.Common.Models.Location", null) + .WithMany("Schedules") + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.SignUp", b => + { + b.HasOne("BedBrigade.Common.Models.Schedule", "Schedule") + .WithMany() + .HasForeignKey("ScheduleId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("BedBrigade.Common.Models.Volunteer", "Volunteer") + .WithMany() + .HasForeignKey("VolunteerId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("Schedule"); + + b.Navigation("Volunteer"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.SmsQueue", b => + { + b.HasOne("BedBrigade.Common.Models.BedRequest", "BedRequest") + .WithMany() + .HasForeignKey("BedRequestId"); + + b.HasOne("BedBrigade.Common.Models.ContactUs", "ContactUs") + .WithMany() + .HasForeignKey("ContactUsId"); + + b.HasOne("BedBrigade.Common.Models.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BedBrigade.Common.Models.SignUp", "SignUp") + .WithMany() + .HasForeignKey("SignUpId"); + + b.HasOne("BedBrigade.Common.Models.Volunteer", "Volunteer") + .WithMany() + .HasForeignKey("VolunteerId"); + + b.Navigation("BedRequest"); + + b.Navigation("ContactUs"); + + b.Navigation("Location"); + + b.Navigation("SignUp"); + + b.Navigation("Volunteer"); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.User", b => + { + b.HasOne("BedBrigade.Common.Models.Location", null) + .WithMany("Users") + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.Volunteer", b => + { + b.HasOne("BedBrigade.Common.Models.Location", null) + .WithMany("Volunteers") + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("BedBrigade.Common.Models.Location", b => + { + b.Navigation("BedRequests"); + + b.Navigation("ContactUs"); + + b.Navigation("Contents"); + + b.Navigation("Donations"); + + b.Navigation("Schedules"); + + b.Navigation("Users"); + + b.Navigation("Volunteers"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BedBrigade.Data/Migrations/20260916115657_SmsQueueOtherLinkedTables.cs b/BedBrigade.Data/Migrations/20260916115657_SmsQueueOtherLinkedTables.cs new file mode 100644 index 00000000..2738dfbf --- /dev/null +++ b/BedBrigade.Data/Migrations/20260916115657_SmsQueueOtherLinkedTables.cs @@ -0,0 +1,78 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BedBrigade.Data.Migrations +{ + /// + public partial class SmsQueueOtherLinkedTables : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ContactUsId", + table: "SmsQueue", + type: "int", + nullable: true); + + migrationBuilder.AddColumn( + name: "VolunteerId", + table: "SmsQueue", + type: "int", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_SmsQueue_ContactUsId", + table: "SmsQueue", + column: "ContactUsId"); + + migrationBuilder.CreateIndex( + name: "IX_SmsQueue_VolunteerId", + table: "SmsQueue", + column: "VolunteerId"); + + migrationBuilder.AddForeignKey( + name: "FK_SmsQueue_ContactUs_ContactUsId", + table: "SmsQueue", + column: "ContactUsId", + principalTable: "ContactUs", + principalColumn: "ContactUsId"); + + migrationBuilder.AddForeignKey( + name: "FK_SmsQueue_Volunteers_VolunteerId", + table: "SmsQueue", + column: "VolunteerId", + principalTable: "Volunteers", + principalColumn: "VolunteerId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_SmsQueue_ContactUs_ContactUsId", + table: "SmsQueue"); + + migrationBuilder.DropForeignKey( + name: "FK_SmsQueue_Volunteers_VolunteerId", + table: "SmsQueue"); + + migrationBuilder.DropIndex( + name: "IX_SmsQueue_ContactUsId", + table: "SmsQueue"); + + migrationBuilder.DropIndex( + name: "IX_SmsQueue_VolunteerId", + table: "SmsQueue"); + + migrationBuilder.DropColumn( + name: "ContactUsId", + table: "SmsQueue"); + + migrationBuilder.DropColumn( + name: "VolunteerId", + table: "SmsQueue"); + } + } +} diff --git a/BedBrigade.Data/Migrations/DataContextModelSnapshot.cs b/BedBrigade.Data/Migrations/DataContextModelSnapshot.cs index d3fcf4a5..ed407fd3 100644 --- a/BedBrigade.Data/Migrations/DataContextModelSnapshot.cs +++ b/BedBrigade.Data/Migrations/DataContextModelSnapshot.cs @@ -1254,6 +1254,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasMaxLength(20) .HasColumnType("nvarchar(20)"); + b.Property("ContactUsId") + .HasColumnType("int"); + b.Property("CreateDate") .HasColumnType("datetime2"); @@ -1318,16 +1321,23 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasMaxLength(100) .HasColumnType("nvarchar(100)"); + b.Property("VolunteerId") + .HasColumnType("int"); + b.HasKey("SmsQueueId"); b.HasIndex("BedRequestId"); + b.HasIndex("ContactUsId"); + b.HasIndex("LocationId"); b.HasIndex("SignUpId"); b.HasIndex("ToPhoneNumber"); + b.HasIndex("VolunteerId"); + b.ToTable("SmsQueue"); }); @@ -1912,6 +1922,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) .WithMany() .HasForeignKey("BedRequestId"); + b.HasOne("BedBrigade.Common.Models.ContactUs", "ContactUs") + .WithMany() + .HasForeignKey("ContactUsId"); + b.HasOne("BedBrigade.Common.Models.Location", "Location") .WithMany() .HasForeignKey("LocationId") @@ -1922,11 +1936,19 @@ protected override void BuildModel(ModelBuilder modelBuilder) .WithMany() .HasForeignKey("SignUpId"); + b.HasOne("BedBrigade.Common.Models.Volunteer", "Volunteer") + .WithMany() + .HasForeignKey("VolunteerId"); + b.Navigation("BedRequest"); + b.Navigation("ContactUs"); + b.Navigation("Location"); b.Navigation("SignUp"); + + b.Navigation("Volunteer"); }); modelBuilder.Entity("BedBrigade.Common.Models.User", b => diff --git a/BedBrigade.Data/Services/ISignUpDataService.cs b/BedBrigade.Data/Services/ISignUpDataService.cs index b772c724..83e05565 100644 --- a/BedBrigade.Data/Services/ISignUpDataService.cs +++ b/BedBrigade.Data/Services/ISignUpDataService.cs @@ -13,5 +13,6 @@ public interface ISignUpDataService : IRepository Task>> GetVolunteersNotSignedUpForAnEvent(int locationId, int scheduleId); Task>> GetAllForScheduleIdAsync(int scheduleId); Task>> GetFutureSignUpsForLocation(int locationId); + Task>> GetFutureSignUpsByPhone(string phone); } } \ No newline at end of file diff --git a/BedBrigade.Data/Services/SignUpDataService.cs b/BedBrigade.Data/Services/SignUpDataService.cs index d34d79e1..522f0add 100644 --- a/BedBrigade.Data/Services/SignUpDataService.cs +++ b/BedBrigade.Data/Services/SignUpDataService.cs @@ -1,8 +1,12 @@ using BedBrigade.Common.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Internal; +using Stripe.Terminal; using System.Data.Common; +using AKSoftware.Localization.MultiLanguages; +using BedBrigade.Common.Logic; using Twilio.TwiML.Voice; +using StringUtil = BedBrigade.Common.Logic.StringUtil; namespace BedBrigade.Data.Services; @@ -159,6 +163,31 @@ public async Task>> GetFutureSignUpsForLocation(int return new ServiceResponse>($"Found {result.Count} sign-ups for location {locationId}", true, result); } + public async Task>> GetFutureSignUpsByPhone(string phone) + { + string cacheKey = _cachingService.BuildCacheKey(GetEntityName(), $"GetFutureSignUpsByPhone({phone})"); + List? cachedContent = _cachingService.Get>(cacheKey); + + if (cachedContent != null) + { + return new ServiceResponse>($"Found {cachedContent.Count} future sign-ups for phone {phone} in cache", true, cachedContent); + } + + string phoneNumbersOnly = StringUtil.ExtractDigits(phone); + string formattedPhone = phoneNumbersOnly.FormatPhoneNumber(); + + using var ctx = _contextFactory.CreateDbContext(); + List result = await ctx.SignUps + .Include(signUp => signUp.Volunteer) + .Include(signUp => signUp.Schedule) + .Where(signUp => (signUp.Volunteer.Phone == phoneNumbersOnly || signUp.Volunteer.Phone == formattedPhone) + && signUp.Schedule.EventDateScheduled.Date >= DateTime.UtcNow.Date) + .ToListAsync(); + + _cachingService.Set(cacheKey, result); + return new ServiceResponse>($"Found {result.Count} future sign-ups for phone {phone}", true, result); + } + public async Task>> GetAllForScheduleIdAsync(int scheduleId) { using (var ctx = _contextFactory.CreateDbContext()) diff --git a/BedBrigade.Data/Services/SmsQueueDataService.cs b/BedBrigade.Data/Services/SmsQueueDataService.cs index 195c0673..812fe4dd 100644 --- a/BedBrigade.Data/Services/SmsQueueDataService.cs +++ b/BedBrigade.Data/Services/SmsQueueDataService.cs @@ -21,7 +21,9 @@ public class SmsQueueDataService : Repository, ISmsQueueDataService private IScheduleDataService _scheduleDataService; private readonly ITimezoneDataService _svcTimeZone; private readonly IBedRequestPhoneDataService _bedRequestPhoneDataService; - + private readonly ISignUpDataService _signUpDataService; + + public SmsQueueDataService(IDbContextFactory contextFactory, ICachingService cachingService, IAuthService authService, @@ -33,7 +35,8 @@ public SmsQueueDataService(IDbContextFactory contextFactory, ITimezoneDataService svcTimeZone, ILocationDataService locationDataService, IScheduleDataService scheduleDataService, - IBedRequestPhoneDataService bedRequestPhoneDataService) : base(contextFactory, cachingService, authService) + IBedRequestPhoneDataService bedRequestPhoneDataService, + ISignUpDataService signUpDataService) : base(contextFactory, cachingService, authService) { _contextFactory = contextFactory; _cachingService = cachingService; @@ -46,6 +49,7 @@ public SmsQueueDataService(IDbContextFactory contextFactory, _locationDataService = locationDataService; _scheduleDataService = scheduleDataService; _bedRequestPhoneDataService = bedRequestPhoneDataService; + _signUpDataService = signUpDataService; } public async Task> GetLockedMessages() @@ -404,6 +408,69 @@ private async Task FillContactByPhoneNumberFromUser(SmsQueue smsQueue) } private async Task FillLocationByFromPhoneNumber(SmsQueue smsQueue) + { + //Try to find by the Bed Requestor + var bedRequestorResult = await _bedRequestPhoneDataService.GetByPhone(smsQueue.ToPhoneNumber); + + if (bedRequestorResult.Success && bedRequestorResult.Data != null) + { + smsQueue.LocationId = bedRequestorResult.Data.LocationId; + smsQueue.BedRequestId = bedRequestorResult.Data.BedRequestId; + return string.Empty; + } + + //Try to find it by the SignUp + if (await FillSignUpIdByPhone(smsQueue)) + { + return string.Empty; + } + + //Try to find by the Volunteer + var volunteerResult = await _volunteerDataService.GetByPhone(smsQueue.ToPhoneNumber); + + if (volunteerResult.Success && volunteerResult.Data != null) + { + smsQueue.LocationId = volunteerResult.Data.LocationId; + smsQueue.VolunteerId = volunteerResult.Data.VolunteerId; + return string.Empty; + } + + //Try to find by Contact Us + var contactUsResult = await _contactUsDataService.GetByPhone(smsQueue.ToPhoneNumber); + + if (contactUsResult.Success && contactUsResult.Data != null) + { + smsQueue.LocationId = contactUsResult.Data.LocationId; + smsQueue.ContactUsId = contactUsResult.Data.ContactUsId; + return string.Empty; + } + + //Try to find by the User + var userResult = await _userDataService.GetByPhone(smsQueue.ToPhoneNumber); + + if (userResult.Success && userResult.Data != null) + { + smsQueue.LocationId = userResult.Data.LocationId; + return string.Empty; + } + + return await FillLocationPhoneNumberByConfig(smsQueue); + } + + private async Task FillSignUpIdByPhone(SmsQueue smsQueue) + { + var result = await _signUpDataService.GetFutureSignUpsByPhone(smsQueue.ToPhoneNumber); + if (result.Success && result.Data != null) + { + smsQueue.SignUpId = result.Data.First().SignUpId; + smsQueue.VolunteerId = result.Data.First().VolunteerId; + return true; + } + + return false; + } + + private async Task FillLocationPhoneNumberByConfig(SmsQueue smsQueue) { var result = await _configDataService.GetAllAsync(ConfigSection.Sms); if (!result.Success || result.Data == null || !result.Data.Any())