diff --git a/AppLibs/AppLibs/Libs/AsyncGateAttribute.cs b/AppLibs/AppLibs/Libs/AsyncGateAttribute.cs new file mode 100644 index 0000000..6a23b3e --- /dev/null +++ b/AppLibs/AppLibs/Libs/AsyncGateAttribute.cs @@ -0,0 +1,38 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AppLibs.Libs +{ + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] + public sealed class AsyncGateAttribute : Attribute, IAsyncActionFilter + { + public async Task OnActionExecutionAsync( + ActionExecutingContext context, + ActionExecutionDelegate next) + { + var vr = context.HttpContext.Request.Query["vr"].ToString(); + + // Nếu có vr=cAsync hoặc vr=lAsync => cho chạy action (logic nặng) + if (vr == "cAsync" || vr == "lAsync") + { + await next(); + return; + } + + // Không có vr => return ViewAsync ngay, bỏ qua action + if (context.Controller is Controller c) + { + var result = await ControllerExtensions.ViewAsync(c); + context.Result = result; // short-circuit + return; + } + + context.Result = new NotFoundResult(); + } + } +} diff --git a/AppLibs/AppLibs/Libs/ControllerExtensions.cs b/AppLibs/AppLibs/Libs/ControllerExtensions.cs index 654bc41..ab8efbe 100644 --- a/AppLibs/AppLibs/Libs/ControllerExtensions.cs +++ b/AppLibs/AppLibs/Libs/ControllerExtensions.cs @@ -7,6 +7,7 @@ using Newtonsoft.Json; using Microsoft.AspNetCore.Http; using AppLibs.Libs.Pages; using System.Security.Cryptography; +using System.Runtime.CompilerServices; namespace AppLibs.Libs { @@ -152,6 +153,22 @@ namespace AppLibs.Libs await viewResult.View.RenderAsync(viewContext); return Regex.Replace(writer.ToString(), @"(?>[^\S ]\s*| \s{2,})", "").Trim(); } + } + + public static async Task ReadStaticPage(this Controller controller, string id) + { + var filePath = Path.Combine(Directory.GetCurrentDirectory(), + "Data", "page", $"{id}.html"); + + if (!System.IO.File.Exists(filePath)) + throw new FileNotFoundException(); + + string htmlContent; + using (var reader = new StreamReader(filePath)) + { + htmlContent = await reader.ReadToEndAsync(); + } + return htmlContent; } } } diff --git a/AppLibs/AppLibs/Libs/LayoutAttribute.cs b/AppLibs/AppLibs/Libs/LayoutAttribute.cs index c9a50cb..e27d5ee 100644 --- a/AppLibs/AppLibs/Libs/LayoutAttribute.cs +++ b/AppLibs/AppLibs/Libs/LayoutAttribute.cs @@ -23,7 +23,7 @@ namespace AppLibs.Libs { } - public LayoutAttribute(LayoutOptions option, string layoutName = "") + public LayoutAttribute(LayoutOptions option, string layoutName = "Async") { switch (option) { diff --git a/TWA-App/Controllers/CompanyController.cs b/TWA-App/Controllers/CompanyController.cs new file mode 100644 index 0000000..8f26a5f --- /dev/null +++ b/TWA-App/Controllers/CompanyController.cs @@ -0,0 +1,30 @@ +using AppLibs.Libs; +using Microsoft.AspNetCore.Mvc; + +namespace TWA_App.Controllers +{ + public class CompanyController : Controller + { + [PageInfor("2000", "Company", "/Company/*")] + [Layout(LayoutOptions.Default)] + public async Task Index(string? id) + { + if (id != null) + { + NavItem list = (await WSNavigation.GetListMenu())[1]; + if (list.SubItem != null && list.SubItem.Count > 0) + { + NavItem? result = list.SubItem.FirstOrDefault(l => l.Url.Split('/').Last().Equals(id)); + if (result != null) { + ViewData["PageID"] = result.ID; + ViewData["Title"] = result.Name; + + ViewBag.Content = await this.ReadStaticPage(result.ID); + return await this.ViewAsync(); + } + } + } + return NotFound(); + } + } +} diff --git a/TWA-App/Data/page/2001.html b/TWA-App/Data/page/2001.html new file mode 100644 index 0000000..efeff02 --- /dev/null +++ b/TWA-App/Data/page/2001.html @@ -0,0 +1 @@ +Hello Page About Us \ No newline at end of file diff --git a/TWA-App/Data/page/2002.html b/TWA-App/Data/page/2002.html new file mode 100644 index 0000000..34afae2 --- /dev/null +++ b/TWA-App/Data/page/2002.html @@ -0,0 +1 @@ +Hello Page Our Team \ No newline at end of file diff --git a/TWA-App/Json/navlist.json b/TWA-App/Json/navlist.json index a7994b2..dbbd00d 100644 --- a/TWA-App/Json/navlist.json +++ b/TWA-App/Json/navlist.json @@ -14,36 +14,41 @@ "group": 0, "url": "", "sub-item": [ - { - "id": "2001", - "name": "About Us", - "url": "/Company/AboutUs" - }, + { + "id": "2001", + "name": "About Us", + "url": "/Company/AboutUs", + "flexpage": true + }, { "id": "2002", "name": "Our Team", "url": "/Company/OurTeam" }, - { - "id": "2003", - "name": "Mission & Vision", - "url": "/Company/Mission-Vision" - }, - { - "id": "2004", - "name": "Milestone", - "url": "/Company/Milestone" - }, - { - "id": "2005", - "name": "Careers", - "url": "/Company/Careers" - }, - { - "id": "2006", - "name": "Partners", - "url": "/Company/Partners" - } + { + "id": "2003", + "name": "Mission & Vision", + "url": "/Company/Mission-Vision", + "flexpage": true + }, + { + "id": "2004", + "name": "Milestone", + "url": "/Company/Milestone", + "flexpage": true + }, + { + "id": "2005", + "name": "Careers", + "url": "/Company/Careers", + "flexpage": true + }, + { + "id": "2006", + "name": "Partners", + "url": "/Company/Partners", + "flexpage": true + } ] }, { diff --git a/TWA-App/Program.cs b/TWA-App/Program.cs index 470bcb5..0106ce7 100644 --- a/TWA-App/Program.cs +++ b/TWA-App/Program.cs @@ -6,6 +6,10 @@ await WSNavigation.LoadJson(); var builder = WebApplication.CreateBuilder(args); // Add services to the container. +builder.Services.AddControllers(options => +{ + options.Filters.Add(); +}); #if (!DEBUG) builder.Services.Configure(options => { @@ -25,6 +29,7 @@ builder.Services.AddControllersWithViews(); #else builder.Services.AddControllersWithViews().AddRazorRuntimeCompilation(); #endif + var app = builder.Build(); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) @@ -41,6 +46,12 @@ app.UseAuthorization(); app.MapStaticAssets(); +app.MapControllerRoute( + name: "mapCompany", + pattern: "Company/{id?}", + defaults: new { controller = "Company", action = "Index" }) + .WithStaticAssets(); + app.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}") diff --git a/TWA-App/TWA-App.csproj b/TWA-App/TWA-App.csproj index 9bc43e1..25a2fd8 100644 --- a/TWA-App/TWA-App.csproj +++ b/TWA-App/TWA-App.csproj @@ -16,4 +16,13 @@ + + + Always + + + Always + + + diff --git a/TWA-App/Views/Company/Index.cshtml b/TWA-App/Views/Company/Index.cshtml new file mode 100644 index 0000000..4fc9d22 --- /dev/null +++ b/TWA-App/Views/Company/Index.cshtml @@ -0,0 +1,5 @@ +@Html.Raw(ViewBag.Content) + +@section jsLib { + +} \ No newline at end of file diff --git a/TWA-App/Views/Home/Index.cshtml b/TWA-App/Views/Home/Index.cshtml index a5201e8..f1457f6 100644 --- a/TWA-App/Views/Home/Index.cshtml +++ b/TWA-App/Views/Home/Index.cshtml @@ -392,7 +392,7 @@ -
+
@@ -406,84 +406,131 @@
-
-
- - - +
+
+
+

Air Freight

+
+
+
+ + + + + + + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + + + + + + +
+
+
+ + + +
+
+
+ +

We will contact you soon!

+

+ As one of the world’s leading supply chain management companies. +

+
+
- -
- - - -
- -
- - - -
- -
-
- - - - - -
-
- -
+
+
+
+

Tracking shipments

+
    +
  • + + Depending on the tracking technology that carriers are using, Morz’s system will work differently to receive and create updates on the status of the shipments. While some tracking updates are received through automated systems, others require Morz tracking teams to regularly reach out to carriers. If you have questions about tracking your shipment, contact your Account Executive. + +
  • +
  • + + Make sure you use a Morz BOL, otherwise it could result in tracking information delays. The carriers send shipment tracking information to Morz’s system when a Morz BOL is used. + +
  • +
  • + + For help finding the BOL number, take a look at a BOL example. Contact your account manager to get a copy of your BOL if you don’t have one. + +
  • +
+
+
+
+ +
+ + +
+
+
+
+
+
+ +
+
+
+
+ +
@@ -519,85 +566,122 @@
-
-
- - - -
-
-
- +
+
+
+
+
+ + + +
+
+
+ +
+ +
+ Logistics +

+ 5 Ways To Get The Most Out Of Your Logistics +

+
+
+ Oct 13, 2021 +
+
+ 0 +
+
+
-
- Logistics -

- The Top 5 Changes That Occur With AI in Logistics -

-
-
- Oct 13, 2021 +
+
+ + + +
+
+
+ +
+ +
+ Logistics +

+ The Top 5 Changes That Occur With AI in Logistics +

+
+
+ Oct 13, 2021 +
+
+ 0 +
+
+
-
- 0 -
-
-
-
-
-
-
- - - -
-
-
- -
- -
- Logistics -

- 5 Ways To Get The Most Out Of Your Logistics -

-
-
- Oct 13, 2021 -
-
- 0 -
-
-
-
-
-
-
- - - -
-
-
- -
- -
- Logistics -

- Supply Chain And Logistics Trends That Could Be Big -

-
-
- Oct 13, 2021 -
-
- 0 +
+
+
+ + + +
+
+
+ +
+ +
+ Logistics +

+ 5 Ways To Get The Most Out Of Your Logistics +

+
+
+ Oct 13, 2021 +
+
+ 0 +
+
+
+
+
+
+
+ + + +
+
+
+ +
+ +
+ Logistics +

+ Supply Chain And Logistics Trends That Could Be Big +

+
+
+ Oct 13, 2021 +
+
+ 0 +
+
+
+ + +
+
diff --git a/TWA-App/Views/Partial/Footer.cshtml b/TWA-App/Views/Partial/Footer.cshtml index fc3674d..39c090c 100644 --- a/TWA-App/Views/Partial/Footer.cshtml +++ b/TWA-App/Views/Partial/Footer.cshtml @@ -1,7 +1,7 @@