Skip to content
This repository was archived by the owner on Jul 10, 2024. It is now read-only.

Commit d6191e3

Browse files
davidfowlDamianEdwards
authored andcommitted
Added the first snapshot
1 parent 71be83e commit d6191e3

File tree

11 files changed

+73
-96
lines changed

11 files changed

+73
-96
lines changed
Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.2</TargetFramework>
5-
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
4+
<TargetFramework>netcoreapp3.0</TargetFramework>
65
</PropertyGroup>
76

87
<ItemGroup>
9-
<PackageReference Include="Microsoft.AspNetCore.App" />
10-
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
11-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.1" />
12-
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" />
13-
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
8+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview6.19304.10" />
9+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.0.0-preview6.19304.10" />
10+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0-preview6.19304.10">
11+
<PrivateAssets>all</PrivateAssets>
12+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
13+
</PackageReference>
14+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0-preview5-19264-04">
15+
<PrivateAssets>all</PrivateAssets>
16+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
17+
</PackageReference>
18+
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc2" />
1419
</ItemGroup>
1520

1621
</Project>

save-points/1-Create-API-and-EF-Model/ConferencePlanner/BackEnd/Controllers/SpeakersController.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32
using System.Linq;
43
using System.Threading.Tasks;
5-
using Microsoft.AspNetCore.Http;
64
using Microsoft.AspNetCore.Mvc;
75
using Microsoft.EntityFrameworkCore;
86
using BackEnd.Models;
@@ -45,7 +43,7 @@ public async Task<ActionResult<Speaker>> GetSpeaker(int id)
4543
[HttpPut("{id}")]
4644
public async Task<IActionResult> PutSpeaker(int id, Speaker speaker)
4745
{
48-
if (id != speaker.ID)
46+
if (id != speaker.Id)
4947
{
5048
return BadRequest();
5149
}
@@ -78,7 +76,7 @@ public async Task<ActionResult<Speaker>> PostSpeaker(Speaker speaker)
7876
_context.Speakers.Add(speaker);
7977
await _context.SaveChangesAsync();
8078

81-
return CreatedAtAction("GetSpeaker", new { id = speaker.ID }, speaker);
79+
return CreatedAtAction("GetSpeaker", new { id = speaker.Id }, speaker);
8280
}
8381

8482
// DELETE: api/Speakers/5
@@ -99,7 +97,7 @@ public async Task<ActionResult<Speaker>> DeleteSpeaker(int id)
9997

10098
private bool SpeakerExists(int id)
10199
{
102-
return _context.Speakers.Any(e => e.ID == id);
100+
return _context.Speakers.Any(e => e.Id == id);
103101
}
104102
}
105103
}
Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ protected override void Up(MigrationBuilder migrationBuilder)
1111
name: "Speakers",
1212
columns: table => new
1313
{
14-
ID = table.Column<int>(nullable: false)
14+
Id = table.Column<int>(nullable: false)
1515
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
1616
Name = table.Column<string>(maxLength: 200, nullable: false),
1717
Bio = table.Column<string>(maxLength: 4000, nullable: true),
1818
WebSite = table.Column<string>(maxLength: 1000, nullable: true)
1919
},
2020
constraints: table =>
2121
{
22-
table.PrimaryKey("PK_Speakers", x => x.ID);
22+
table.PrimaryKey("PK_Speakers", x => x.Id);
2323
});
2424
}
2525

save-points/1-Create-API-and-EF-Model/ConferencePlanner/BackEnd/Migrations/ApplicationDbContextModelSnapshot.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ protected override void BuildModel(ModelBuilder modelBuilder)
1414
{
1515
#pragma warning disable 612, 618
1616
modelBuilder
17-
.HasAnnotation("ProductVersion", "2.2.1-servicing-10028")
17+
.HasAnnotation("ProductVersion", "3.0.0-preview6.19304.10")
1818
.HasAnnotation("Relational:MaxIdentifierLength", 128)
1919
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
2020

2121
modelBuilder.Entity("BackEnd.Models.Speaker", b =>
2222
{
23-
b.Property<int>("ID")
23+
b.Property<int>("Id")
2424
.ValueGeneratedOnAdd()
2525
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
2626

@@ -34,7 +34,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
3434
b.Property<string>("WebSite")
3535
.HasMaxLength(1000);
3636

37-
b.HasKey("ID");
37+
b.HasKey("Id");
3838

3939
b.ToTable("Speakers");
4040
});

save-points/1-Create-API-and-EF-Model/ConferencePlanner/BackEnd/Models/Speaker.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
using System.ComponentModel.DataAnnotations;
44
using System.Linq;
55
using System.Threading.Tasks;
6-
using Microsoft.Extensions.DependencyInjection;
7-
using Microsoft.EntityFrameworkCore.Design;
86

97
namespace BackEnd.Models
108
{
119
public class Speaker
1210
{
13-
public int ID { get; set; }
11+
public int Id { get; set; }
1412

1513
[Required]
1614
[StringLength(200)]
@@ -22,4 +20,4 @@ public class Speaker
2220
[StringLength(1000)]
2321
public virtual string WebSite { get; set; }
2422
}
25-
}
23+
}
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
3-
using System.IO;
43
using System.Linq;
54
using System.Threading.Tasks;
6-
using Microsoft.AspNetCore;
75
using Microsoft.AspNetCore.Hosting;
86
using Microsoft.Extensions.Configuration;
7+
using Microsoft.Extensions.Hosting;
98
using Microsoft.Extensions.Logging;
109

1110
namespace BackEnd
@@ -14,11 +13,14 @@ public class Program
1413
{
1514
public static void Main(string[] args)
1615
{
17-
CreateWebHostBuilder(args).Build().Run();
16+
CreateHostBuilder(args).Build().Run();
1817
}
1918

20-
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
21-
WebHost.CreateDefaultBuilder(args)
22-
.UseStartup<Startup>();
19+
public static IHostBuilder CreateHostBuilder(string[] args) =>
20+
Host.CreateDefaultBuilder(args)
21+
.ConfigureWebHostDefaults(webBuilder =>
22+
{
23+
webBuilder.UseStartup<Startup>();
24+
});
2325
}
2426
}

save-points/1-Create-API-and-EF-Model/ConferencePlanner/BackEnd/Properties/launchSettings.json

Lines changed: 0 additions & 30 deletions
This file was deleted.

save-points/1-Create-API-and-EF-Model/ConferencePlanner/BackEnd/Startup.cs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Runtime.InteropServices;
@@ -11,9 +11,9 @@
1111
using Microsoft.EntityFrameworkCore;
1212
using Microsoft.Extensions.Configuration;
1313
using Microsoft.Extensions.DependencyInjection;
14+
using Microsoft.Extensions.Hosting;
1415
using Microsoft.Extensions.Logging;
15-
using Microsoft.Extensions.Options;
16-
using Swashbuckle.AspNetCore.Swagger;
16+
using Microsoft.OpenApi.Models;
1717

1818
namespace BackEnd
1919
{
@@ -41,34 +41,36 @@ public void ConfigureServices(IServiceCollection services)
4141
}
4242
});
4343

44-
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
44+
services.AddControllers();
4545

4646
services.AddSwaggerGen(options =>
47-
options.SwaggerDoc("v1", new Info { Title = "Conference Planner API", Version = "v1" })
48-
);
47+
options.SwaggerDoc("v1", new OpenApiInfo { Title = "Conference Planner API", Version = "v1" }));
4948
}
5049

5150
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
52-
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
51+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
5352
{
53+
if (env.IsDevelopment())
54+
{
55+
app.UseDeveloperExceptionPage();
56+
}
57+
58+
app.UseHttpsRedirection();
59+
60+
app.UseRouting();
61+
62+
app.UseAuthorization();
63+
5464
app.UseSwagger();
5565

5666
app.UseSwaggerUI(options =>
5767
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Conference Planner API v1")
5868
);
5969

60-
if (env.IsDevelopment())
61-
{
62-
app.UseDeveloperExceptionPage();
63-
}
64-
else
70+
app.UseEndpoints(endpoints =>
6571
{
66-
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
67-
app.UseHsts();
68-
}
69-
70-
app.UseHttpsRedirection();
71-
app.UseMvc();
72+
endpoints.MapControllers();
73+
});
7274

7375
app.Run(context =>
7476
{

save-points/1-Create-API-and-EF-Model/ConferencePlanner/BackEnd/appsettings.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
"ConnectionStrings": {
33
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-BackEnd-931E56BD-86CB-4A96-BD99-2C6A6ABB0829;Trusted_Connection=True;MultipleActiveResultSets=true"
44
},
5-
"Logging": {
6-
"LogLevel": {
7-
"Default": "Warning"
8-
}
9-
},
10-
"AllowedHosts": "*"
5+
"Logging": {
6+
"LogLevel": {
7+
"Default": "Warning",
8+
"Microsoft": "Warning",
9+
"Microsoft.Hosting.Lifetime": "Information"
10+
}
11+
},
12+
"AllowedHosts": "*"
1113
}

0 commit comments

Comments
 (0)