Compare commits
50 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
4a86cb563d | |
|
|
cb9425b627 | |
|
|
b5fa0e62f9 | |
|
|
6ebb32306f | |
|
|
c51bdf1221 | |
|
|
e40fe7e37f | |
|
|
2f7e600372 | |
|
|
1123dd83bc | |
|
|
17d56d3435 | |
|
|
81ae8fa297 | |
|
|
b31fd4c945 | |
|
|
db35563e6f | |
|
|
9693fb92d5 | |
|
|
3c86ac190c | |
|
|
8c04849be2 | |
|
|
d0ad5fa52c | |
|
|
cdba94de2b | |
|
|
9e781af82b | |
|
|
ef6c38189b | |
|
|
5c56db2625 | |
|
|
e9c12acfbe | |
|
|
b958d04bc5 | |
|
|
d10d402779 | |
|
|
590cae684d | |
|
|
28c07b3afe | |
|
|
29b15d38c7 | |
|
|
b8de599a11 | |
|
|
463e38cbaf | |
|
|
56310a4d99 | |
|
|
ea77183b7a | |
|
|
eb481285b5 | |
|
|
4eeda7392e | |
|
|
befb1111ac | |
|
|
b434524dd0 | |
|
|
b51eb5c962 | |
|
|
510378e0e5 | |
|
|
f377ee6c98 | |
|
|
5a4a08b16e | |
|
|
f175611a2c | |
|
|
4aa8be56b1 | |
|
|
358c816300 | |
|
|
302c1366a1 | |
|
|
fbd56d4e33 | |
|
|
1d47da55c7 | |
|
|
b8f77ecdf2 | |
|
|
fef20cbfc9 | |
|
|
d517d883a8 | |
|
|
ad9687083b | |
|
|
75c2e530e0 | |
|
|
0fadf3bc21 |
|
|
@ -0,0 +1,2 @@
|
||||||
|
bin/
|
||||||
|
obj/
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"dotnet.defaultSolution": "OFBButte.sln"
|
||||||
|
}
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using OFBButte.Application.Configuration;
|
|
||||||
using OFBButte.Application.Database;
|
|
||||||
using OFBButte.Application.Email;
|
|
||||||
using OFBButte.Application.Missionary;
|
|
||||||
using OFBButte.Entities;
|
|
||||||
|
|
||||||
namespace OFBButte.Api.Controllers
|
|
||||||
{
|
|
||||||
[Route("api/[controller]")]
|
|
||||||
[ApiController]
|
|
||||||
public class MissionaryController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly AppSettings appSettings;
|
|
||||||
private readonly IOFBContext context;
|
|
||||||
private readonly IEmailSender emailSender;
|
|
||||||
public MissionaryController(IOptions<AppSettings> options, IOFBContext context, IEmailSender emailSender)
|
|
||||||
{
|
|
||||||
this.appSettings = options.Value;
|
|
||||||
this.context = context;
|
|
||||||
this.emailSender = emailSender;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost]
|
|
||||||
public async Task<ActionResult<MissionarySupport>> Post([FromBody] MissionarySupport value)
|
|
||||||
{
|
|
||||||
var adder = new AddAndSendMissionaryForm(context, emailSender);
|
|
||||||
var result = await adder.Handle(value, appSettings.MissionaryEmailAddress);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("{id}")]
|
|
||||||
public ActionResult<MissionarySupport> Get(int id)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
var getter = new GetMissionarySupportForm(context);
|
|
||||||
var result = getter.Handle(id);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using OFBButte.Application.Configuration;
|
|
||||||
|
|
||||||
namespace OFBButte.Api.Controllers
|
|
||||||
{
|
|
||||||
[Route("api/[controller]")]
|
|
||||||
[ApiController]
|
|
||||||
public class ValuesController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly AppSettings appSettings;
|
|
||||||
public ValuesController(IOptions<AppSettings> options)
|
|
||||||
{
|
|
||||||
this.appSettings = options.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET api/values
|
|
||||||
[HttpGet]
|
|
||||||
public ActionResult<IEnumerable<string>> Get()
|
|
||||||
{
|
|
||||||
return new string[] { "value1 updated", "value2", appSettings.Environment };
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET api/values/5
|
|
||||||
[HttpGet("{id}")]
|
|
||||||
public ActionResult<string> Get(int id)
|
|
||||||
{
|
|
||||||
return "value";
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST api/values
|
|
||||||
[HttpPost]
|
|
||||||
public void Post([FromBody] string value)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// PUT api/values/5
|
|
||||||
[HttpPut("{id}")]
|
|
||||||
public void Put(int id, [FromBody] string value)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// DELETE api/values/5
|
|
||||||
[HttpDelete("{id}")]
|
|
||||||
public void Delete(int id)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
|
||||||
|
public class JsonStringBooleanConverter : JsonConverter<bool>
|
||||||
|
{
|
||||||
|
public override bool Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||||
|
{
|
||||||
|
var val = reader.GetString();
|
||||||
|
if (val == "true")
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (val == "false")
|
||||||
|
return false;
|
||||||
|
|
||||||
|
throw new Exception($"Cannot convert {val} to boolean");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOptions options)
|
||||||
|
{
|
||||||
|
writer.WriteBooleanValue(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using OFBButte.Application.Configuration;
|
||||||
|
using OFBButte.Application.Database;
|
||||||
|
using OFBButte.Application.Email;
|
||||||
|
using OFBButte.Application.Missionary;
|
||||||
|
using OFBButte.Entities;
|
||||||
|
|
||||||
|
public static class MissionaryRoutes
|
||||||
|
{
|
||||||
|
public static WebApplication MapMissionaryRoutes(this WebApplication app)
|
||||||
|
{
|
||||||
|
app.MapGet("/missionary/{id}", GetMissionarySupport);
|
||||||
|
app.MapPost("/missionary", PostMissionarySupport);
|
||||||
|
return app;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MissionarySupport GetMissionarySupport(int id)
|
||||||
|
{
|
||||||
|
return new MissionarySupport(){
|
||||||
|
Id = id
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<MissionarySupport> PostMissionarySupport([FromBody] MissionarySupport value, AppSettings appSettings, IOFBContext context, IEmailSender emailSender)
|
||||||
|
{
|
||||||
|
var adder = new AddAndSendMissionaryForm(context, emailSender);
|
||||||
|
var result = await adder.Handle(value, appSettings.MissionaryEmailAddress);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
@ -15,12 +16,6 @@
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
|
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OFBButte.Application\OFBButte.Application.csproj" />
|
<ProjectReference Include="..\OFBButte.Application\OFBButte.Application.csproj" />
|
||||||
<ProjectReference Include="..\OFBButte.Database\OFBButte.Database.csproj" />
|
<ProjectReference Include="..\OFBButte.Database\OFBButte.Database.csproj" />
|
||||||
|
|
|
||||||
|
|
@ -1,54 +1,56 @@
|
||||||
using System;
|
using System.Text.Json.Serialization;
|
||||||
using System.Collections.Generic;
|
using Microsoft.AspNetCore.Cors.Infrastructure;
|
||||||
using System.IO;
|
using Microsoft.Extensions.Options;
|
||||||
using System.Linq;
|
using OFBButte.Application.Configuration;
|
||||||
using System.Threading.Tasks;
|
using OFBButte.Application.Database;
|
||||||
using Microsoft.AspNetCore;
|
using OFBButte.Application.Email;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using OFBButte.Database;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using OFBButte.Infrastructure.Email;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace OFBButte.Api
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
string CorsPolicy = "OFBCorsPolicy";
|
||||||
|
|
||||||
|
builder.Services.AddCors(options =>
|
||||||
{
|
{
|
||||||
public class Program
|
options.AddPolicy(CorsPolicy, policy =>
|
||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
policy.WithOrigins("http://localhost:4200", "https://test.ofbbutte.com", "https://ofbbutte.com")
|
||||||
{
|
.AllowAnyHeader()
|
||||||
CreateWebHostBuilder(args, false).Run();
|
.AllowAnyMethod()
|
||||||
}
|
.AllowCredentials();
|
||||||
/// <summary>
|
});
|
||||||
/// This method is for entity framework
|
});
|
||||||
/// </summary>
|
|
||||||
/// <param name="args"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static IWebHost BuildWebHost(string[] args)
|
|
||||||
{
|
|
||||||
return CreateWebHostBuilder(args, true);
|
|
||||||
}
|
|
||||||
public static IWebHost CreateWebHostBuilder(string[] args, bool fromEF)
|
|
||||||
{
|
|
||||||
var hostBuilder = WebHost.CreateDefaultBuilder(args)
|
|
||||||
.UseStartup<Startup>();
|
|
||||||
|
|
||||||
if (args.Length >= 1)
|
builder.Services.ConfigureHttpJsonOptions(options => {
|
||||||
{
|
options.SerializerOptions.Converters.Add(new JsonStringEnumConverter());
|
||||||
hostBuilder.UseUrls($"http://localhost:{args[0]}");
|
options.SerializerOptions.Converters.Add(new JsonStringBooleanConverter());
|
||||||
}
|
});
|
||||||
|
|
||||||
var host = hostBuilder.Build();
|
// App Settings
|
||||||
|
var appSettings = builder.Configuration.GetSection("App").Get<AppSettings>();
|
||||||
|
builder.Services.AddSingleton(appSettings);
|
||||||
|
|
||||||
if (fromEF)
|
// DB Context
|
||||||
return host;
|
builder.Services.AddDbContext<OFBContext>(o =>
|
||||||
|
{
|
||||||
|
OFBContext.UseMySql(o, builder.Configuration.GetConnectionString("OFBContext"));
|
||||||
|
});
|
||||||
|
builder.Services.AddScoped<IOFBContext, OFBContext>(s => s.GetService<OFBContext>());
|
||||||
|
|
||||||
using (var scope = host.Services.CreateScope())
|
// Email Service
|
||||||
{
|
builder.Services.AddScoped<IEmailSender, EmailSender>(s =>
|
||||||
var db = scope.ServiceProvider.GetService<Database.OFBContext>();
|
{
|
||||||
db.Database.Migrate();
|
return new EmailSender(appSettings.Environment != "Prod");
|
||||||
}
|
});
|
||||||
|
|
||||||
return host;
|
var app = builder.Build();
|
||||||
}
|
|
||||||
}
|
app.UseCors(CorsPolicy);
|
||||||
}
|
|
||||||
|
app.MapGet("/", () => $"OFB API - {app.Environment.EnvironmentName} - {appSettings.Environment}");
|
||||||
|
|
||||||
|
app.MapMissionaryRoutes();
|
||||||
|
|
||||||
|
|
||||||
|
app.Run();
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,37 @@
|
||||||
{
|
{
|
||||||
"iisSettings": {
|
"iisSettings": {
|
||||||
"windowsAuthentication": false,
|
"windowsAuthentication": false,
|
||||||
"anonymousAuthentication": true,
|
"anonymousAuthentication": true,
|
||||||
"iisExpress": {
|
"iisExpress": {
|
||||||
"applicationUrl": "http://localhost:50405",
|
"applicationUrl": "http://localhost:49131",
|
||||||
"sslPort": 44314
|
"sslPort": 44314
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"IIS Express": {
|
"http": {
|
||||||
"commandName": "IISExpress",
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "api/values",
|
"applicationUrl": "http://localhost:5030",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"OFBButte.Api": {
|
"https": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "api/values",
|
"applicationUrl": "https://localhost:7214;http://localhost:5030",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
},
|
}
|
||||||
"applicationUrl": "https://localhost:5001;http://localhost:5000"
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,84 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.AspNetCore.HttpsPolicy;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using OFBButte.Application.Configuration;
|
|
||||||
using OFBButte.Application.Database;
|
|
||||||
using OFBButte.Application.Email;
|
|
||||||
using OFBButte.Database;
|
|
||||||
using OFBButte.Infrastructure.Email;
|
|
||||||
|
|
||||||
namespace OFBButte.Api
|
|
||||||
{
|
|
||||||
public class Startup
|
|
||||||
{
|
|
||||||
private readonly string CorsPolicy = "OFBCorsPolicy";
|
|
||||||
|
|
||||||
public Startup(IConfiguration configuration)
|
|
||||||
{
|
|
||||||
Configuration = configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IConfiguration Configuration { get; }
|
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to add services to the container.
|
|
||||||
public void ConfigureServices(IServiceCollection services)
|
|
||||||
{
|
|
||||||
// CORS - This needs to be before services.AddMvc
|
|
||||||
services.AddCors(options =>
|
|
||||||
{
|
|
||||||
options.AddPolicy(CorsPolicy, policy =>
|
|
||||||
{
|
|
||||||
policy.WithOrigins("http://localhost:4200", "https://test.ofbbutte.com", "https://ofbbutte.com")
|
|
||||||
.AllowAnyHeader()
|
|
||||||
.AllowAnyMethod()
|
|
||||||
.AllowCredentials();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
|
|
||||||
|
|
||||||
// App Settings
|
|
||||||
services.Configure<AppSettings>(Configuration.GetSection("App"));
|
|
||||||
|
|
||||||
// DB Context
|
|
||||||
services.AddDbContext<OFBContext>(o =>
|
|
||||||
{
|
|
||||||
OFBContext.UseMySql(o, Configuration.GetConnectionString("OFBContext"));
|
|
||||||
});
|
|
||||||
services.AddScoped<IOFBContext, OFBContext>(s => s.GetService<OFBContext>());
|
|
||||||
|
|
||||||
// Email Service
|
|
||||||
services.AddScoped<IEmailSender, EmailSender>(s =>
|
|
||||||
{
|
|
||||||
var options = s.GetService<IOptions<AppSettings>>();
|
|
||||||
return new EmailSender(options.Value.Environment != "Prod");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
|
||||||
{
|
|
||||||
if (env.IsDevelopment())
|
|
||||||
{
|
|
||||||
app.UseDeveloperExceptionPage();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// 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.UseCors(CorsPolicy);
|
|
||||||
app.UseHttpsRedirection();
|
|
||||||
app.UseMvc();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
{
|
{
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Debug",
|
"Default": "Information",
|
||||||
"System": "Information",
|
"Microsoft.AspNetCore": "Warning"
|
||||||
"Microsoft": "Information"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"App": {
|
"App": {
|
||||||
|
|
@ -11,6 +10,6 @@
|
||||||
"MissionaryEmailAddress": "admin@oldfashionbaptistbutte.com"
|
"MissionaryEmailAddress": "admin@oldfashionbaptistbutte.com"
|
||||||
},
|
},
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"OFBContext": "server=localhost;database=ofb2_test;user=ofbapi2_test;password=Look to the LORD and his strength seek his face always"
|
"OFBContext": "server=localhost;database=ofb_missionary;user=admin_ofbbutte;password=87hjdusiodksyeunsjkdis7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
{
|
{
|
||||||
"App": {
|
"App": {
|
||||||
"Environment": "Prod",
|
"Environment": "Prod",
|
||||||
"MissionaryEmailAddress": "contact@oldfashionbaptistbutte.com"
|
"MissionaryEmailAddress": "mail@ofbbutte.com"
|
||||||
},
|
},
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"OFBContext": "server=localhost;database=ofb2;user=ofbapi2;password={{db_pass}};"
|
"OFBContext": "server=localhost;database=admin_ofb_missionary;user=admin_ofbbutte;password={{dbpass}};"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
@ -2,8 +2,7 @@
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
"Microsoft": "Warning",
|
"Microsoft.AspNetCore": "Warning"
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.9" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.9" />
|
||||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
|
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ namespace OFBButte.Database
|
||||||
|
|
||||||
public static void UseMySql(DbContextOptionsBuilder optionsBuilder, string connString)
|
public static void UseMySql(DbContextOptionsBuilder optionsBuilder, string connString)
|
||||||
{
|
{
|
||||||
optionsBuilder.UseMySql(connString);
|
optionsBuilder.UseMySql(connString, ServerVersion.AutoDetect(connString));
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbSet<User> Users { get; set; }
|
public DbSet<User> Users { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -23,15 +23,15 @@ namespace OFBButte.Infrastructure.Email
|
||||||
{
|
{
|
||||||
message.SetBodyFromTemplate(isTest);
|
message.SetBodyFromTemplate(isTest);
|
||||||
var mm = new MimeMessage();
|
var mm = new MimeMessage();
|
||||||
mm.From.Add(new MailboxAddress(message.From));
|
mm.From.Add(new MailboxAddress(message.From, message.From));
|
||||||
mm.To.Add(new MailboxAddress(message.To));
|
mm.To.Add(new MailboxAddress(message.To, message.To));
|
||||||
mm.Subject = message.Subject;
|
mm.Subject = message.Subject;
|
||||||
var bodyBuilder = new BodyBuilder();
|
var bodyBuilder = new BodyBuilder();
|
||||||
bodyBuilder.HtmlBody = message.Body;
|
bodyBuilder.HtmlBody = message.Body;
|
||||||
mm.Body = bodyBuilder.ToMessageBody();
|
mm.Body = bodyBuilder.ToMessageBody();
|
||||||
|
|
||||||
client.Connect("smtp.webfaction.com", 465, true);
|
client.Connect("smtp.ionos.com", 587, false);
|
||||||
client.Authenticate("ofbcontact", "2014OfbPwd");
|
client.Authenticate("mail@ofbbutte.com", "@2014OfbPwd");
|
||||||
await client.SendAsync(mm);
|
await client.SendAsync(mm);
|
||||||
client.Disconnect(true);
|
client.Disconnect(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MailKit" Version="2.2.0" />
|
<PackageReference Include="MailKit" Version="4.1.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="7.0.9" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
62
OFBButte.sln
62
OFBButte.sln
|
|
@ -1,19 +1,17 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 16
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 16.0.29102.190
|
VisualStudioVersion = 17.5.002.0
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OFBButte.Api", "OFBButte.Api\OFBButte.Api.csproj", "{FF5F4D78-6419-47E4-A7CE-5B25503BE2D7}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OFBButte.Api", "OFBButte.Api\OFBButte.Api.csproj", "{57949138-1831-4BEB-B89A-66C5034CCFF5}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OFBButte.Application", "OFBButte.Application\OFBButte.Application.csproj", "{8BCA31C6-C10D-4865-BAE8-6DC932B4797D}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OFBButte.Application", "OFBButte.Application\OFBButte.Application.csproj", "{86647588-E6F1-4D24-98FB-F98ED02BF3CB}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OFBButte.Console", "OFBButte.Console\OFBButte.Console.csproj", "{82FA36EC-1CBC-4F9A-B436-A61D9AA6D1C7}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OFBButte.Database", "OFBButte.Database\OFBButte.Database.csproj", "{4BE1B263-6D9F-4ACC-8FA9-1AA2165BCCB3}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OFBButte.Database", "OFBButte.Database\OFBButte.Database.csproj", "{64A05F44-4BB2-45CE-A343-6307EA8F099A}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OFBButte.Entities", "OFBButte.Entities\OFBButte.Entities.csproj", "{9FF67157-2D1C-4B6C-9C9C-90067875E931}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OFBButte.Infrastructure", "OFBButte.Infrastructure\OFBButte.Infrastructure.csproj", "{157A1CB3-9320-4FE6-ABC5-1C9EF1952540}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OFBButte.Infrastructure", "OFBButte.Infrastructure\OFBButte.Infrastructure.csproj", "{E7B66D8A-3431-4FD3-84A5-8037A2A5404C}"
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OFBButte.Entities", "OFBButte.Entities\OFBButte.Entities.csproj", "{39A5BAF9-E108-4B81-8DBB-A7C1A6CEA9EF}"
|
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|
@ -21,35 +19,31 @@ Global
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{FF5F4D78-6419-47E4-A7CE-5B25503BE2D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{57949138-1831-4BEB-B89A-66C5034CCFF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{FF5F4D78-6419-47E4-A7CE-5B25503BE2D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{57949138-1831-4BEB-B89A-66C5034CCFF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{FF5F4D78-6419-47E4-A7CE-5B25503BE2D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{57949138-1831-4BEB-B89A-66C5034CCFF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{FF5F4D78-6419-47E4-A7CE-5B25503BE2D7}.Release|Any CPU.Build.0 = Release|Any CPU
|
{57949138-1831-4BEB-B89A-66C5034CCFF5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{8BCA31C6-C10D-4865-BAE8-6DC932B4797D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{86647588-E6F1-4D24-98FB-F98ED02BF3CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{8BCA31C6-C10D-4865-BAE8-6DC932B4797D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{86647588-E6F1-4D24-98FB-F98ED02BF3CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{8BCA31C6-C10D-4865-BAE8-6DC932B4797D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{86647588-E6F1-4D24-98FB-F98ED02BF3CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{8BCA31C6-C10D-4865-BAE8-6DC932B4797D}.Release|Any CPU.Build.0 = Release|Any CPU
|
{86647588-E6F1-4D24-98FB-F98ED02BF3CB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{82FA36EC-1CBC-4F9A-B436-A61D9AA6D1C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{4BE1B263-6D9F-4ACC-8FA9-1AA2165BCCB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{82FA36EC-1CBC-4F9A-B436-A61D9AA6D1C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{4BE1B263-6D9F-4ACC-8FA9-1AA2165BCCB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{82FA36EC-1CBC-4F9A-B436-A61D9AA6D1C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{4BE1B263-6D9F-4ACC-8FA9-1AA2165BCCB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{82FA36EC-1CBC-4F9A-B436-A61D9AA6D1C7}.Release|Any CPU.Build.0 = Release|Any CPU
|
{4BE1B263-6D9F-4ACC-8FA9-1AA2165BCCB3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{64A05F44-4BB2-45CE-A343-6307EA8F099A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{9FF67157-2D1C-4B6C-9C9C-90067875E931}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{64A05F44-4BB2-45CE-A343-6307EA8F099A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{9FF67157-2D1C-4B6C-9C9C-90067875E931}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{64A05F44-4BB2-45CE-A343-6307EA8F099A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{9FF67157-2D1C-4B6C-9C9C-90067875E931}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{64A05F44-4BB2-45CE-A343-6307EA8F099A}.Release|Any CPU.Build.0 = Release|Any CPU
|
{9FF67157-2D1C-4B6C-9C9C-90067875E931}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{157A1CB3-9320-4FE6-ABC5-1C9EF1952540}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{E7B66D8A-3431-4FD3-84A5-8037A2A5404C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{157A1CB3-9320-4FE6-ABC5-1C9EF1952540}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{E7B66D8A-3431-4FD3-84A5-8037A2A5404C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{157A1CB3-9320-4FE6-ABC5-1C9EF1952540}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{E7B66D8A-3431-4FD3-84A5-8037A2A5404C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{157A1CB3-9320-4FE6-ABC5-1C9EF1952540}.Release|Any CPU.Build.0 = Release|Any CPU
|
{E7B66D8A-3431-4FD3-84A5-8037A2A5404C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{39A5BAF9-E108-4B81-8DBB-A7C1A6CEA9EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{39A5BAF9-E108-4B81-8DBB-A7C1A6CEA9EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{39A5BAF9-E108-4B81-8DBB-A7C1A6CEA9EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{39A5BAF9-E108-4B81-8DBB-A7C1A6CEA9EF}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {CD719D07-AABB-44D8-84CD-705EDF224EB9}
|
SolutionGuid = {CFE73C56-C2A6-4CC4-8F7A-2AC6843F160C}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# API Restore
|
||||||
|
WORKDIR /app/OFBButte.Api
|
||||||
|
COPY OFBButte.Api/*.csproj ./
|
||||||
|
RUN dotnet restore
|
||||||
|
|
||||||
|
# Application Restore
|
||||||
|
WORKDIR /app/OFBButte.Application
|
||||||
|
COPY OFBButte.Application/*.csproj ./
|
||||||
|
RUN dotnet restore
|
||||||
|
|
||||||
|
# Database Restore
|
||||||
|
WORKDIR /app/OFBButte.Database
|
||||||
|
COPY OFBButte.Database/*.csproj ./
|
||||||
|
RUN dotnet restore
|
||||||
|
|
||||||
|
# Entities Restore
|
||||||
|
WORKDIR /app/OFBButte.Entities
|
||||||
|
COPY OFBButte.Entities/*.csproj ./
|
||||||
|
RUN dotnet restore
|
||||||
|
|
||||||
|
# Infrastructure Restore
|
||||||
|
WORKDIR /app/OFBButte.Infrastructure
|
||||||
|
COPY OFBButte.Infrastructure/*.csproj ./
|
||||||
|
RUN dotnet restore
|
||||||
|
|
||||||
|
|
||||||
|
# Copy everything else and build
|
||||||
|
WORKDIR /app
|
||||||
|
COPY . ./
|
||||||
|
WORKDIR /app/OFBButte.Api
|
||||||
|
RUN dotnet publish -c Release -o out
|
||||||
|
|
||||||
|
# Build runtime image
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:7.0
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=build-env /app/OFBButte.Api/out .
|
||||||
|
ENTRYPOINT ["dotnet", "OFBButte.Api.dll"]
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: build-deploy
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: docker
|
||||||
|
volumes:
|
||||||
|
- name: docker_sock
|
||||||
|
path: /var/run/docker.sock
|
||||||
|
commands:
|
||||||
|
- docker build --tag ofb_api .
|
||||||
|
|
||||||
|
- name: deploy_test
|
||||||
|
image: docker
|
||||||
|
volumes:
|
||||||
|
- name: docker_sock
|
||||||
|
path: /var/run/docker.sock
|
||||||
|
commands:
|
||||||
|
- docker rm -f ofb_api_test || true
|
||||||
|
- docker run --name ofb_api_test --network=proxy --restart always -d -e ASPNETCORE_ENVIRONMENT="Development" -e ConnectionStrings__OFBContext="server=mysql;database=ofb_missionary;user=admin_ofbbutte;password=87hjdusiodksyeunsjkdis7;" ofb_api
|
||||||
|
- docker network connect mysql ofb_api_test
|
||||||
|
|
||||||
|
- name: deploy_prod
|
||||||
|
image: docker
|
||||||
|
volumes:
|
||||||
|
- name: docker_sock
|
||||||
|
path: /var/run/docker.sock
|
||||||
|
commands:
|
||||||
|
- docker rm -f ofb_api || true
|
||||||
|
- docker run --name ofb_api --network=proxy --restart always -d -e ASPNETCORE_ENVIRONMENT="Production" -e ConnectionStrings__OFBContext="server=mysql;database=ofb_missionary;user=admin_ofbbutte;password=87hjdusiodksyeunsjkdis7;" ofb_api
|
||||||
|
- docker network connect mysql ofb_api
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- promote
|
||||||
|
target:
|
||||||
|
- production
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- name: docker_sock
|
||||||
|
host:
|
||||||
|
path: /var/run/docker.sock
|
||||||
Loading…
Reference in New Issue