Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exercise-complete #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
Binary file added .vs/ProjectEvaluation/cars.metadata.v9.bin
Binary file not shown.
Binary file added .vs/ProjectEvaluation/cars.projects.v9.bin
Binary file not shown.
Binary file added .vs/ProjectEvaluation/cars.strings.v9.bin
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added .vs/cars/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file not shown.
1,016 changes: 1,016 additions & 0 deletions .vs/cars/config/applicationhost.config

Large diffs are not rendered by default.

Binary file not shown.
Binary file added .vs/cars/v17/.futdcache.v2
Binary file not shown.
Binary file added .vs/cars/v17/.suo
Binary file not shown.
58 changes: 58 additions & 0 deletions .vs/cars/v17/DocumentLayout.backup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\Jonas\\Documents\\Boolean\\AI\\ai-day-2\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{9EFDF816-2C0B-47DA-A88E-ABB878287423}|cars.wwwapi\\cars.wwwapi.csproj|c:\\users\\jonas\\documents\\boolean\\ai\\ai-day-2\\cars.wwwapi\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{9EFDF816-2C0B-47DA-A88E-ABB878287423}|cars.wwwapi\\cars.wwwapi.csproj|solutionrelative:cars.wwwapi\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{493CAE6C-941C-4543-9531-0068C74B9FC1}|cars.webapp\\cars.webapp.csproj|c:\\users\\jonas\\documents\\boolean\\ai\\ai-day-2\\cars.webapp\\pages\\index.cshtml||{40D31677-CBC0-4297-A9EF-89D907823A98}",
"RelativeMoniker": "D:0:0:{493CAE6C-941C-4543-9531-0068C74B9FC1}|cars.webapp\\cars.webapp.csproj|solutionrelative:cars.webapp\\pages\\index.cshtml||{40D31677-CBC0-4297-A9EF-89D907823A98}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 1,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:0:0:{aa2115a1-9712-457b-9047-dbb71ca2cdd2}"
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "Program.cs",
"DocumentMoniker": "C:\\Users\\Jonas\\Documents\\Boolean\\AI\\ai-day-2\\cars.wwwapi\\Program.cs",
"RelativeDocumentMoniker": "cars.wwwapi\\Program.cs",
"ToolTip": "C:\\Users\\Jonas\\Documents\\Boolean\\AI\\ai-day-2\\cars.wwwapi\\Program.cs",
"RelativeToolTip": "cars.wwwapi\\Program.cs",
"ViewState": "AgIAAAMAAAAAAAAAAAAwwBYAAAAVAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-10-25T12:00:06.736Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "Index.cshtml",
"DocumentMoniker": "C:\\Users\\Jonas\\Documents\\Boolean\\AI\\ai-day-2\\cars.webapp\\Pages\\Index.cshtml",
"RelativeDocumentMoniker": "cars.webapp\\Pages\\Index.cshtml",
"ToolTip": "C:\\Users\\Jonas\\Documents\\Boolean\\AI\\ai-day-2\\cars.webapp\\Pages\\Index.cshtml",
"RelativeToolTip": "cars.webapp\\Pages\\Index.cshtml",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAA8AAAAQAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000759|",
"WhenOpened": "2024-10-25T11:56:40.399Z",
"EditorCaption": ""
}
]
}
]
}
]
}
58 changes: 58 additions & 0 deletions .vs/cars/v17/DocumentLayout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\Jonas\\Documents\\Boolean\\AI\\ai-day-2\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{9EFDF816-2C0B-47DA-A88E-ABB878287423}|cars.wwwapi\\cars.wwwapi.csproj|c:\\users\\jonas\\documents\\boolean\\ai\\ai-day-2\\cars.wwwapi\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{9EFDF816-2C0B-47DA-A88E-ABB878287423}|cars.wwwapi\\cars.wwwapi.csproj|solutionrelative:cars.wwwapi\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{493CAE6C-941C-4543-9531-0068C74B9FC1}|cars.webapp\\cars.webapp.csproj|c:\\users\\jonas\\documents\\boolean\\ai\\ai-day-2\\cars.webapp\\pages\\index.cshtml||{40D31677-CBC0-4297-A9EF-89D907823A98}",
"RelativeMoniker": "D:0:0:{493CAE6C-941C-4543-9531-0068C74B9FC1}|cars.webapp\\cars.webapp.csproj|solutionrelative:cars.webapp\\pages\\index.cshtml||{40D31677-CBC0-4297-A9EF-89D907823A98}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 1,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:0:0:{aa2115a1-9712-457b-9047-dbb71ca2cdd2}"
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "Program.cs",
"DocumentMoniker": "C:\\Users\\Jonas\\Documents\\Boolean\\AI\\ai-day-2\\cars.wwwapi\\Program.cs",
"RelativeDocumentMoniker": "cars.wwwapi\\Program.cs",
"ToolTip": "C:\\Users\\Jonas\\Documents\\Boolean\\AI\\ai-day-2\\cars.wwwapi\\Program.cs",
"RelativeToolTip": "cars.wwwapi\\Program.cs",
"ViewState": "AgIAAAMAAAAAAAAAAAAwwBYAAAAVAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-10-25T12:00:06.736Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "Index.cshtml",
"DocumentMoniker": "C:\\Users\\Jonas\\Documents\\Boolean\\AI\\ai-day-2\\cars.webapp\\Pages\\Index.cshtml",
"RelativeDocumentMoniker": "cars.webapp\\Pages\\Index.cshtml",
"ToolTip": "C:\\Users\\Jonas\\Documents\\Boolean\\AI\\ai-day-2\\cars.webapp\\Pages\\Index.cshtml",
"RelativeToolTip": "cars.webapp\\Pages\\Index.cshtml",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAA8AAAAQAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000759|",
"WhenOpened": "2024-10-25T11:56:40.399Z",
"EditorCaption": ""
}
]
}
]
}
]
}
28 changes: 28 additions & 0 deletions cars.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cars.webapp", "cars.webapp\cars.webapp.csproj", "{493CAE6C-941C-4543-9531-0068C74B9FC1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cars.wwwapi", "cars.wwwapi\cars.wwwapi.csproj", "{9EFDF816-2C0B-47DA-A88E-ABB878287423}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{493CAE6C-941C-4543-9531-0068C74B9FC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{493CAE6C-941C-4543-9531-0068C74B9FC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{493CAE6C-941C-4543-9531-0068C74B9FC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{493CAE6C-941C-4543-9531-0068C74B9FC1}.Release|Any CPU.Build.0 = Release|Any CPU
{9EFDF816-2C0B-47DA-A88E-ABB878287423}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9EFDF816-2C0B-47DA-A88E-ABB878287423}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9EFDF816-2C0B-47DA-A88E-ABB878287423}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9EFDF816-2C0B-47DA-A88E-ABB878287423}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
26 changes: 26 additions & 0 deletions cars.webapp/Pages/Error.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@page
@model ErrorModel
@{
ViewData["Title"] = "Error";
}

<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}

<h3>Development Mode</h3>
<p>
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>
27 changes: 27 additions & 0 deletions cars.webapp/Pages/Error.cshtml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace cars.webapp.Pages;

[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string? RequestId { get; set; }

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);

private readonly ILogger<ErrorModel> _logger;

public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}

public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}

48 changes: 48 additions & 0 deletions cars.webapp/Pages/Index.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
@page
@model IndexModel
@{
ViewData["Title"] = "Home page";
}

<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>

<div>
<h2>Car List</h2>
<table class="table table-striped" id="carTable">
<thead>
<tr>
<th>Id</th>
<th>Make</th>
<th>Model</th>
<th>Year</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>

@section Scripts {
<script>
async function fetchCars() {
const response = await fetch('http://localhost:5157/cars');
const cars = await response.json();
const tableBody = document.querySelector('#carTable tbody');
cars.forEach(car => {
const row = document.createElement('tr');
row.innerHTML = `
<td>${car.id}</td>
<td>${car.make}</td>
<td>${car.model}</td>
<td>${car.year}</td>
`;
tableBody.appendChild(row);
});
}

document.addEventListener('DOMContentLoaded', fetchCars);
</script>
}
19 changes: 19 additions & 0 deletions cars.webapp/Pages/Index.cshtml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace cars.webapp.Pages;

public class IndexModel : PageModel
{
private readonly ILogger<IndexModel> _logger;

public IndexModel(ILogger<IndexModel> logger)
{
_logger = logger;
}

public void OnGet()
{

}
}
8 changes: 8 additions & 0 deletions cars.webapp/Pages/Privacy.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@page
@model PrivacyModel
@{
ViewData["Title"] = "Privacy Policy";
}
<h1>@ViewData["Title"]</h1>

<p>Use this page to detail your site's privacy policy.</p>
19 changes: 19 additions & 0 deletions cars.webapp/Pages/Privacy.cshtml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace cars.webapp.Pages;

public class PrivacyModel : PageModel
{
private readonly ILogger<PrivacyModel> _logger;

public PrivacyModel(ILogger<PrivacyModel> logger)
{
_logger = logger;
}

public void OnGet()
{
}
}

51 changes: 51 additions & 0 deletions cars.webapp/Pages/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - cars.webapp</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/cars.webapp.styles.css" asp-append-version="true" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container">
<a class="navbar-brand" asp-area="" asp-page="/Index">cars.webapp</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Privacy">Privacy</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>

<footer class="border-top footer text-muted">
<div class="container">
&copy; 2024 - cars.webapp - <a asp-area="" asp-page="/Privacy">Privacy</a>
</div>
</footer>

<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>

@await RenderSectionAsync("Scripts", required: false)
</body>
</html>
Loading