From ff2a72f11251cad5394469c05141ca96d4c9b5a3 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 20 Mar 2023 21:48:32 +0000 Subject: [PATCH] a Startup --- .../new-templates/ViewGenerator/Create.cshtml | 14 +++--- .../new-templates/ViewGenerator/Delete.cshtml | 18 ++++---- .../ViewGenerator/Details.cshtml | 16 +++---- .../new-templates/ViewGenerator/Edit.cshtml | 12 ++--- .../new-templates/ViewGenerator/List.cshtml | 24 +++++----- src/Yavsc.Server/Interfaces/IFreeDateSet.cs | 1 + .../Interfaces/IScheduledEvent.cs | 4 +- .../Models/Calendar/Availabliity.cs | 9 ++++ src/Yavsc.Server/Models/Calendar/Period.cs | 2 +- .../Models/Calendar/Periodicity.cs | 2 +- .../Models/Calendar/PositionAndKeyphrase.cs | 5 +- .../Models/Calendar/ScheduledEvent.cs | 3 +- .../Models/EMailing/MailingTemplate.cs | 1 + .../Calendar/DateTimeChooserViewModel.cs | 2 +- src/Yavsc/Program.cs | 33 ++++++------- src/Yavsc/Startup/Startup.FileServer.cs | 2 +- src/Yavsc/Startup/Startup.SanityChecks.cs | 2 +- src/Yavsc/Startup/Startup.cs | 46 ++++--------------- src/Yavsc/Yavsc.csproj | 1 + 19 files changed, 90 insertions(+), 107 deletions(-) create mode 100644 src/Yavsc.Server/Models/Calendar/Availabliity.cs diff --git a/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Create.cshtml b/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Create.cshtml index 4cd712a2..12f13963 100644 --- a/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Create.cshtml +++ b/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Create.cshtml @@ -9,20 +9,20 @@ else if (Model.IsLayoutPageSelected) { @:@@{ - @:ViewData["Title"] = @@SR["@Model.ViewName"]; + @:ViewData["Title"] = @@Model.ViewName"]; if (!string.IsNullOrEmpty(Model.LayoutPageFile)) { @:Layout = "@Model.LayoutPageFile"; } @:} @: -@:

@@SR["@Model.ViewName"]

+@:

@@Model.ViewName"]

@: } else { @:@@{ - @:Layout = null; + @:Layout = "null"; @:} @: @: @@ -38,9 +38,9 @@ } @:
@:
- @:

@@SR["@Model.ViewDataTypeShortName"]

+ @:

@@Model.ViewDataTypeShortName"]

@:
- @:
+ @:
foreach (var property in Model.ModelMetadata.Properties) { if (property.Scaffold && !property.IsAutoGenerated && !property.IsReadOnly) @@ -107,7 +107,7 @@
- @@SR["Back to List"] + @Back to List
@{ @@ -142,4 +142,4 @@ { return string.Equals("System.Guid", property.TypeName, StringComparison.OrdinalIgnoreCase); } -} \ No newline at end of file +} diff --git a/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Delete.cshtml b/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Delete.cshtml index d2845a09..d8fbd304 100644 --- a/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Delete.cshtml +++ b/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Delete.cshtml @@ -9,20 +9,20 @@ else if (Model.IsLayoutPageSelected) { @:@@{ - @:ViewData["Title"] = @@SR["@Model.ViewName"]; + @:ViewData["Title"] = @@Model.ViewName"]; if (!string.IsNullOrEmpty(Model.LayoutPageFile)) { @:Layout = "@Model.LayoutPageFile"; } @:} @: -@:

@@SR["@Model.ViewName"]

+@:

@@Model.ViewName"]

@: } else { @:@@{ - @:Layout = null; + @:Layout = "null"; @:} @: @: @@ -30,16 +30,16 @@ @: @: @: - @:@@SR[@Model.ViewName] + @:@@@Model.ViewName @: @: @: // PushIndent(" "); } } -

@@SR["AreYourSureYouWantToDeleteThis"]

+

@AreYourSureYouWantToDeleteThis

-

@@SR[@Model.ViewDataTypeShortName]

+

@@@Model.ViewDataTypeShortName


@{ @@ -59,8 +59,8 @@ @: @:
@:
- @: | - @:@@SR["Back to List"] + @: | + @:Back to List @:
@:
@:
@@ -78,4 +78,4 @@ //Todo: Get the association for the property and use that. return property.PropertyName; } -} \ No newline at end of file +} diff --git a/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Details.cshtml b/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Details.cshtml index 8d443d94..99024a45 100644 --- a/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Details.cshtml +++ b/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Details.cshtml @@ -9,20 +9,20 @@ else if (Model.IsLayoutPageSelected) { @:@@{ - @:ViewData["Title"] = @@SR["@Model.ViewName"]; + @:ViewData["Title"] = @@Model.ViewName"]; if (!string.IsNullOrEmpty(Model.LayoutPageFile)) { @:Layout = "@Model.LayoutPageFile"; } @:} @: -@:

@@SR["@Model.ViewName"]

+@:

@@Model.ViewName"]

@: } else { @:@@{ - @:Layout = null; + @:Layout = "null"; @:} @: @: @@ -61,13 +61,13 @@ string pkName = GetPrimaryKeyName(); if (pkName != null) { - @:@@SR["Edit"] | - @:@@SR["Back to List"] + @:@Edit | + @:Back to List } else { - @:@@Html.ActionLink(@@SR["Edit"], "Edit", new { /* id = Model.PrimaryKey */ }) | - @:@@SR["Back to List"] + @:@@Html.ActionLink(@Edit, "Edit", new { /* id = Model.PrimaryKey */ }) | + @:Back to List } }

@{ @@ -92,4 +92,4 @@ //Todo: Get the association for the property and use that. return property.PropertyName; } -} \ No newline at end of file +} diff --git a/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Edit.cshtml b/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Edit.cshtml index df402e34..12d7b2a5 100644 --- a/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Edit.cshtml +++ b/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/Edit.cshtml @@ -9,20 +9,20 @@ else if (Model.IsLayoutPageSelected) { @:@@{ - @:ViewData["Title"] = @@SR["@Model.ViewName"]; + @:ViewData["Title"] = @@Model.ViewName"]; if (!string.IsNullOrEmpty(Model.LayoutPageFile)) { @:Layout = "@Model.LayoutPageFile"; } @:} @: -@:

@@SR["@Model.ViewName"]

+@:

@@Model.ViewName"]

@: } else { @:@@{ - @:Layout = null; + @:Layout = "null"; @:} @: @: @@ -30,7 +30,7 @@ @: @: @: - @:@@SR["@Model.ViewName"] + @:@@Model.ViewName"] @: @: @: @@ -40,7 +40,7 @@ @:
@:

@Model.ViewDataTypeShortName

@:
- @:
+ @:
foreach (PropertyMetadata property in Model.ModelMetadata.Properties) { if (property.Scaffold) @@ -111,7 +111,7 @@
- @@SR["Back to List"] + Back to List
@{ diff --git a/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/List.cshtml b/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/List.cshtml index f0e78978..1e52f7fd 100644 --- a/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/List.cshtml +++ b/scripts/configure/tools/mvc-code-generators/new-templates/ViewGenerator/List.cshtml @@ -9,20 +9,20 @@ else if (Model.IsLayoutPageSelected) { @:@@{ - @:ViewData["Title"] = @@SR["@Model.ViewName"]; + @:ViewData["Title"] = @@Model.ViewName"]; if (!string.IsNullOrEmpty(Model.LayoutPageFile)) { @:Layout = "@Model.LayoutPageFile"; } @:} @: -@:

@@SR["@Model.ViewName"]

+@:

@@Model.ViewName"]

@: } else { @:@@{ - @:Layout = null; + @:Layout = "null"; @:} @: @: @@ -30,13 +30,13 @@ @: @: @: - @:@@SR["@Model.ViewName"] + @:@@Model.ViewName"] @: @: // PushIndent(" "); } @:

- @:@@SR["Create New"] + @:Create New @:

@: @: @@ -69,17 +69,17 @@ if (pkName != null) { @: } else { } @: @@ -112,4 +112,4 @@ { return "IEnumerable<" + typeName + ">"; } -} \ No newline at end of file +} diff --git a/src/Yavsc.Server/Interfaces/IFreeDateSet.cs b/src/Yavsc.Server/Interfaces/IFreeDateSet.cs index 46c30eab..640248d3 100644 --- a/src/Yavsc.Server/Interfaces/IFreeDateSet.cs +++ b/src/Yavsc.Server/Interfaces/IFreeDateSet.cs @@ -19,6 +19,7 @@ // along with this program. If not, see . using System; using System.Collections.Generic; +using Yavsc.Server.Models.Calendar; namespace Yavsc.Models.Calendar { diff --git a/src/Yavsc.Server/Interfaces/IScheduledEvent.cs b/src/Yavsc.Server/Interfaces/IScheduledEvent.cs index 1043ac4d..6ad04fcd 100644 --- a/src/Yavsc.Server/Interfaces/IScheduledEvent.cs +++ b/src/Yavsc.Server/Interfaces/IScheduledEvent.cs @@ -19,6 +19,8 @@ // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see . +using Yavsc.Server.Models.Calendar; + namespace Yavsc.Models.Calendar { public interface IScheduledEvent @@ -31,4 +33,4 @@ namespace Yavsc.Models.Calendar Period Period { get; set; } } -} \ No newline at end of file +} diff --git a/src/Yavsc.Server/Models/Calendar/Availabliity.cs b/src/Yavsc.Server/Models/Calendar/Availabliity.cs new file mode 100644 index 00000000..e39dd476 --- /dev/null +++ b/src/Yavsc.Server/Models/Calendar/Availabliity.cs @@ -0,0 +1,9 @@ +using Yavsc.Models.Calendar; + +namespace Yavsc.Server.Models.Calendar +{ + public class Availability : List + { + + } +} diff --git a/src/Yavsc.Server/Models/Calendar/Period.cs b/src/Yavsc.Server/Models/Calendar/Period.cs index a3ee9710..50303463 100644 --- a/src/Yavsc.Server/Models/Calendar/Period.cs +++ b/src/Yavsc.Server/Models/Calendar/Period.cs @@ -22,7 +22,7 @@ using System; using System.ComponentModel.DataAnnotations; -namespace Yavsc.Models.Calendar +namespace Yavsc.Server.Models.Calendar { /// /// Hollydays. diff --git a/src/Yavsc.Server/Models/Calendar/Periodicity.cs b/src/Yavsc.Server/Models/Calendar/Periodicity.cs index 119dee76..059b50ab 100644 --- a/src/Yavsc.Server/Models/Calendar/Periodicity.cs +++ b/src/Yavsc.Server/Models/Calendar/Periodicity.cs @@ -19,7 +19,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see . -namespace Yavsc.Models.Calendar +namespace Yavsc.Server.Models.Calendar { /// /// Periodicity. diff --git a/src/Yavsc.Server/Models/Calendar/PositionAndKeyphrase.cs b/src/Yavsc.Server/Models/Calendar/PositionAndKeyphrase.cs index a4f45240..f563f6c6 100644 --- a/src/Yavsc.Server/Models/Calendar/PositionAndKeyphrase.cs +++ b/src/Yavsc.Server/Models/Calendar/PositionAndKeyphrase.cs @@ -21,9 +21,10 @@ -namespace Yavsc.Models.Calendar +using Yavsc.Models.Relationship; + +namespace Yavsc.Server.Models.Calendar { - using Models.Relationship; /// /// Position and keyphrase. /// diff --git a/src/Yavsc.Server/Models/Calendar/ScheduledEvent.cs b/src/Yavsc.Server/Models/Calendar/ScheduledEvent.cs index dfeb1431..6ea5b5de 100644 --- a/src/Yavsc.Server/Models/Calendar/ScheduledEvent.cs +++ b/src/Yavsc.Server/Models/Calendar/ScheduledEvent.cs @@ -21,6 +21,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; +using Yavsc.Server.Models.Calendar; namespace Yavsc.Models.Calendar { @@ -42,4 +43,4 @@ namespace Yavsc.Models.Calendar set; } } -} \ No newline at end of file +} diff --git a/src/Yavsc.Server/Models/EMailing/MailingTemplate.cs b/src/Yavsc.Server/Models/EMailing/MailingTemplate.cs index f3e70ac3..66b3f6dd 100644 --- a/src/Yavsc.Server/Models/EMailing/MailingTemplate.cs +++ b/src/Yavsc.Server/Models/EMailing/MailingTemplate.cs @@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema; using Yavsc.Attributes.Validation; using Yavsc.Models; using Yavsc.Models.Calendar; +using Yavsc.Server.Models.Calendar; namespace Yavsc.Server.Models.EMailing { diff --git a/src/Yavsc.Server/ViewModels/Calendar/DateTimeChooserViewModel.cs b/src/Yavsc.Server/ViewModels/Calendar/DateTimeChooserViewModel.cs index 46d2fe99..de078cdb 100644 --- a/src/Yavsc.Server/ViewModels/Calendar/DateTimeChooserViewModel.cs +++ b/src/Yavsc.Server/ViewModels/Calendar/DateTimeChooserViewModel.cs @@ -1,6 +1,6 @@ using System; using Yavsc.Models.Calendar; - +using Yavsc.Server.Models.Calendar; namespace Yavsc.ViewModels.Calendar { diff --git a/src/Yavsc/Program.cs b/src/Yavsc/Program.cs index 07274680..9dbd245a 100644 --- a/src/Yavsc/Program.cs +++ b/src/Yavsc/Program.cs @@ -1,27 +1,20 @@ -var builder = WebApplication.CreateBuilder(args); -// Add services to the container. -builder.Services.AddControllersWithViews(); +using Microsoft.AspNetCore; -var app = builder.Build(); - -// Configure the HTTP request pipeline. -if (!app.Environment.IsDevelopment()) +namespace Yavsc { - app.UseExceptionHandler("/Home/Error"); - // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. - app.UseHsts(); + public class Program + { + public static void Main(string[] args) + { + BuildWebHost(args).Run(); + } + + public static IWebHost BuildWebHost(string[] args) { + return WebHost.CreateDefaultBuilder(args).UseStartup().Build(); + } + } } -app.UseHttpsRedirection(); -app.UseStaticFiles(); - -app.UseRouting(); - -app.UseAuthorization(); -app.MapControllerRoute( - name: "default", - pattern: "{controller=Home}/{action=Index}/{id?}"); -app.Run(); diff --git a/src/Yavsc/Startup/Startup.FileServer.cs b/src/Yavsc/Startup/Startup.FileServer.cs index 9d5522ad..1c355d3e 100644 --- a/src/Yavsc/Startup/Startup.FileServer.cs +++ b/src/Yavsc/Startup/Startup.FileServer.cs @@ -42,7 +42,7 @@ namespace Yavsc static IAuthorizationService AuthorizationService { get; set; } public void ConfigureFileServerApp(IApplicationBuilder app, - SiteSettings siteSettings, Microsoft.AspNetCore.Hosting.IHostingEnvironment env, + SiteSettings siteSettings, IWebHostEnvironment env, IAuthorizationService authorizationService) { AuthorizationService = authorizationService; diff --git a/src/Yavsc/Startup/Startup.SanityChecks.cs b/src/Yavsc/Startup/Startup.SanityChecks.cs index 4e13572f..828c8bdd 100644 --- a/src/Yavsc/Startup/Startup.SanityChecks.cs +++ b/src/Yavsc/Startup/Startup.SanityChecks.cs @@ -9,7 +9,7 @@ namespace Yavsc public partial class Startup { - public void CheckApp(Microsoft.AspNetCore.Hosting.IHostingEnvironment env, + public void CheckApp(IWebHostEnvironment env, ILoggerFactory loggerFactory) { diff --git a/src/Yavsc/Startup/Startup.cs b/src/Yavsc/Startup/Startup.cs index 1da67699..32f04b53 100755 --- a/src/Yavsc/Startup/Startup.cs +++ b/src/Yavsc/Startup/Startup.cs @@ -89,6 +89,7 @@ namespace Yavsc // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { + services.AddSignalR(); // Database connection @@ -241,26 +242,21 @@ namespace Yavsc options.ResourcesPath = "Resources"; }); } - static ApplicationDbContext _dbContext; - private UserManager _usermanager; public static IServiceProvider Services { get; private set; } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure( - IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env, - ApplicationDbContext dbContext, IOptions siteSettings, - IOptions localizationOptions, + IApplicationBuilder app, + IOptions siteSettings, IAuthorizationService authorizationService, IOptions payPalSettings, IOptions googleSettings, IStringLocalizer localizer, - UserManager usermanager, - ILoggerFactory loggerFactory) + ILoggerFactory loggerFactory, + IWebHostEnvironment env) { Services = app.ApplicationServices; - _dbContext = dbContext; - _usermanager = usermanager; GoogleSettings = googleSettings.Value; ResourcesHelpers.GlobalLocalizer = localizer; SiteSetup = siteSettings.Value; @@ -319,7 +315,7 @@ namespace Yavsc // before fixing the security protocol, let beleive our lib it's done with it. var cxmgr = PayPal.Manager.ConnectionManager.Instance; // then, fix it. - ServicePointManager.SecurityProtocol = (SecurityProtocolType)0xC00; // Tls12, required by PayPal + // ServicePointManager.SecurityProtocol = (SecurityProtocolType)0xC00; // Tls12, required by PayPal app.UseSession(); @@ -335,35 +331,13 @@ namespace Yavsc _logger.LogInformation("LocalApplicationData: " + Environment.GetFolderPath(SpecialFolder.LocalApplicationData, SpecialFolderOption.DoNotVerify)); CheckApp(env, loggerFactory); - } - - // Entry point for the application. - public static void Main(string[] args) { - var builder = WebApplication.CreateBuilder(args); - builder.Services.AddSignalR(); - var app = builder.Build(); - - // Configure the HTTP request pipeline. - if (!app.Environment.IsDevelopment()) + app.UseEndpoints(endpoints => { - app.UseExceptionHandler("/Error"); - // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. - app.UseHsts(); - } - - app.UseHttpsRedirection(); - app.UseStaticFiles(); - - app.UseRouting(); - - app.UseAuthorization(); - - app.MapRazorPages(); - app.MapHub("/chatHub"); - - app.Run(); + endpoints.MapHub("/chat"); + }); } + } } // diff --git a/src/Yavsc/Yavsc.csproj b/src/Yavsc/Yavsc.csproj index 8dd06fac..50d958fd 100644 --- a/src/Yavsc/Yavsc.csproj +++ b/src/Yavsc/Yavsc.csproj @@ -16,6 +16,7 @@ +
- @:@@SR["Edit"] | - @:@@SR["Details"] | - @:@@SR["Delete"] + @:@Edit | + @:@Details | + @:@Delete @: - @@Html.ActionLink(SR["Edit"], "Edit",new { /* id=item.PrimaryKey */ }) | - @@Html.ActionLink(SR["Details"], "Details", new { /* id=item.PrimaryKey */ }) | - @@Html.ActionLink(SR["Delete"], "Delete", new { /* id=item.PrimaryKey */ }) + @@Html.ActionLink("Edit", "Edit",new { /* id=item.PrimaryKey */ }) | + @@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) | + @@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })