Skip to content

Commit badd08c

Browse files
author
Kendall Roden
committed
initial commit
1 parent e4b648a commit badd08c

21 files changed

+813
-70
lines changed

.gitignore

+450
Large diffs are not rendered by default.

.vscode/launch.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
// Use IntelliSense to find out which attributes exist for C# debugging
6+
// Use hover for the description of the existing attributes
7+
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
8+
"name": ".NET Core Album API Launch (web)",
9+
"type": "coreclr",
10+
"request": "launch",
11+
"preLaunchTask": "build",
12+
// If you have changed target frameworks, make sure to update the program path.
13+
"program": "${workspaceFolder}/src/bin/Debug/net6.0/albumapi_csharp.dll",
14+
"args": [],
15+
"cwd": "${workspaceFolder}/src",
16+
"stopAtEntry": false,
17+
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
18+
"serverReadyAction": {
19+
"action": "openExternally",
20+
"pattern": "\\bNow listening on:\\s+(http?://\\S+)"
21+
},
22+
"env": {
23+
"ASPNETCORE_ENVIRONMENT": "Development"
24+
},
25+
"sourceFileMap": {
26+
"/Views": "${workspaceFolder}/Views"
27+
}
28+
},
29+
{
30+
"name": ".NET Core Album API Attach",
31+
"type": "coreclr",
32+
"request": "attach"
33+
}
34+
]
35+
}

.vscode/tasks.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "build",
6+
"command": "dotnet",
7+
"type": "process",
8+
"args": [
9+
"build",
10+
"${workspaceFolder}/src/albumapi_csharp.csproj",
11+
"/property:GenerateFullPaths=true",
12+
"/consoleloggerparameters:NoSummary"
13+
],
14+
"problemMatcher": "$msCompile"
15+
},
16+
{
17+
"label": "publish",
18+
"command": "dotnet",
19+
"type": "process",
20+
"args": [
21+
"publish",
22+
"${workspaceFolder}/src/albumapi_csharp.csproj",
23+
"/property:GenerateFullPaths=true",
24+
"/consoleloggerparameters:NoSummary"
25+
],
26+
"problemMatcher": "$msCompile"
27+
},
28+
{
29+
"label": "watch",
30+
"command": "dotnet",
31+
"type": "process",
32+
"args": [
33+
"watch",
34+
"run",
35+
"--project",
36+
"${workspaceFolder}/src/albumapi_csharp.csproj"
37+
],
38+
"problemMatcher": "$msCompile"
39+
}
40+
]
41+
}

CHANGELOG.md

-13
This file was deleted.

README.md

-57
Original file line numberDiff line numberDiff line change
@@ -1,57 +0,0 @@
1-
# Project Name
2-
3-
(short, 1-3 sentenced, description of the project)
4-
5-
## Features
6-
7-
This project framework provides the following features:
8-
9-
* Feature 1
10-
* Feature 2
11-
* ...
12-
13-
## Getting Started
14-
15-
### Prerequisites
16-
17-
(ideally very short, if any)
18-
19-
- OS
20-
- Library version
21-
- ...
22-
23-
### Installation
24-
25-
(ideally very short)
26-
27-
- npm install [package name]
28-
- mvn install
29-
- ...
30-
31-
### Quickstart
32-
(Add steps to get up and running quickly)
33-
34-
1. git clone [repository clone url]
35-
2. cd [repository name]
36-
3. ...
37-
38-
39-
## Demo
40-
41-
A demo app is included to show how to use the project.
42-
43-
To run the demo, follow these steps:
44-
45-
(Add steps to start up the demo)
46-
47-
1.
48-
2.
49-
3.
50-
51-
## Resources
52-
53-
(Any additional resources or related projects)
54-
55-
- Link to supporting information
56-
- Link to similar sample
57-
- ...

src/Dockerfile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
2+
WORKDIR /app
3+
EXPOSE 80
4+
5+
ENV ASPNETCORE_URLS=http://+:80
6+
7+
# Copy csproj and restore as distinct layers
8+
COPY *.csproj ./
9+
RUN dotnet restore
10+
11+
# Copy everything else and build
12+
COPY . .
13+
RUN dotnet publish -c Release -o out
14+
15+
# Build runtime image
16+
FROM mcr.microsoft.com/dotnet/aspnet:6.0
17+
WORKDIR /app
18+
COPY --from=build-env /app/out .
19+
ENTRYPOINT ["dotnet", "aca-csharp.dll"]

src/Program.cs

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
var builder = WebApplication.CreateBuilder();
2+
3+
// Add services to the container.
4+
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
5+
builder.Services.AddEndpointsApiExplorer();
6+
builder.Services.AddSwaggerGen();
7+
8+
builder.Services.AddCors(options => {
9+
options.AddDefaultPolicy(builder =>
10+
{
11+
builder.AllowAnyOrigin();
12+
builder.AllowAnyHeader();
13+
builder.AllowAnyMethod();
14+
});
15+
});
16+
17+
var app = builder.Build();
18+
19+
// Configure the HTTP request pipeline.
20+
if (app.Environment.IsDevelopment())
21+
{
22+
app.UseSwagger();
23+
app.UseSwaggerUI();
24+
}
25+
26+
app.UseCors();
27+
28+
app.MapGet("/", async context =>
29+
{
30+
await context.Response.WriteAsync("Hit the /albums endpoint to retrieve a list of albums!");
31+
});
32+
33+
app.MapGet("/albums", () =>
34+
{
35+
return Album.GetAll();
36+
})
37+
.WithName("GetAlbums");
38+
39+
app.Run();
40+
41+
record Album(int Id, string Title, string Artist, double Price, string Image_URL)
42+
{
43+
public static List<Album> GetAll(){
44+
var albums = new List<Album>(){
45+
new Album(1, "Sgt Peppers Lonely Hearts Club Band", "The Beatles", 10.99, "https://www.listchallenges.com/f/items/f3b05a20-31ae-4fdf-aebd-d1515af54eea.jpg"),
46+
new Album(2, "Pet Sounds", "The Beach Boys", 13.99, "https://www.listchallenges.com/f/items/fdef1440-e979-455a-90a7-14e77fac79af.jpg"),
47+
new Album(3, "The Beatles: Revolver", "The Beatles", 13.99, "https://www.listchallenges.com/f/items/19ff786d-d7a4-4fdc-bee2-59db8b33370d.jpg"),
48+
new Album(4, "Highway 61 Revisited", "Bob Dylan", 12.99,"https://www.listchallenges.com/f/items/428cf087-6c24-45ad-bf8c-bd3c57ddf444.jpg"),
49+
new Album(5, "Rubber Soul", "The Beatles", 12.99, "https://www.listchallenges.com/f/items/ebc794ef-1491-4672-a007-0081edc1a8ae.jpg"),
50+
new Album(6, "What's Going On", "Marvin Gaye", 14.99, "https://www.listchallenges.com/f/items/e5250d6c-1c15-4617-a943-b27e87e21704.jpg")
51+
};
52+
53+
return albums;
54+
}
55+
}

src/Properties/launchSettings.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"iisSettings": {
4+
"windowsAuthentication": false,
5+
"anonymousAuthentication": true,
6+
"iisExpress": {
7+
"applicationUrl": "http://localhost:17352",
8+
"sslPort": 44328
9+
}
10+
},
11+
"profiles": {
12+
"albumapi_csharp": {
13+
"commandName": "Project",
14+
"dotnetRunMessages": true,
15+
"launchBrowser": true,
16+
"launchUrl": "swagger",
17+
"applicationUrl": "https://localhost:3501;http://localhost:3500",
18+
"environmentVariables": {
19+
"ASPNETCORE_ENVIRONMENT": "Development"
20+
}
21+
},
22+
"IIS Express": {
23+
"commandName": "IISExpress",
24+
"launchBrowser": true,
25+
"launchUrl": "swagger",
26+
"environmentVariables": {
27+
"ASPNETCORE_ENVIRONMENT": "Development"
28+
}
29+
}
30+
}
31+
}

src/albumapi_csharp.csproj

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<RootNamespace>albumapi_csharp</RootNamespace>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
12+
</ItemGroup>
13+
14+
</Project>

src/appsettings.Development.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
}
8+
}

src/appsettings.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
},
8+
"AllowedHosts": "*"
9+
}

src/net6.0/Microsoft.OpenApi.dll

170 KB
Binary file not shown.
14.5 KB
Binary file not shown.
Binary file not shown.
3.55 MB
Binary file not shown.

src/net6.0/albumapi_csharp

129 KB
Binary file not shown.

0 commit comments

Comments
 (0)