Skip to content

Commit 8c1b24e

Browse files
committed
2nd Session, UI Update + New Controller Class + Form
1 parent 01eea6f commit 8c1b24e

15 files changed

Lines changed: 162 additions & 11 deletions

.DS_Store

8 KB
Binary file not shown.

CMS.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@
88

99
<PropertyGroup Condition=" '$(RunConfiguration)' == 'https' " />
1010
<PropertyGroup Condition=" '$(RunConfiguration)' == 'http' " />
11+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
12+
<WarningLevel>4</WarningLevel>
13+
</PropertyGroup>
1114
<ItemGroup>
1215
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="7.0.10" />
1316
</ItemGroup>
17+
<ItemGroup>
18+
<None Remove="Views\Record\" />
19+
</ItemGroup>
20+
<ItemGroup>
21+
<Folder Include="Views\Record\" />
22+
</ItemGroup>
1423
</Project>

CMS.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ VisualStudioVersion = 25.0.1706.3
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CMS", "CMS.csproj", "{D11EF63C-52B6-4350-922B-32402DB67BF2}"
77
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E1E4C05C-3715-4C32-BE84-03B4C26BE38F}"
9+
ProjectSection(SolutionItems) = preProject
10+
global.xft.xml = global.xft.xml
11+
EmptyClass.cs = EmptyClass.cs
12+
global.cs = global.cs
13+
EndProjectSection
14+
EndProject
815
Global
916
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1017
Debug|Any CPU = Debug|Any CPU

Controllers/HomeController.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ public HomeController(ILogger<HomeController> logger)
1515

1616
public IActionResult Index()
1717
{
18+
string user = "Hardy Wen";
19+
int stu_num = 21447;
20+
21+
var currentTime = DateTime.Now;
22+
string greeting = "";
23+
greeting = (currentTime.Hour >= 0 && currentTime.Hour < 12) ? "Good Morning" :
24+
(currentTime.Hour >= 12 && currentTime.Hour < 18) ? "Good Afternoon" : "Good Evening";
25+
26+
ViewBag.user = user;
27+
ViewBag.stu_num = stu_num;
28+
ViewBag.greeting = greeting;
29+
1830
return View();
1931
}
2032

Controllers/RecordController.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc;
6+
7+
// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
8+
9+
namespace CMS.Controllers
10+
{
11+
public class RecordController : Controller
12+
{
13+
// GET: /<controller>/
14+
public IActionResult Index()
15+
{
16+
return View();
17+
}
18+
19+
public IActionResult TimeTable()
20+
{
21+
return View();
22+
}
23+
24+
public IActionResult Assessments()
25+
{
26+
return View();
27+
}
28+
29+
[HttpPost]
30+
public ActionResult TestForm(Models.TestResult sm)
31+
{
32+
ViewBag.subject = sm.subject;
33+
ViewBag.grade = sm.grade;
34+
35+
return View("Assessments");
36+
}
37+
}
38+
}
39+

Models/TestResult.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System;
2+
namespace CMS.Models
3+
{
4+
public class TestResult
5+
{
6+
public string subject { get; set; }
7+
public float grade { get; set; }
8+
}
9+
}
10+

Properties/launchSettings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
"environmentVariables": {
3434
"ASPNETCORE_ENVIRONMENT": "Development"
3535
}
36+
},
37+
"CMS": {
38+
"commandName": "Project",
39+
"launchBrowser": true,
40+
"applicationUrl": "https://localhost:50169;http://localhost:38710",
41+
"environmentVariables": {
42+
"ASPNETCORE_ENVIRONMENT": "Development"
43+
}
3644
}
3745
}
3846
}

Views/.DS_Store

6 KB
Binary file not shown.

Views/Home/About.cshtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
ViewData["Title"] = "About";
33
}
44

5-
<div class="p-16 bg-grey-100 dark:bg-black min-h-screen">
5+
<div class="p-16 bg-grey-100 dark:bg-dark min-h-screen">
66
<p class="dark:text-white font-bold text-2xl md:text-6xl">About Our Website</p>
77
<p>This is about our new CMS system</p>
88

@@ -11,9 +11,9 @@
1111
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 lg:grid-cols-7 gap-8 mt-4">
1212
@for (int i = 0; i < 10; i++)
1313
{
14-
<p class="p-4 bg-gray-100 rounded-lg shadow-xl">Helglo World @(i*10)</p>
14+
<p class="p-4 bg-gray-100 rounded-lg shadow-xl">Hello World @(i*10)</p>
1515
}
16-
</div>
16+
</div
1717

1818
<div class="mt-4">
1919
<a class="btn btn-sm md:btn-md xl:btn-lg btn-neutral btn-outline">Privacy</a>

Views/Home/Index.cshtml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,23 @@
22
ViewData["Title"] = "Home Page";
33
}
44

5-
<div class="text-center">
6-
<h1 class="display-4">Welcome</h1>
7-
<p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
8-
</div>
5+
<div class="flex flex-col px-10 bg-grey-100 min-h-screen">
6+
<p class="dark:text-white font-bold text-2xl md:text-6xl text-center pb-10">@ViewBag.Greeting, &nbsp; @ViewBag.User</p>
7+
<p id="clock" class="dark:text-white text-1xl md:text-3xl text-center pb-10"></p>
8+
9+
10+
</div>
11+
12+
13+
<script>
14+
function updateClock() {
15+
const now = new Date();
16+
const hours = now.getHours().toString().padStart(2, '0');
17+
const minutes = now.getMinutes().toString().padStart(2, '0');
18+
const seconds = now.getSeconds().toString().padStart(2, '0');
19+
document.getElementById('clock').textContent = `${hours}:${minutes}:${seconds}`;
20+
}
21+
22+
setInterval(updateClock, 1000);
23+
updateClock(); // Call it once to set the clock immediately
24+
</script>

0 commit comments

Comments
 (0)