initial
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
@page
|
||||
@model _2021_backend.Pages.Students.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="Student.Name" class="control-label"></label>
|
||||
<input asp-for="Student.Name" class="form-control" />
|
||||
<span asp-validation-for="Student.Name" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Student.Stuid" class="control-label"></label>
|
||||
<input asp-for="Student.Stuid" class="form-control" />
|
||||
<span asp-validation-for="Student.Stuid" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Student.Sex" class="control-label"></label>
|
||||
<select asp-for="Student.Sex" class="form-control" asp-items="@Html.GetEnumSelectList(typeof(_2021_backend.Models.sex))"></select>
|
||||
<span asp-validation-for="Student.Sex" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Student.Yard" class="control-label"></label>
|
||||
<select asp-for="Student.Yard" class="form-control" asp-items="@Html.GetEnumSelectList(typeof(_2021_backend.Models.yard))"></select>
|
||||
<span asp-validation-for="Student.Yard" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Student.Grade" class="control-label"></label>
|
||||
<select asp-for="Student.Grade" class="form-control" asp-items="@Html.GetEnumSelectList(typeof(_2021_backend.Models.grade))"></select>
|
||||
<span asp-validation-for="Student.Grade" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Student.Major" class="control-label"></label>
|
||||
<input asp-for="Student.Major" class="form-control" />
|
||||
<span asp-validation-for="Student.Major" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Student.Email" class="control-label"></label>
|
||||
<input asp-for="Student.Email" class="form-control" />
|
||||
<span asp-validation-for="Student.Email" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Student.Tel" class="control-label"></label>
|
||||
<input asp-for="Student.Tel" class="form-control" />
|
||||
<span asp-validation-for="Student.Tel" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Student.Status" class="control-label"></label>
|
||||
<select asp-for="Student.Status" class="form-control" asp-items="@Html.GetEnumSelectList(typeof(_2021_backend.Models.status))"></select>
|
||||
<span asp-validation-for="Student.Status" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Student.RegisterTime" class="control-label"></label>
|
||||
<input asp-for="Student.RegisterTime" class="form-control" />
|
||||
<span asp-validation-for="Student.RegisterTime" 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,48 @@
|
||||
using _2021_backend.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _2021_backend.Pages.Students
|
||||
{
|
||||
public class CreateModel : PageModel
|
||||
{
|
||||
private readonly _2021_backend.Data.BackendContext Context;
|
||||
|
||||
public CreateModel(_2021_backend.Data.BackendContext context)
|
||||
{
|
||||
Context = context;
|
||||
}
|
||||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
Student = new Student();
|
||||
return Page();
|
||||
}
|
||||
|
||||
|
||||
|
||||
[BindProperty]
|
||||
[Required(ErrorMessage = "该项不能为空")]
|
||||
public Student Student { get; set; }
|
||||
|
||||
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
if (Context.Students.Any(t => (t.Name == Student.Name || t.Stuid == Student.Stuid || t.Tel == Student.Tel)))
|
||||
{
|
||||
return RedirectToPage("./Index", new { pageId = 0, errInfo = "该学生已经存在" });
|
||||
}
|
||||
Context.Students.Add(Student);
|
||||
await Context.SaveChangesAsync();
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
@page
|
||||
@model _2021_backend.Pages.Students.DeleteModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
}
|
||||
|
||||
<h1>删除</h1>
|
||||
|
||||
<h3>你确定要删除该项目吗?</h3>
|
||||
<div>
|
||||
<h4>学生</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Student.Name)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Student.Name)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Student.Stuid)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Student.Stuid)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Student.Sex)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Student.Sex)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Student.Grade)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Student.Grade)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Student.Major)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Student.Major)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Student.Email)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Student.Email)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Student.Tel)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Student.Tel)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Student.Status)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Student.Status)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Student.LastSubmission)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Student.LastSubmission)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Student.RegisterTime)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Student.RegisterTime)
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="Student.Guid" />
|
||||
<input type="submit" value="删除" class="btn btn-danger" /> |
|
||||
<a asp-page="./Index">返回列表</a>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,67 @@
|
||||
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.Students
|
||||
{
|
||||
public class DeleteModel : PageModel
|
||||
{
|
||||
private readonly _2021_backend.Data.BackendContext Context;
|
||||
|
||||
public DeleteModel(_2021_backend.Data.BackendContext context)
|
||||
{
|
||||
Context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public Student Student { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(string? idstr)
|
||||
{
|
||||
if (idstr == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
Guid id = Guid.Parse(idstr);
|
||||
|
||||
Student = await Context.Students.FirstOrDefaultAsync(m => m.Guid == id);
|
||||
|
||||
if (Student == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync(string? idstr)
|
||||
{
|
||||
if (idstr == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
Guid id = Guid.Parse(idstr);
|
||||
|
||||
Student = await Context.Students.FindAsync(id);
|
||||
|
||||
if (Student != null)
|
||||
{
|
||||
var q = from e in Context.Sessions where e.Students.Contains(id) select e;
|
||||
var lst = q.ToList();
|
||||
foreach(var it in lst)
|
||||
{
|
||||
it.Students.RemoveAll(k => k == id);
|
||||
}
|
||||
Context.Students.Remove(Student);
|
||||
Context.SaveChanges();
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,370 @@
|
||||
@page
|
||||
@model _2021_backend.Pages.Students.DetailsModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Details";
|
||||
}
|
||||
|
||||
<h1>@Html.DisplayFor(model=> Model.Student.Name)</h1>
|
||||
|
||||
<div>
|
||||
<h4>详细信息</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Student.Name)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Student.Name)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Student.Stuid)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Student.Stuid)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Student.Sex)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Student.Sex)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Student.Grade)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Student.Grade)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Student.Major)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Student.Major)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Student.Email)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Student.Email)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Student.Tel)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Student.Tel)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Student.Status)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Student.Status)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Student.RegisterTime)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Student.RegisterTime)
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<h5>此人的最终得分 : @Html.DisplayFor(model => model.Student.Score)</h5>
|
||||
<form method="post" class="form-inline m-2">
|
||||
<input type="hidden" asp-for="Student.Guid" />
|
||||
<div class="mb-2">
|
||||
操作
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<input type="submit" value="通过" class="btn btn-info" style="margin:5px" asp-page-handler="Accept" />
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<input type="submit" value="拒绝" class="btn btn-danger" style="margin:5px" asp-page-handler="Reject" />
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
给他打分
|
||||
<input asp-for="score" class="form-control"/>
|
||||
<input type="submit" value="打" class="btn btn-warning" style="margin:5px" asp-page-handler="Rank" />
|
||||
</div>
|
||||
</form>
|
||||
<br />
|
||||
|
||||
<h4>
|
||||
看看大家怎么说
|
||||
</h4>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> @Html.DisplayNameFor(model => model.CommentSample.Operator)</th>
|
||||
<th> @Html.DisplayNameFor(model => model.CommentSample.Content)</th>
|
||||
<th> @Html.DisplayNameFor(model => model.CommentSample.AddTime)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var cmt in Model.CurComments)
|
||||
{
|
||||
<tr>
|
||||
@{
|
||||
var usr = Model.Context.Users.Find(cmt.Operator);
|
||||
<td>
|
||||
@Html.DisplayFor(model => usr.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(model => cmt.Content)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(model => cmt.AddTime)
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h4>
|
||||
添加评论
|
||||
</h4>
|
||||
<form method="post">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<textarea asp-for="NewComment" class="form-control" rows="5"></textarea>
|
||||
<span asp-validation-for="NewComment" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="hidden" asp-for="Student.Guid" />
|
||||
<input type="submit" value="→" class="btn btn-primary btn-sm" />
|
||||
</div>
|
||||
</form>
|
||||
<br />
|
||||
|
||||
<h4>
|
||||
场次
|
||||
</h4>
|
||||
|
||||
<h4>
|
||||
最终场次 : @{
|
||||
if (Model.Interviewtime == null)
|
||||
{
|
||||
<div class="text-danger">尚未确定活动场次</div>
|
||||
<hr />
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="text-info">
|
||||
@{
|
||||
var val = Model.Interviewtime.Place + " " + Model.Interviewtime.Day.ToString("MM月dd日") + " " + Model.Interviewtime.BeginTime.ToString("hh:mm");
|
||||
@Html.DisplayFor(model => val)
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</h4>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr >
|
||||
<th>地点</th>
|
||||
<th>日期</th>
|
||||
<th>时间</th>
|
||||
<th>总容量</th>
|
||||
<th>剩余人数</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (int i = 0; i < Model.Student.Timelist.Count; i++)
|
||||
{
|
||||
var it = Model.Student.Timelist[i];
|
||||
var dt = Model.Context.Sessions.Find(it);
|
||||
if (dt.Capacity > dt.Students.Count || dt.Students.Contains(Model.Student.Guid))
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@{
|
||||
|
||||
@Html.DisplayFor(model => dt.Place)
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@{
|
||||
var s1 = dt.Day.ToString("MM-dd");
|
||||
@Html.DisplayFor(model => s1)
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@{
|
||||
var s2 = dt.BeginTime.ToString("hh-mm");
|
||||
@Html.DisplayFor(model => s2)
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@{
|
||||
var s4 = dt.Capacity.ToString();
|
||||
@Html.DisplayFor(model => s4)
|
||||
}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
@{
|
||||
var num = (dt.Capacity - dt.Students.Count()).ToString();
|
||||
@Html.DisplayFor(model => num)
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
<form method="post" class="form-inline">
|
||||
<input type="hidden" asp-for="Student.Guid" />
|
||||
<a asp-page="/Sessions/Edit" asp-route-id="@it.ToString()" class="btn btn-sm btn-primary">场次详情</a>
|
||||
<input type="submit" asp-page-handler="Select" asp-route-stu="@Model.Student.Guid" asp-route-time="@it.ToString()" class="btn btn-sm btn-warning" value="选择这个" />
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<h4>
|
||||
Ta的短信
|
||||
</h4>
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="Student.Guid" />
|
||||
<input type="submit" value="拉取5天内的回复短信" class="btn btn-primary" asp-page-handler="Pull" />
|
||||
<input type="submit" value="发送报名确认短信" class="btn btn-primary" asp-page-handler="Sign" />
|
||||
<input type="submit" value="发送活动场次确认短信" class="btn btn-primary" asp-page-handler="Time" />
|
||||
<input type="submit" value="发送活动结果短信" class="btn btn-primary" asp-page-handler="Result" />
|
||||
</form>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
发送时间
|
||||
</th>
|
||||
<th>
|
||||
短信类型
|
||||
</th>
|
||||
<th>
|
||||
短信内容
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var msg in Model.Messages)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@{
|
||||
var str = msg.SendTime.ToString("MM-dd hh:mm:ss");
|
||||
@Html.DisplayFor(it => str)
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@{
|
||||
var s = Enum.GetName(typeof(_2021_backend.Models.SMSType), msg.Type);
|
||||
@Html.DisplayFor(it=> s)
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@{
|
||||
string s2 = "";
|
||||
foreach (var e in msg.Data)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(e)) s2 += " " + e;
|
||||
}
|
||||
@Html.DisplayFor(it => s2)
|
||||
}
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
<h4>
|
||||
Ta的提交记录
|
||||
</h4>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.SubmissionSample.Name)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.SubmissionSample.Stuid)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.SubmissionSample.Sex)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.SubmissionSample.Yard)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.SubmissionSample.Grade)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.SubmissionSample.Major)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.SubmissionSample.Email)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.SubmissionSample.Tel)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.SubmissionSample.Address)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.SubmissionSample.SubmitTime)
|
||||
</th>
|
||||
<th>
|
||||
Operation
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.Student.Submissions)
|
||||
{
|
||||
var sub = Model.Context.Submissions.Find(item);
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => sub.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => sub.Stuid)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => sub.Sex)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => sub.Yard)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => sub.Grade)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => sub.Major)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => sub.Email)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => sub.Tel)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => sub.Address)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => sub.SubmitTime)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="/Submissions/Edit" asp-route-strid="@sub.Guid">Edit</a> |
|
||||
<a asp-page="/Submissions/Details" asp-route-strid="@sub.Guid">Details</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
<div>
|
||||
<a asp-page="./Edit" asp-route-idstr="@Model.Student.Guid">编辑信息</a> |
|
||||
<a asp-page="./Index">返回列表</a>
|
||||
</div>
|
||||
@@ -0,0 +1,204 @@
|
||||
using _2021_backend.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace _2021_backend.Pages.Students
|
||||
{
|
||||
public class DetailsModel : PageModel
|
||||
{
|
||||
public _2021_backend.Data.BackendContext Context;
|
||||
|
||||
public DetailsModel(_2021_backend.Data.BackendContext context)
|
||||
{
|
||||
Context = context;
|
||||
}
|
||||
[BindProperty]
|
||||
public Student Student { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public int score { get; set; }
|
||||
public List<Session> Sessions { get; set; }
|
||||
|
||||
public List<Submission> Submissions { get; set; }
|
||||
|
||||
public List<Comment> CurComments { get; set; }
|
||||
public Session Interviewtime { get; set; }
|
||||
public Comment CommentSample { get; set; }
|
||||
public Submission SubmissionSample { get; set; }
|
||||
[Display(Name = "评论内容")]
|
||||
[BindProperty]
|
||||
[Required(ErrorMessage = "该项不能为空")]
|
||||
public string NewComment { get; set; }
|
||||
|
||||
public List<SMS> Messages { get; set; }
|
||||
|
||||
public IActionResult Construct(string? idstr)
|
||||
{
|
||||
if (idstr == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
Guid id = Guid.Parse(idstr);
|
||||
Student = Context.Students.Find(id);
|
||||
if (Student == null)
|
||||
{
|
||||
Console.WriteLine("Student not found.");
|
||||
return NotFound();
|
||||
}
|
||||
Sessions = new List<Session>();
|
||||
Submissions = new List<Submission>();
|
||||
Interviewtime = Context.Sessions.Find(Student.InterviewTime);
|
||||
foreach (var it in Student.Timelist)
|
||||
{
|
||||
var tm = Context.Sessions.Find(it);
|
||||
if (tm == null) Console.WriteLine("null encountered in timelist!");
|
||||
Sessions.Add(tm);
|
||||
}
|
||||
Messages = Context.SMS.Where(it => it.Host == id).ToList();
|
||||
CurComments = Context.Comments.Where(cmt => cmt.Student == Student.Guid).ToList();
|
||||
Sessions.Sort((Session a, Session b) => {
|
||||
var x = a.Day.CompareTo(b.Day);
|
||||
var y = a.BeginTime.CompareTo(b.BeginTime);
|
||||
var z = a.Place.CompareTo(b.Place);
|
||||
return (x != 0 ? x : y != 0 ? y : z != 0 ? z : 0);
|
||||
|
||||
});
|
||||
Console.WriteLine("Page construction finished.");
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(string? idstr)
|
||||
{
|
||||
Console.WriteLine("getting student " + idstr);
|
||||
return Construct(idstr);
|
||||
}
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(NewComment))
|
||||
{
|
||||
var cmt = new Comment();
|
||||
cmt.Student = Student.Guid;
|
||||
cmt.Content = NewComment;
|
||||
cmt.Operator = Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value);
|
||||
var stu = Context.Students.Find(Student.Guid);
|
||||
stu.Comments.Add(cmt.Guid);
|
||||
Context.Comments.Add(cmt);
|
||||
Context.SaveChanges();
|
||||
}
|
||||
Construct(Student.Guid.ToString());
|
||||
return RedirectToPage(new { idstr = Student.Guid.ToString() });
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAcceptAsync()
|
||||
{
|
||||
Student = Context.Students.Find(Student.Guid);
|
||||
Student.Status = status.通过;
|
||||
Context.SaveChanges();
|
||||
CurComments = Context.Comments.Where(cmt => cmt.Student == Student.Guid).ToList();
|
||||
Messages = Context.SMS.Where(it => it.Host == Student.Guid).ToList();
|
||||
Construct(Student.Guid.ToString());
|
||||
return RedirectToPage(new { idstr = Student.Guid.ToString() });
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<IActionResult> OnPostRejectAsync()
|
||||
{
|
||||
Student = Context.Students.Find(Student.Guid);
|
||||
Student.Status = status.不通过;
|
||||
Context.SaveChanges();
|
||||
Student.Score = 0;
|
||||
CurComments = Context.Comments.Where(cmt => cmt.Student == Student.Guid).ToList();
|
||||
Messages = Context.SMS.Where(it => it.Host == Student.Guid).ToList();
|
||||
Construct(Student.Guid.ToString());
|
||||
return RedirectToPage(new { idstr = Student.Guid.ToString() });
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostSelectAsync(Guid stu, Guid time)
|
||||
{
|
||||
var st = Context.Students.Find(stu);
|
||||
if (st != null)
|
||||
{
|
||||
|
||||
if (Context.Sessions.Any(it => it.Guid == time))
|
||||
{
|
||||
var tm = Context.Sessions.Find(time);
|
||||
if (tm.Students.Count < tm.Capacity)
|
||||
{
|
||||
if (st.InterviewTime != Guid.Empty)
|
||||
{
|
||||
var tmold = Context.Sessions.Find(st.InterviewTime);
|
||||
if (tmold != null)
|
||||
{
|
||||
tmold.Students.RemoveAll(it => it == st.Guid);
|
||||
Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
tm.Students.Add(stu);
|
||||
st.InterviewTime = time;
|
||||
if (st.Status != status.不通过 && st.Status != status.通过) st.Status = status.已选时间;
|
||||
Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Construct(Student.Guid.ToString());
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostPullAsync()
|
||||
{
|
||||
await Utils.TencentSMS.Pull(Context, Context.Students.Find(Student.Guid), true);
|
||||
return Construct(Student.Guid.ToString());
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostRankAsync()
|
||||
{
|
||||
var s = Context.Students.Find(Student.Guid);
|
||||
s.Score = score;
|
||||
s.Status = status.已评分;
|
||||
Context.SaveChanges();
|
||||
return Construct(Student.Guid.ToString());
|
||||
}
|
||||
|
||||
|
||||
public async Task<IActionResult> OnPostResultAsync()
|
||||
{
|
||||
var stu = Context.Students.Find(Student.Guid);
|
||||
if (stu.Status == status.通过)
|
||||
await Utils.TencentSMS.Send(Context, SMSType.Accept, stu, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
else if (stu.Status == status.不通过)
|
||||
await Utils.TencentSMS.Send(Context, SMSType.Reject, stu, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
return Construct(Student.Guid.ToString());
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostSignAsync()
|
||||
{
|
||||
var stu = Context.Students.Find(Student.Guid);
|
||||
await Utils.TencentSMS.Send(Context, SMSType.Signed, stu, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
return Construct(Student.Guid.ToString());
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostSelectTimeAsync()
|
||||
{
|
||||
var stu = Context.Students.Find(Student.Guid);
|
||||
await Utils.TencentSMS.Send(Context, SMSType.TimeSelect, stu, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
stu.Status = status.需调整时间;
|
||||
return Construct(Student.Guid.ToString());
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostTimeAsync()
|
||||
{
|
||||
var stu = Context.Students.Find(Student.Guid);
|
||||
await Utils.TencentSMS.Send(Context, SMSType.TimeSet, stu, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name);
|
||||
stu.Status = status.已确认时间;
|
||||
Context.SaveChanges();
|
||||
return Construct(Student.Guid.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
@page
|
||||
@model _2021_backend.Pages.Students.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="Student.Guid" />
|
||||
<div class="form-group">
|
||||
<label asp-for="Student.Name" class="control-label"></label>
|
||||
<input asp-for="Student.Name" class="form-control" />
|
||||
<span asp-validation-for="Student.Name" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Student.Stuid" class="control-label"></label>
|
||||
<input asp-for="Student.Stuid" class="form-control" />
|
||||
<span asp-validation-for="Student.Stuid" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Student.Sex" class="control-label"></label>
|
||||
<select asp-for="Student.Sex" class="form-control" asp-items="@Html.GetEnumSelectList(typeof(_2021_backend.Models.sex))"></select>
|
||||
<span asp-validation-for="Student.Sex" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Student.Yard" class="control-label"></label>
|
||||
<select asp-for="Student.Yard" class="form-control" asp-items="@Html.GetEnumSelectList(typeof(_2021_backend.Models.yard))"></select>
|
||||
<span asp-validation-for="Student.Yard" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Student.Grade" class="control-label"></label>
|
||||
<select asp-for="Student.Grade" class="form-control" asp-items="@Html.GetEnumSelectList(typeof(_2021_backend.Models.grade))"></select>
|
||||
<span asp-validation-for="Student.Grade" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Student.Major" class="control-label"></label>
|
||||
<input asp-for="Student.Major" class="form-control" />
|
||||
<span asp-validation-for="Student.Major" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Student.Email" class="control-label"></label>
|
||||
<input asp-for="Student.Email" class="form-control" />
|
||||
<span asp-validation-for="Student.Email" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Student.Tel" class="control-label"></label>
|
||||
<input asp-for="Student.Tel" class="form-control" />
|
||||
<span asp-validation-for="Student.Tel" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Student.RegisterTime" class="control-label"></label>
|
||||
<input asp-for="Student.RegisterTime" class="form-control" />
|
||||
<span asp-validation-for="Student.RegisterTime" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Student.Status" class="control-label"></label>
|
||||
<select asp-for="Student.Status" class="form-control" asp-items="@Html.GetEnumSelectList(typeof(_2021_backend.Models.status))"></select>
|
||||
<span asp-validation-for="Student.Status" 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,61 @@
|
||||
using _2021_backend.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _2021_backend.Pages.Students
|
||||
{
|
||||
public class EditModel : PageModel
|
||||
{
|
||||
public readonly _2021_backend.Data.BackendContext Context;
|
||||
|
||||
public EditModel(_2021_backend.Data.BackendContext context)
|
||||
{
|
||||
Context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public Student Student { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(string? idstr)
|
||||
{
|
||||
if (idstr == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
Guid id = Guid.Parse(idstr);
|
||||
Student = await Context.Students.AsNoTracking().FirstOrDefaultAsync(m => m.Guid == id);
|
||||
|
||||
if (Student == 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()
|
||||
{
|
||||
var stu = Context.Students.Find(Student.Guid);
|
||||
stu.Status = Student.Status;
|
||||
stu.Email = Student.Email;
|
||||
stu.Name = Student.Name;
|
||||
stu.Stuid = Student.Stuid;
|
||||
stu.Tel = Student.Tel;
|
||||
stu.Grade = Student.Grade;
|
||||
stu.Sex = Student.Sex;
|
||||
stu.Yard = Student.Yard;
|
||||
Context.SaveChanges();
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
|
||||
private bool StudentExists(Guid id)
|
||||
{
|
||||
return Context.Students.Any(e => e.Guid == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
@page
|
||||
@model _2021_backend.Pages.Students.IndexModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
}
|
||||
|
||||
<h1>报了名的xpy们</h1>
|
||||
|
||||
<p>
|
||||
<a asp-page="Create">手动添加一个</a>
|
||||
</p>
|
||||
<h5 class="text-red">
|
||||
<strong>@Html.DisplayFor(model => Model.errmsg)</strong>
|
||||
</h5>
|
||||
<form class="form-inline m-2" method="post">
|
||||
<div class="form-group mx-sm-0 m-2">
|
||||
<input type="text" class="form-control" id="searchString" placeholder="输入部分学号或姓名" asp-for="SearchString" name="SearchString">
|
||||
</div>
|
||||
<div class="form-group mx-sm-0 m-2">
|
||||
<input type="text" class="form-control" id="SearchTel" placeholder="电话号码" asp-for="SearchTel" name="SearchTel">
|
||||
</div>
|
||||
<div class="form-group mx-sm-0 m-2">
|
||||
<input type="text" class="form-control" id="SearchQQ" placeholder="QQ号码" asp-for="SearchQQ" name="SearchQQ">
|
||||
</div>
|
||||
<div class="m-2">
|
||||
年级
|
||||
<select asp-for="Grade" asp-items="@Html.GetEnumSelectList(typeof(_2021_backend.Models.grade))" class="form-control">
|
||||
</select>
|
||||
</div>
|
||||
<div class="m-2">
|
||||
状态
|
||||
<select asp-for="StatusSel" asp-items="@Html.GetEnumSelectList(typeof(_2021_backend.Models.status))" class="form-control">
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-outline-primary m-2">搜索</button>
|
||||
</form>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Index
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Student[0].Name)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Student[0].Stuid)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Student[0].Sex)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Student[0].Yard)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Student[0].Grade)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Student[0].Major)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Student[0].Status)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Student[0].Exp)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Student[0].Score)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Student[0].RegisterTime)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@{
|
||||
var n = 0;
|
||||
@foreach (var item in Model.Student)
|
||||
{
|
||||
n++;
|
||||
<tr class="@{
|
||||
switch(item.Status){
|
||||
case _2021_backend.Models.status.不通过:
|
||||
@("table-danger")
|
||||
break;
|
||||
case _2021_backend.Models.status.通过:
|
||||
@("table-success")
|
||||
break;
|
||||
case _2021_backend.Models.status.刚报名:
|
||||
@("")
|
||||
break;
|
||||
case _2021_backend.Models.status.已评分:
|
||||
@("table-primary")
|
||||
break;
|
||||
}
|
||||
}">
|
||||
<td>
|
||||
@{
|
||||
var s = (Model.PageId * IndexModel.PageSize + n).ToString();
|
||||
@Html.DisplayFor(it => s)
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="./Details" asp-route-idstr="@item.Guid.ToString()"> @Html.DisplayFor(modelItem => item.Name)</a>
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="./Details" asp-route-idstr="@item.Guid.ToString()"> @Html.DisplayFor(modelItem => item.Stuid)</a>
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Sex)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Yard)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Grade)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Major)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Status)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Exp)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Score)
|
||||
</td>
|
||||
<th>
|
||||
@Html.DisplayFor(modelItem => item.RegisterTime)
|
||||
</th>
|
||||
<td>
|
||||
<a asp-page="./Edit" asp-route-idstr="@item.Guid.ToString()">编辑资料</a> |
|
||||
<a asp-page="./Details" asp-route-idstr="@item.Guid.ToString()">审阅</a> |
|
||||
<a asp-page="./Delete" asp-route-idstr="@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) " asp-route-Grade="@Model.Grade" asp-route-SearchString="@Model.SearchString" asp-route-StatusSel="@Model.StatusSel" asp-route-SearchQQ="@Model.SearchQQ">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" asp-route-Grade="@Model.Grade" asp-route-SearchString="@Model.SearchString" asp-route-StatusSel="@Model.StatusSel" asp-route-SearchQQ="@Model.SearchQQ">@i</a></li>
|
||||
}
|
||||
<li class="page-item @(Model.PageId>=Model.PageCount -1? "disabled" : "")"><a class="page-link" asp-route-pageId="@(Model.PageId+1)" asp-route-Grade="@Model.Grade" asp-route-SearchString="@Model.SearchString" asp-route-StatusSel="@Model.StatusSel" asp-route-SearchQQ="@Model.SearchQQ">Next</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
@@ -0,0 +1,97 @@
|
||||
using _2021_backend.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.IO.Compression;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using _2021_backend.Utils;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _2021_backend.Pages.Students
|
||||
{
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly _2021_backend.Data.BackendContext Context;
|
||||
public static int PageSize { get; set; }
|
||||
public int PageCount { get; set; }
|
||||
public int PageId { get; set; }
|
||||
public string errmsg { get; set; }
|
||||
|
||||
[BindProperty(SupportsGet = true)]
|
||||
public string SearchString { get; set; }
|
||||
[BindProperty(SupportsGet = true)]
|
||||
public grade Grade { get; set; }
|
||||
|
||||
[BindProperty(SupportsGet = true)]
|
||||
public string SearchQQ { get; set; }
|
||||
|
||||
[BindProperty(SupportsGet = true)]
|
||||
public string SearchTel { get; set; }
|
||||
|
||||
[BindProperty(SupportsGet = true)]
|
||||
public status StatusSel { get; set; } = status.暂缺;
|
||||
|
||||
|
||||
|
||||
public IndexModel(_2021_backend.Data.BackendContext context)
|
||||
{
|
||||
Context = context;
|
||||
}
|
||||
|
||||
public List<Student> Student { get; set; }
|
||||
public IActionResult Construct(int pageId, string errInfo)
|
||||
{
|
||||
PageSize = 30;
|
||||
if (string.IsNullOrEmpty(errInfo))
|
||||
{
|
||||
errmsg = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
errmsg = errInfo;
|
||||
}
|
||||
if (pageId == null) pageId = 0;
|
||||
IQueryable<Student> q;
|
||||
if (!string.IsNullOrEmpty(SearchString))
|
||||
{
|
||||
q = Context.Students.Where(s => (s.Name.Contains(SearchString) || s.Stuid.Contains(SearchString)));
|
||||
}
|
||||
else
|
||||
{
|
||||
q = Context.Students;
|
||||
}
|
||||
if (Grade != grade.暂缺) q = q.Where(it => it.Grade == Grade);
|
||||
if (StatusSel != status.暂缺) q = q.Where(it => it.Status == StatusSel);
|
||||
if (!String.IsNullOrEmpty(SearchTel)) q = q.Where(it => it.Tel.Contains(SearchTel));
|
||||
if (!String.IsNullOrEmpty(SearchQQ)) q = q.Where(it => it.Email.Contains(SearchQQ));
|
||||
Student = q.ToList();
|
||||
|
||||
Student.Sort((Student a, Student b) =>
|
||||
{
|
||||
return -a.RegisterTime.CompareTo(b.RegisterTime);
|
||||
});
|
||||
int cnt = Student.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;
|
||||
Student = Student.GetRange(PageId * PageSize, count);
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? pageId, string errInfo)
|
||||
{
|
||||
if (pageId == null) pageId = 0;
|
||||
return Construct((int)pageId, errInfo);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync(int? pageId, string errInfo)
|
||||
{
|
||||
if (pageId == null) pageId = 0;
|
||||
return Construct((int)pageId, errInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user