Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions DotnetToLambda.sln
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,6 @@ Global
{1EB6729D-9846-441F-9C09-5F7CD563C0CE}.Release|x64.Build.0 = Release|Any CPU
{1EB6729D-9846-441F-9C09-5F7CD563C0CE}.Release|x86.ActiveCfg = Release|Any CPU
{1EB6729D-9846-441F-9C09-5F7CD563C0CE}.Release|x86.Build.0 = Release|Any CPU
{9BEB806D-2444-40FD-8871-E13174E291B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9BEB806D-2444-40FD-8871-E13174E291B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9BEB806D-2444-40FD-8871-E13174E291B1}.Debug|x64.ActiveCfg = Debug|Any CPU
{9BEB806D-2444-40FD-8871-E13174E291B1}.Debug|x64.Build.0 = Debug|Any CPU
{9BEB806D-2444-40FD-8871-E13174E291B1}.Debug|x86.ActiveCfg = Debug|Any CPU
{9BEB806D-2444-40FD-8871-E13174E291B1}.Debug|x86.Build.0 = Debug|Any CPU
{9BEB806D-2444-40FD-8871-E13174E291B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9BEB806D-2444-40FD-8871-E13174E291B1}.Release|Any CPU.Build.0 = Release|Any CPU
{9BEB806D-2444-40FD-8871-E13174E291B1}.Release|x64.ActiveCfg = Release|Any CPU
{9BEB806D-2444-40FD-8871-E13174E291B1}.Release|x64.Build.0 = Release|Any CPU
{9BEB806D-2444-40FD-8871-E13174E291B1}.Release|x86.ActiveCfg = Release|Any CPU
{9BEB806D-2444-40FD-8871-E13174E291B1}.Release|x86.Build.0 = Release|Any CPU
{3630969D-0CBF-443D-9894-4DAC15B9D947}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3630969D-0CBF-443D-9894-4DAC15B9D947}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3630969D-0CBF-443D-9894-4DAC15B9D947}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -187,7 +175,6 @@ Global
{5B35C029-27CE-44ED-AFEF-A646F2CEC096} = {163A600C-DD7F-436D-A8B5-32F69D7041C5}
{43C59108-87C5-4F4B-81D8-481CDE6C2D6D} = {163A600C-DD7F-436D-A8B5-32F69D7041C5}
{1EB6729D-9846-441F-9C09-5F7CD563C0CE} = {163A600C-DD7F-436D-A8B5-32F69D7041C5}
{9BEB806D-2444-40FD-8871-E13174E291B1} = {12000098-E55C-49C0-B224-2027315833DB}
{3630969D-0CBF-443D-9894-4DAC15B9D947} = {163A600C-DD7F-436D-A8B5-32F69D7041C5}
{B4F8269C-8734-4F4D-8D17-E933EC07A054} = {6A524563-A123-4814-85AD-BD64EBA01BDF}
EndGlobalSection
Expand Down
7 changes: 7 additions & 0 deletions NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Use root/example as user/password credentials
version: '3.1'

services:
db:
image: mysql
Expand All @@ -9,4 +7,4 @@ services:
environment:
MYSQL_ROOT_PASSWORD: example
ports:
- "3306:3306"
- "3306:3306"
5 changes: 3 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"sdk": {
"version": "3.1.416"
"version": "10.0.100",
"rollForward": "latestMinor"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\DotnetToLambda.Core\DotnetToLambda.Core.csproj" />
</ItemGroup>


</Project>
60 changes: 36 additions & 24 deletions src/DotnetToLambda.Api/DotnetToLambda.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace DotnetToLambda.Api
using DotnetToLambda.Core.Models;
using DotnetToLambda.Core.Infrastructure;
using DotnetToLambda.Core.Services;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

var databaseConnection =
new DatabaseConnection(builder.Configuration.GetConnectionString("DatabaseConnection")!);

builder.Services.AddSingleton(databaseConnection);

builder.Services.AddDbContext<BookingContext>(options =>
options.UseMySQL(databaseConnection.ToString()));

builder.Services.AddTransient<IBookingRepository, BookingRepository>();
builder.Services.AddHttpClient<ICustomerService, CustomerService>();

builder.Services.AddControllers();

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

using (var scope = app.Services.CreateScope())
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
var context = scope.ServiceProvider.GetRequiredService<BookingContext>();
context.Database.Migrate();
}

app.UseRouting();
app.UseAuthorization();
app.MapControllers();

app.Run();
63 changes: 0 additions & 63 deletions src/DotnetToLambda.Api/DotnetToLambda.Api/Startup.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.22" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.22" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.22" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.22">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MySql.EntityFrameworkCore" Version="3.1.19" />
<PackageReference Include="System.Text.Json" Version="6.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MySql.EntityFrameworkCore" Version="10.0.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
using DotnetToLambda.Core.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;

namespace DotnetToLambda.Core.Infrastructure
namespace DotnetToLambda.Core.Infrastructure;

public class BookingContext : DbContext
{
public class BookingContext : DbContext
private readonly DatabaseConnection _connection;

public BookingContext(DatabaseConnection connection)
{
private readonly DatabaseConnection _connection;
_connection = connection;
}

public BookingContext(DatabaseConnection connection)
{
this._connection = connection;
}

public DbSet<Booking> Bookings { get; set; }
public DbSet<Booking> Bookings { get; set; } = null!;

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseMySQL(this._connection.ToString());
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseMySQL(_connection.ToString());
}

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Booking>().ToTable("Bookings");
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Booking>().ToTable("Bookings");

modelBuilder.Entity<Booking>()
.HasKey(b => b.BookingId).HasName("PK_BookingId");
modelBuilder.Entity<Booking>()
.HasIndex(b => b.CustomerId)
.HasName("UX_Booking_CustomerId");
}
modelBuilder.Entity<Booking>()
.HasKey(b => b.BookingId).HasName("PK_BookingId");
modelBuilder.Entity<Booking>()
.HasIndex(b => b.CustomerId)
.HasDatabaseName("UX_Booking_CustomerId");
}
}
}
10 changes: 5 additions & 5 deletions src/infrastructure/src/Infrastructure/Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<!-- Roll forward to future major versions of the netcoreapp as needed -->
<RollForward>Major</RollForward>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<!-- CDK Construct Library dependencies -->
<PackageReference Include="Amazon.CDK.Lib" Version="2.10.0" />
<PackageReference Include="Constructs" Version="[10.0.0,11.0.0)" />
<PackageReference Include="Amazon.CDK.Lib" Version="2.250.0" />
<PackageReference Include="Constructs" Version="[10.5.0,11.0.0)" />

<!-- jsii Roslyn analyzers (un-comment to obtain compile-time checks for missing required props
<PackageReference Include="Amazon.Jsii.Analyzers" Version="*" PrivateAssets="all" />
Expand Down
Loading