Build flashsharp flashcard app
This commit is contained in:
commit
c97759b04c
69 files changed
+6959
No files matched your search
@@ -0,0 +1,54 @@
|
||||
@page "/courses/{id:long}"
|
||||
@model Courses.DetailsModel
|
||||
@{
|
||||
ViewData["Title"] = Model.Course.Name;
|
||||
var breadcrumb = new BreadcrumbView(
|
||||
[
|
||||
new Crumb("Courses", "/"),
|
||||
new Crumb(Model.Course.Name, null)
|
||||
],
|
||||
[]);
|
||||
}
|
||||
|
||||
<partial name="_Breadcrumb" model="breadcrumb" />
|
||||
|
||||
<section class="fs-page-head">
|
||||
<p class="fs-eyebrow">Course</p>
|
||||
<h1 class="fs-page-title" dir="auto">@Model.Course.Name</h1>
|
||||
@if (!string.IsNullOrWhiteSpace(Model.Course.Description))
|
||||
{
|
||||
<p class="fs-page-description" dir="auto">@Model.Course.Description</p>
|
||||
}
|
||||
</section>
|
||||
|
||||
@if (Model.Lessons.Count == 0)
|
||||
{
|
||||
<section class="fs-empty">
|
||||
<p>No lessons yet. Ask your agent to create one in this course.</p>
|
||||
</section>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="fs-list">
|
||||
@foreach (var lesson in Model.Lessons)
|
||||
{
|
||||
<a class="fs-row" asp-page="/Lessons/Details" asp-route-id="@lesson.Id">
|
||||
<div class="fs-row-main">
|
||||
<h2 class="fs-row-title" dir="auto">@lesson.Name</h2>
|
||||
@if (!string.IsNullOrWhiteSpace(lesson.Description))
|
||||
{
|
||||
<p class="fs-row-subtitle" dir="auto">@Display.Preview(lesson.Description, 140)</p>
|
||||
}
|
||||
</div>
|
||||
<div class="fs-row-meta">
|
||||
<span>@lesson.DeckCount decks</span>
|
||||
<span>@lesson.CardCount cards</span>
|
||||
@if (lesson.DueCount > 0)
|
||||
{
|
||||
<span class="fs-due-pill">@lesson.DueCount due</span>
|
||||
}
|
||||
</div>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Flashsharp.Auth;
|
||||
using Flashsharp.Data;
|
||||
using Flashsharp.Domain;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace Flashsharp.Pages.Courses;
|
||||
|
||||
public sealed class DetailsModel(Store store) : PageModel
|
||||
{
|
||||
public CourseSummary Course { get; private set; } = null!;
|
||||
|
||||
public IReadOnlyList<LessonSummary> Lessons { get; private set; } = [];
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(long id, CancellationToken cancellationToken)
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
var course = await store.GetCourseAsync(id, userId, cancellationToken);
|
||||
if (course is null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Course = course;
|
||||
Lessons = await store.ListLessonsAsync(id, userId, cancellationToken);
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user