initial
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
@page
|
||||
@model _2021_backend.Pages.Submissions.CreateModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
}
|
||||
|
||||
<h1>创建</h1>
|
||||
|
||||
<h4>提交记录</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form method="post">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Submission.Name" class="control-label"></label>
|
||||
<input asp-for="Submission.Name" class="form-control" />
|
||||
<span asp-validation-for="Submission.Name" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Submission.Stuid" class="control-label"></label>
|
||||
<input asp-for="Submission.Stuid" class="form-control" />
|
||||
<span asp-validation-for="Submission.Stuid" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Submission.Sex" class="control-label"></label>
|
||||
<select asp-for="Submission.Sex" class="form-control" asp-items="@Html.GetEnumSelectList(typeof(_2021_backend.Models.sex))"></select>
|
||||
<span asp-validation-for="Submission.Sex" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Submission.Yard" class="control-label"></label>
|
||||
<select asp-for="Submission.Yard" class="form-control" asp-items="@Html.GetEnumSelectList(typeof(_2021_backend.Models.yard))"></select>
|
||||
<span asp-validation-for="Submission.Yard" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Submission.Grade" class="control-label"></label>
|
||||
<select asp-for="Submission.Grade" class="form-control" asp-items="@Html.GetEnumSelectList(typeof(_2021_backend.Models.grade))"></select>
|
||||
<span asp-validation-for="Submission.Grade" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Submission.Major" class="control-label"></label>
|
||||
<input asp-for="Submission.Major" class="form-control" />
|
||||
<span asp-validation-for="Submission.Major" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Submission.Email" class="control-label"></label>
|
||||
<input asp-for="Submission.Email" class="form-control" />
|
||||
<span asp-validation-for="Submission.Email" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Submission.Tel" class="control-label"></label>
|
||||
<input asp-for="Submission.Tel" class="form-control" />
|
||||
<span asp-validation-for="Submission.Tel" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Submission.Address" class="control-label"></label>
|
||||
<input asp-for="Submission.Address" class="form-control" />
|
||||
<span asp-validation-for="Submission.Address" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Create" class="btn btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a asp-page="Index">返回列表</a>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using _2021_backend.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _2021_backend.Pages.Submissions
|
||||
{
|
||||
public class CreateModel : PageModel
|
||||
{
|
||||
private readonly _2021_backend.Data.BackendContext Context;
|
||||
|
||||
public CreateModel(_2021_backend.Data.BackendContext context)
|
||||
{
|
||||
Context = context;
|
||||
}
|
||||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
Submission = new Submission();
|
||||
return Page();
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public Submission Submission { get; set; }
|
||||
|
||||
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
var q = Context.Students.Where(stu => (stu.Name == Submission.Name || stu.Tel == Submission.Tel || stu.Stuid == Submission.Stuid));
|
||||
Student stu;
|
||||
if (q.Count() == 0)
|
||||
{
|
||||
stu = Student.create(Submission);
|
||||
stu.Status = status.刚报名;
|
||||
var q2 = from e in Context.Sessions select e.Guid;
|
||||
var lst = q2.ToList();
|
||||
stu.Timelist = lst;
|
||||
Context.Students.Add(stu);
|
||||
}
|
||||
else
|
||||
{
|
||||
stu = q.FirstOrDefault();
|
||||
stu.Update(Submission);
|
||||
}
|
||||
Submission.Host = stu.Guid;
|
||||
Context.Submissions.Add(Submission);
|
||||
Context.SaveChanges();
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
@page
|
||||
@model _2021_backend.Pages.Submissions.DeleteModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
}
|
||||
|
||||
<h1>删除</h1>
|
||||
|
||||
<h3>你确定要删除该项目吗?</h3>
|
||||
<div>
|
||||
<h4>提交记录</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Submission.Name)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Submission.Name)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Submission.Stuid)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Submission.Stuid)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Submission.Sex)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Submission.Sex)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Submission.Grade)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Submission.Grade)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Submission.Major)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Submission.Major)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Submission.Email)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Submission.Email)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Submission.Tel)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Submission.Tel)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Submission.Address)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Submission.Address)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Submission.SubmitTime)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Submission.SubmitTime)
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="Submission.Guid" />
|
||||
<input type="submit" value="删除" class="btn btn-danger" asp-route-id="@Model.Submission.Guid.ToString()"/> |
|
||||
<a asp-page="./Index">返回列表</a>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using _2021_backend.Data;
|
||||
using _2021_backend.Models;
|
||||
|
||||
namespace _2021_backend.Pages.Submissions
|
||||
{
|
||||
public class DeleteModel : PageModel
|
||||
{
|
||||
private readonly _2021_backend.Data.BackendContext Context;
|
||||
|
||||
public DeleteModel(_2021_backend.Data.BackendContext context)
|
||||
{
|
||||
Context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public Submission Submission { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(string? strid)
|
||||
{
|
||||
Guid id = Guid.Parse(strid);
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
Submission = Context.Submissions.FirstOrDefault(m => m.Guid == id);
|
||||
|
||||
if (Submission == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync(Guid? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
Submission = Context.Submissions.Find(id);
|
||||
|
||||
if (Submission != null)
|
||||
{
|
||||
var stu = Context.Students.Find(Submission.Host);
|
||||
if (stu != null)
|
||||
{
|
||||
stu.Submissions.Remove(Submission.Guid);
|
||||
}
|
||||
Context.Submissions.Remove(Submission);
|
||||
Context.SaveChanges();
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
@page
|
||||
@model _2021_backend.Pages.Submissions.DetailsModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Details";
|
||||
}
|
||||
|
||||
<h1>Details</h1>
|
||||
|
||||
<div>
|
||||
<h4>Submission</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Submission.Name)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Submission.Name)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Submission.Stuid)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Submission.Stuid)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Submission.Sex)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Submission.Sex)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Submission.Yard)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Submission.Yard)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Submission.Grade)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Submission.Grade)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Submission.Major)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Submission.Major)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Submission.Email)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Submission.Email)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Submission.Tel)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Submission.Tel)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Submission.Address)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Submission.Address)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Submission.SubmitTime)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Submission.SubmitTime)
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
<a asp-page="./Edit" asp-route-id="@Model.Submission.Guid">Edit</a> |
|
||||
<a asp-page="./Index">返回列表</a>
|
||||
</div>
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using _2021_backend.Data;
|
||||
using _2021_backend.Models;
|
||||
|
||||
namespace _2021_backend.Pages.Submissions
|
||||
{
|
||||
public class DetailsModel : PageModel
|
||||
{
|
||||
private readonly _2021_backend.Data.BackendContext _context;
|
||||
|
||||
public DetailsModel(_2021_backend.Data.BackendContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public Submission Submission { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(string? strid)
|
||||
{
|
||||
|
||||
if (strid == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
Guid id = Guid.Parse(strid);
|
||||
Submission = await _context.Submissions.FirstOrDefaultAsync(m => m.Guid == id);
|
||||
|
||||
if (Submission == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
@page
|
||||
@model _2021_backend.Pages.Submissions.EditModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Edit";
|
||||
}
|
||||
|
||||
<h1>编辑详细信息</h1>
|
||||
|
||||
<h4>提交记录</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form method="post">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<input type="hidden" asp-for="Submission.Guid" />
|
||||
<div class="form-group">
|
||||
<label asp-for="Submission.Name" class="control-label"></label>
|
||||
<input asp-for="Submission.Name" class="form-control" />
|
||||
<span asp-validation-for="Submission.Name" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Submission.Stuid" class="control-label"></label>
|
||||
<input asp-for="Submission.Stuid" class="form-control" />
|
||||
<span asp-validation-for="Submission.Stuid" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Submission.Sex" class="control-label"></label>
|
||||
<select asp-for="Submission.Sex" class="form-control" asp-items="@Html.GetEnumSelectList(typeof(_2021_backend.Models.sex))"></select>
|
||||
<span asp-validation-for="Submission.Sex" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Submission.Grade" class="control-label"></label>
|
||||
<select asp-for="Submission.Grade" class="form-control" asp-items="@Html.GetEnumSelectList(typeof(_2021_backend.Models.grade))"></select>
|
||||
<span asp-validation-for="Submission.Grade" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Submission.Major" class="control-label"></label>
|
||||
<input asp-for="Submission.Major" class="form-control" />
|
||||
<span asp-validation-for="Submission.Major" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Submission.Email" class="control-label"></label>
|
||||
<input asp-for="Submission.Email" class="form-control" />
|
||||
<span asp-validation-for="Submission.Email" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Submission.Tel" class="control-label"></label>
|
||||
<input asp-for="Submission.Tel" class="form-control" />
|
||||
<span asp-validation-for="Submission.Tel" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Submission.Address" class="control-label"></label>
|
||||
<input asp-for="Submission.Address" class="form-control" />
|
||||
<span asp-validation-for="Submission.Address" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Submission.SubmitTime" class="control-label"></label>
|
||||
<input asp-for="Submission.SubmitTime" class="form-control" />
|
||||
<span asp-validation-for="Submission.SubmitTime" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Save" class="btn btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a asp-page="./Index">返回列表</a>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using _2021_backend.Data;
|
||||
using _2021_backend.Models;
|
||||
|
||||
namespace _2021_backend.Pages.Submissions
|
||||
{
|
||||
public class EditModel : PageModel
|
||||
{
|
||||
public readonly _2021_backend.Data.BackendContext Context;
|
||||
|
||||
public EditModel(_2021_backend.Data.BackendContext context)
|
||||
{
|
||||
Context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public Submission Submission { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(string? strid)
|
||||
{
|
||||
Guid id = Guid.Parse(strid);
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Submission = await Context.Submissions.FirstOrDefaultAsync(m => m.Guid == id);
|
||||
|
||||
if (Submission == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
|
||||
// To protect from overposting attacks, enable the specific properties you want to bind to.
|
||||
// For more details, see https://aka.ms/RazorPagesCRUD.
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
Context.Attach(Submission).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
await Context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!SubmissionExists(Submission.Guid))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
|
||||
private bool SubmissionExists(Guid id)
|
||||
{
|
||||
return Context.Submissions.Any(e => e.Guid == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
@page
|
||||
@model _2021_backend.Pages.Submissions.IndexModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
}
|
||||
|
||||
<h1>全部提交记录</h1>
|
||||
<p>
|
||||
<a asp-page="Create">Create New</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Submission[0].Name)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Submission[0].Stuid)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Submission[0].Sex)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Submission[0].Grade)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Submission[0].Major)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Submission[0].Email)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Submission[0].Tel)
|
||||
</th>
|
||||
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Submission[0].Address)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Submission[0].SubmitTime)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.Submission)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Stuid)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Sex)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Grade)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Major)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Email)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Tel)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Address)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.SubmitTime)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="./Edit" asp-route-strid="@item.Guid.ToString()">编辑</a> |
|
||||
<a asp-page="./Details" asp-route-strid="@item.Guid.ToString()">详细信息</a> |
|
||||
<a asp-page="./Delete" asp-route-strid="@item.Guid.ToString()">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<nav>
|
||||
<ul class="pagination">
|
||||
<li class="page-item @(Model.PageId==0 ? "disabled" : "")"><a class="page-link" asp-route-pageId="@(Model.PageId-1) ">Prev</a></li>
|
||||
@for (int i = 0; i < Model.PageCount; i++)
|
||||
{
|
||||
<li class="page-item @(Model.PageId==i ? "active" : "")"><a class="page-link" asp-route-pageId="@i">@i</a></li>
|
||||
}
|
||||
<li class="page-item @(Model.PageId>=Model.PageCount -1? "disabled" : "")"><a class="page-link" asp-route-pageId="@(Model.PageId+1)" >Next</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using _2021_backend.Data;
|
||||
using _2021_backend.Models;
|
||||
|
||||
namespace _2021_backend.Pages.Submissions
|
||||
{
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly _2021_backend.Data.BackendContext Context;
|
||||
|
||||
public static int PageSize = 30;
|
||||
public int PageCount { get; set; }
|
||||
public int PageId { get; set; }
|
||||
|
||||
public IndexModel(_2021_backend.Data.BackendContext context)
|
||||
{
|
||||
Context = context;
|
||||
}
|
||||
|
||||
public List<Submission> Submission { get;set; }
|
||||
|
||||
public async Task OnGetAsync(int pageId)
|
||||
{
|
||||
var q = from e in Context.Submissions orderby e.SubmitTime select e;
|
||||
Submission = await q.ToListAsync();
|
||||
Submission.Sort((a,b)=>b.SubmitTime.CompareTo(a.SubmitTime));
|
||||
int cnt = Submission.Count;
|
||||
PageCount = (int)Math.Ceiling((double)cnt / (double)PageSize);
|
||||
if (pageId >= PageCount) pageId = PageCount - 1;
|
||||
if (pageId < 0) pageId = 0;
|
||||
PageId = (int)pageId;
|
||||
int count = (PageId + 1) * PageSize > cnt ? (cnt - PageId * PageSize) : PageSize;
|
||||
Submission = Submission.GetRange(PageId * PageSize, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user