From 7cd388c85b9f6e023f039577df144a4f1de9734e Mon Sep 17 00:00:00 2001 From: Jeff Leung Date: Tue, 28 Dec 2021 19:40:29 -0800 Subject: [PATCH] Move db context out of the main api project --- TwilioSMSReceiver.Data/Models/SMSModel.cs | 38 +++++++++++++++++++ TwilioSMSReceiver.Data/SMSDbCtx.cs | 16 ++++++++ .../TwilioSMSReceiver.Data.csproj | 12 ++++++ TwilioSMSReceiver.sln | 11 +++++- 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 TwilioSMSReceiver.Data/Models/SMSModel.cs create mode 100644 TwilioSMSReceiver.Data/SMSDbCtx.cs create mode 100644 TwilioSMSReceiver.Data/TwilioSMSReceiver.Data.csproj diff --git a/TwilioSMSReceiver.Data/Models/SMSModel.cs b/TwilioSMSReceiver.Data/Models/SMSModel.cs new file mode 100644 index 0000000..4016810 --- /dev/null +++ b/TwilioSMSReceiver.Data/Models/SMSModel.cs @@ -0,0 +1,38 @@ +#nullable disable +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace TwilioSMSReceiver.Data.Models +{ + public class SMSModel + { + [Key] + public int Id { get; set; } + [Required] + public string ReceivedNumber { get; set; } + + [Required] + public string SenderNumber { get; set; } + public DateTime TimeReceived { get; set; } + public string? MessageContents { get; set; } + public ICollection MMSContent { get; set; } + public bool IsForwardedYet { get; set; } + } + + public class MMSModel + { + [Key] + public int Id { get; set; } + public int SMSModelId { get; set; } + public SMSModel ParentSMSMessage { get; set; } + public string OriginalMMSData { get; set; } + } + + public class MSTeamsWebHook + { + public int Id { get; set; } + public string WebHookUri { get; set; } + } +} diff --git a/TwilioSMSReceiver.Data/SMSDbCtx.cs b/TwilioSMSReceiver.Data/SMSDbCtx.cs new file mode 100644 index 0000000..66522c5 --- /dev/null +++ b/TwilioSMSReceiver.Data/SMSDbCtx.cs @@ -0,0 +1,16 @@ +using Microsoft.EntityFrameworkCore; +using TwilioSMSReceiver.Data.Models; + +namespace TwilioSMSReceiver.Data +{ + public class SMSDbCtx : DbContext + { + public SMSDbCtx(DbContextOptions options) : base(options) + { + } + + public DbSet SMSMessages { get; set; } + public DbSet MMSMessages { get; set; } + public DbSet MSTeamsWebHooks { get; set; } + } +} diff --git a/TwilioSMSReceiver.Data/TwilioSMSReceiver.Data.csproj b/TwilioSMSReceiver.Data/TwilioSMSReceiver.Data.csproj new file mode 100644 index 0000000..f1c0551 --- /dev/null +++ b/TwilioSMSReceiver.Data/TwilioSMSReceiver.Data.csproj @@ -0,0 +1,12 @@ + + + + net6.0 + enable + + + + + + + diff --git a/TwilioSMSReceiver.sln b/TwilioSMSReceiver.sln index 1675481..1f428f8 100644 --- a/TwilioSMSReceiver.sln +++ b/TwilioSMSReceiver.sln @@ -3,7 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31912.275 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TwilioSMSReceiver", "TwilioSMSReceiver\TwilioSMSReceiver.csproj", "{223C45EA-FAAC-44B8-B7DF-5DAA257CB52E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TwilioSMSReceiver", "TwilioSMSReceiver\TwilioSMSReceiver.csproj", "{223C45EA-FAAC-44B8-B7DF-5DAA257CB52E}" + ProjectSection(ProjectDependencies) = postProject + {642DADA5-E7A1-4754-A035-E2498C6CCF38} = {642DADA5-E7A1-4754-A035-E2498C6CCF38} + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TwilioSMSReceiver.Data", "TwilioSMSReceiver.Data\TwilioSMSReceiver.Data.csproj", "{642DADA5-E7A1-4754-A035-E2498C6CCF38}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +20,10 @@ Global {223C45EA-FAAC-44B8-B7DF-5DAA257CB52E}.Debug|Any CPU.Build.0 = Debug|Any CPU {223C45EA-FAAC-44B8-B7DF-5DAA257CB52E}.Release|Any CPU.ActiveCfg = Release|Any CPU {223C45EA-FAAC-44B8-B7DF-5DAA257CB52E}.Release|Any CPU.Build.0 = Release|Any CPU + {642DADA5-E7A1-4754-A035-E2498C6CCF38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {642DADA5-E7A1-4754-A035-E2498C6CCF38}.Debug|Any CPU.Build.0 = Debug|Any CPU + {642DADA5-E7A1-4754-A035-E2498C6CCF38}.Release|Any CPU.ActiveCfg = Release|Any CPU + {642DADA5-E7A1-4754-A035-E2498C6CCF38}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE