Skip to content

Commit 66b4ecb

Browse files
committed
Update NuGet packages, enhance SEO, and add icons
Updated several NuGet packages to their latest versions, including `System.Drawing.Common`, `Microsoft.Extensions.Http`, and `Microsoft.EntityFrameworkCore` packages, ensuring the application benefits from the latest features and security fixes. Modified the `Details.cshtml` file to improve department name display and added structured data generation for employee details. Introduced a new `BreadcrumbHelper` class for enhanced navigation and updated the `_metatags.cshtml` file for better SEO. Included new favicon images and updated the `site.webmanifest` to support additional app icons, improving the visual branding across platforms.
1 parent cec204b commit 66b4ecb

22 files changed

+580
-56
lines changed

Mwh.Sample.Domain/Mwh.Sample.Domain.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@
2727
<FrameworkReference Include="Microsoft.AspNetCore.App" />
2828
</ItemGroup>
2929
<ItemGroup>
30-
<PackageReference Include="System.Drawing.Common" Version="9.0.6" />
30+
<PackageReference Include="System.Drawing.Common" Version="9.0.7" />
3131
</ItemGroup>
3232
</Project>

Mwh.Sample.HttpClientFactory/Mwh.Sample.HttpClientFactory.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
</ItemGroup>
2121
<ItemGroup>
2222
<FrameworkReference Include="Microsoft.AspNetCore.App" />
23-
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.6" />
24-
<PackageReference Include="System.Text.Json" Version="9.0.6" />
23+
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.7" />
24+
<PackageReference Include="System.Text.Json" Version="9.0.7" />
2525
</ItemGroup>
2626
<ItemGroup>
2727
<ProjectReference Include="..\Mwh.Sample.Domain\Mwh.Sample.Domain.csproj" />

Mwh.Sample.Repository/Mwh.Sample.Repository.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
</ItemGroup>
2828
<ItemGroup>
2929
<PackageReference Include="Bogus" Version="35.6.3" />
30-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.6" />
31-
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.6" />
32-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.6" />
30+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.7" />
31+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.7" />
32+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.7" />
3333
</ItemGroup>
3434
<ItemGroup>
3535
<ProjectReference Include="..\Mwh.Sample.Domain\Mwh.Sample.Domain.csproj" />
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.Rendering;
3+
4+
namespace Mwh.Sample.Web.Helpers;
5+
6+
/// <summary>
7+
/// Helper class for generating breadcrumb navigation
8+
/// </summary>
9+
public static class BreadcrumbHelper
10+
{
11+
/// <summary>
12+
/// Generate breadcrumbs based on the current route
13+
/// </summary>
14+
public static List<(string Name, string Url)> GenerateBreadcrumbs(ViewContext viewContext)
15+
{
16+
var breadcrumbs = new List<(string Name, string Url)>();
17+
18+
// Always start with Home
19+
breadcrumbs.Add(("Home", "/"));
20+
21+
var areaName = viewContext.RouteData.Values["area"]?.ToString();
22+
var controllerName = viewContext.RouteData.Values["controller"]?.ToString();
23+
var actionName = viewContext.RouteData.Values["action"]?.ToString();
24+
var idValue = viewContext.RouteData.Values["id"]?.ToString();
25+
26+
// Skip if we're already on the home page
27+
if (string.IsNullOrEmpty(controllerName) || controllerName.Equals("Home", StringComparison.OrdinalIgnoreCase))
28+
{
29+
if (string.IsNullOrEmpty(actionName) || actionName.Equals("Index", StringComparison.OrdinalIgnoreCase))
30+
{
31+
return breadcrumbs;
32+
}
33+
}
34+
35+
// Handle different controller patterns
36+
switch (controllerName?.ToLower())
37+
{
38+
case "mvcemployee":
39+
breadcrumbs.Add(("Employee Management", "/MvcEmployee"));
40+
AddActionBreadcrumb(breadcrumbs, actionName, idValue, "/MvcEmployee");
41+
break;
42+
43+
case "employee":
44+
breadcrumbs.Add(("Employee AJAX", "/Employee"));
45+
AddActionBreadcrumb(breadcrumbs, actionName, idValue, "/Employee");
46+
break;
47+
48+
case "employeesinglepage":
49+
breadcrumbs.Add(("Single Page App", "/EmployeeSinglePage"));
50+
AddActionBreadcrumb(breadcrumbs, actionName, idValue, "/EmployeeSinglePage");
51+
break;
52+
53+
case "employeepivot":
54+
breadcrumbs.Add(("Employee Pivot", "/EmployeePivot"));
55+
AddActionBreadcrumb(breadcrumbs, actionName, idValue, "/EmployeePivot");
56+
break;
57+
58+
default:
59+
// Handle other controllers generically
60+
if (!string.IsNullOrEmpty(controllerName))
61+
{
62+
var controllerDisplayName = FormatControllerName(controllerName);
63+
breadcrumbs.Add((controllerDisplayName, $"/{controllerName}"));
64+
AddActionBreadcrumb(breadcrumbs, actionName, idValue, $"/{controllerName}");
65+
}
66+
break;
67+
}
68+
69+
// Handle Razor Pages
70+
if (viewContext.ActionDescriptor.DisplayName?.Contains("Pages") == true ||
71+
viewContext.HttpContext.Request.Path.Value?.Contains("/EmployeeRazor") == true)
72+
{
73+
breadcrumbs.Clear();
74+
breadcrumbs.Add(("Home", "/"));
75+
breadcrumbs.Add(("Employee Razor Pages", "/EmployeeRazor"));
76+
77+
var pageName = viewContext.HttpContext.Request.Path.Value?.Split('/').LastOrDefault();
78+
if (!string.IsNullOrEmpty(pageName) && !pageName.Equals("EmployeeRazor", StringComparison.OrdinalIgnoreCase))
79+
{
80+
AddPageBreadcrumb(breadcrumbs, pageName, idValue);
81+
}
82+
}
83+
84+
return breadcrumbs;
85+
}
86+
87+
/// <summary>
88+
/// Add action-specific breadcrumb
89+
/// </summary>
90+
private static void AddActionBreadcrumb(List<(string Name, string Url)> breadcrumbs, string? actionName, string? idValue, string basePath)
91+
{
92+
if (string.IsNullOrEmpty(actionName) || actionName.Equals("Index", StringComparison.OrdinalIgnoreCase))
93+
return;
94+
95+
switch (actionName.ToLower())
96+
{
97+
case "create":
98+
breadcrumbs.Add(("Create Employee", $"{basePath}/Create"));
99+
break;
100+
101+
case "edit":
102+
breadcrumbs.Add(("Edit Employee", string.IsNullOrEmpty(idValue) ? $"{basePath}/Edit" : $"{basePath}/Edit/{idValue}"));
103+
break;
104+
105+
case "details":
106+
breadcrumbs.Add(("Employee Details", string.IsNullOrEmpty(idValue) ? $"{basePath}/Details" : $"{basePath}/Details/{idValue}"));
107+
break;
108+
109+
case "delete":
110+
breadcrumbs.Add(("Delete Employee", string.IsNullOrEmpty(idValue) ? $"{basePath}/Delete" : $"{basePath}/Delete/{idValue}"));
111+
break;
112+
113+
default:
114+
var actionDisplayName = FormatActionName(actionName);
115+
breadcrumbs.Add((actionDisplayName, $"{basePath}/{actionName}"));
116+
break;
117+
}
118+
}
119+
120+
/// <summary>
121+
/// Add page-specific breadcrumb for Razor Pages
122+
/// </summary>
123+
private static void AddPageBreadcrumb(List<(string Name, string Url)> breadcrumbs, string pageName, string? idValue)
124+
{
125+
switch (pageName.ToLower())
126+
{
127+
case "create":
128+
breadcrumbs.Add(("Create Employee", "/EmployeeRazor/Create"));
129+
break;
130+
131+
case "edit":
132+
breadcrumbs.Add(("Edit Employee", string.IsNullOrEmpty(idValue) ? "/EmployeeRazor/Edit" : $"/EmployeeRazor/Edit/{idValue}"));
133+
break;
134+
135+
case "details":
136+
breadcrumbs.Add(("Employee Details", string.IsNullOrEmpty(idValue) ? "/EmployeeRazor/Details" : $"/EmployeeRazor/Details/{idValue}"));
137+
break;
138+
139+
case "delete":
140+
breadcrumbs.Add(("Delete Employee", string.IsNullOrEmpty(idValue) ? "/EmployeeRazor/Delete" : $"/EmployeeRazor/Delete/{idValue}"));
141+
break;
142+
143+
default:
144+
var pageDisplayName = FormatPageName(pageName);
145+
breadcrumbs.Add((pageDisplayName, $"/EmployeeRazor/{pageName}"));
146+
break;
147+
}
148+
}
149+
150+
/// <summary>
151+
/// Format controller name for display
152+
/// </summary>
153+
private static string FormatControllerName(string controllerName)
154+
{
155+
return controllerName switch
156+
{
157+
"MvcEmployee" => "MVC Employee",
158+
"EmployeeSinglePage" => "Single Page App",
159+
"EmployeePivot" => "Employee Pivot",
160+
_ => controllerName
161+
};
162+
}
163+
164+
/// <summary>
165+
/// Format action name for display
166+
/// </summary>
167+
private static string FormatActionName(string actionName)
168+
{
169+
return actionName switch
170+
{
171+
"Create" => "Create",
172+
"Edit" => "Edit",
173+
"Details" => "Details",
174+
"Delete" => "Delete",
175+
_ => actionName
176+
};
177+
}
178+
179+
/// <summary>
180+
/// Format page name for display
181+
/// </summary>
182+
private static string FormatPageName(string pageName)
183+
{
184+
return pageName switch
185+
{
186+
"Create" => "Create",
187+
"Edit" => "Edit",
188+
"Details" => "Details",
189+
"Delete" => "Delete",
190+
_ => pageName
191+
};
192+
}
193+
}

0 commit comments

Comments
 (0)