removed migration ,altered Guid to int

This commit is contained in:
2022-02-22 17:14:10 +08:00
parent 166821a52e
commit e0115e0e07
48 changed files with 559 additions and 505 deletions
+6 -6
View File
@@ -22,7 +22,7 @@ namespace _2021_backend.Pages.Sessions
[BindProperty]
[Display(Name = "活动官")]
public string ChiefGuid { get; set; }
public string Chiefint { get; set; }
public List<SelectListItem> ChiefList { get; set; }
@@ -34,7 +34,7 @@ namespace _2021_backend.Pages.Sessions
public async Task<IActionResult> OnGet()
{
var qlst = from e in Context.Users select (new SelectListItem { Value = e.Guid.ToString(), Text = e.Name, Selected = false, Disabled = false });
var qlst = from e in Context.Users select (new SelectListItem { Value = e.Id.ToString(), Text = e.Name, Selected = false, Disabled = false });
var lst = qlst.ToList().Distinct().ToList();
ChiefList = lst;
return Page();
@@ -48,8 +48,8 @@ namespace _2021_backend.Pages.Sessions
{
return Page();
}
InterviewTime.Students = new List<Guid>();
InterviewTime.Chiefs = new List<Guid>();
InterviewTime.Students = new List<int>();
InterviewTime.Chiefs = new List<int>();
Session interviewTimeSecond = new Session();
if (CreateTwo)
{
@@ -62,9 +62,9 @@ namespace _2021_backend.Pages.Sessions
Day = InterviewTime.Day,
BeginTime = InterviewTime.BeginTime,
Place = anotherPlace,
Chiefs = new List<Guid>(),
Chiefs = new List<int>(),
SendSMS = InterviewTime.SendSMS,
Students = new List<Guid>(),
Students = new List<int>(),
Capacity = InterviewTime.Capacity
};
Context.Add(interviewTimeSecond);
+1 -1
View File
@@ -34,7 +34,7 @@
</dl>
<form method="post">
<input type="hidden" asp-for="InterviewTime.Guid" />
<input type="hidden" asp-for="InterviewTime.Id" />
<input type="submit" value="确定删除" class="btn btn-danger" /> |
<a asp-page="./Index">Back to List</a>
</form>
+7 -7
View File
@@ -24,13 +24,13 @@ namespace _2021_backend.Pages.Sessions
public async Task<IActionResult> OnGetAsync(string? id)
{
Guid guid = Guid.Parse(id);
int idx = int.Parse(id);
if (id == null)
{
return NotFound();
}
InterviewTime = Context.Sessions.Find(guid);
InterviewTime = Context.Sessions.Find(idx);
if (InterviewTime == null)
{
@@ -41,12 +41,12 @@ namespace _2021_backend.Pages.Sessions
public async Task<IActionResult> OnPostAsync(string? id)
{
Guid guid = Guid.Parse(id);
int idx = int.Parse(id);
if (id == null)
{
return NotFound();
}
InterviewTime = await Context.Sessions.FindAsync(guid);
InterviewTime = await Context.Sessions.FindAsync(idx);
if (InterviewTime != null)
{
@@ -57,15 +57,15 @@ namespace _2021_backend.Pages.Sessions
Student stu = Context.Students.Find(x);
if (stu != null)
{
stu.InterviewTime = Guid.Empty;
stu.Timelist.RemoveAll(it => it == guid);
stu.InterviewTime = 0;
stu.Timelist.RemoveAll(it => it == idx);
}
Context.SaveChanges();
}
}
foreach(var x in Context.Students)
{
x.Timelist.RemoveAll(it => it == guid);
x.Timelist.RemoveAll(it => it == idx);
}
Context.Sessions.Remove(InterviewTime);
Context.SaveChanges();
+1 -1
View File
@@ -64,6 +64,6 @@
</dl>
</div>
<div>
<a asp-page="./Edit" asp-route-id="@Model.CurSession.Guid">Edit</a> |
<a asp-page="./Edit" asp-route-id="@Model.CurSession.Id">Edit</a> |
<a asp-page="./Index">Back to List</a>
</div>
+2 -2
View File
@@ -23,12 +23,12 @@ namespace _2021_backend.Pages.Sessions
public async Task<IActionResult> OnGetAsync(string? id)
{
Guid guid = Guid.Parse(id);
int idx = int.Parse(id);
if (id == null)
{
return NotFound();
}
CurSession = Context.Sessions.Find(guid);
CurSession = Context.Sessions.Find(idx);
if (CurSession == null)
{
return NotFound();
+9 -9
View File
@@ -13,8 +13,8 @@
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="CurSession.Guid" />
<input type="hidden" asp-for="CurGuid">
<input type="hidden" asp-for="CurSession.Id" />
<input type="hidden" asp-for="Curint">
<div class="form-group">
<label asp-for="newDay" class="control-label"></label>
<input asp-for="newDay" class="form-control" />
@@ -51,7 +51,7 @@
<form method="post">
<label class="col-sm-2">添加一个</label>
<select asp-items=Model.Stulist id="stuselect" asp-for="addedStu" class="col-sm-2"></select>
<input type="hidden" asp-for="CurGuid" />
<input type="hidden" asp-for="Curint" />
<input type="submit" value="Go!" class="btn btn-primary" style="margin-left:5px" asp-page-handler="Add" />
</form>
<br />
@@ -76,11 +76,11 @@
<td>@Html.DisplayFor(model=>stu.Name)</td>
<td>
<a asp-page="/Students/Details" asp-route-idstr=@stu.Guid.ToString() class="btn btn-primary">详细信息</a>
<a asp-page="/Students/Details" asp-route-idstr=@stu.Id.ToString() class="btn btn-primary">详细信息</a>
<div style="float:left">
<form method="post">
<input type="hidden" asp-for="CurGuid">
<input type="submit" value="删除" class="btn btn-danger" asp-page-handler="Delete" asp-route-id=@stu.Guid.ToString() />
<input type="hidden" asp-for="Curint">
<input type="submit" value="删除" class="btn btn-danger" asp-page-handler="Delete" asp-route-id=@stu.Id.ToString() />
</form>
</div>
@@ -98,7 +98,7 @@
<form method="post">
<label class="col-sm-2">添加一个</label>
<select id="chiefselect"asp-items=Model.ChiefList asp-for="addedChief" class="col-sm-2"></select>
<input type="hidden" asp-for="CurGuid" />
<input type="hidden" asp-for="Curint" />
<input type="submit" value="Go!" class="btn btn-primary" style="margin-left:5px" asp-page-handler="AddChief" />
</form>
<br />
@@ -121,8 +121,8 @@
<td>
<div style="float:left">
<form method="post">
<input type="hidden" asp-for="CurGuid">
<input type="submit" value="删除" class="btn btn-danger" asp-page-handler="DeleteChief" asp-route-id=@chf.Guid.ToString() />
<input type="hidden" asp-for="Curint">
<input type="submit" value="删除" class="btn btn-danger" asp-page-handler="DeleteChief" asp-route-id=@chf.Id.ToString() />
</form>
</div>
</td>
+33 -33
View File
@@ -24,7 +24,7 @@ namespace _2021_backend.Pages.Sessions
public Session CurSession { get; set; }
[BindProperty]
public string CurGuid { get; set; }
public string Curint { get; set; }
[BindProperty]
public string ChiefSearch { get; set; }
@@ -34,7 +34,7 @@ namespace _2021_backend.Pages.Sessions
public List<SelectListItem> Stulist { get; set; }
[BindProperty]
public Guid addedChief { get; set; }
public int addedChief { get; set; }
[BindProperty]
public string addedStu { get; set; }
@@ -71,13 +71,13 @@ namespace _2021_backend.Pages.Sessions
public IActionResult Construct(string id)
{
Guid guid = Guid.Parse(id);
int idx = int.Parse(id);
if (id == null)
{
return NotFound();
}
CurGuid = id;
CurSession = Context.Sessions.Find(guid);
Curint = id;
CurSession = Context.Sessions.Find(idx);
newDay = CurSession.Day;
newTime = CurSession.BeginTime;
@@ -86,10 +86,10 @@ namespace _2021_backend.Pages.Sessions
newPlace = CurSession.Place;
if (CurSession == null) return RedirectToPage("./Index", new { errmsg = "未找到该活动场次" });
var qlst = from e in Context.Users select (new SelectListItem { Value = e.Guid.ToString(), Text = e.Name, Selected = false, Disabled = false });
var qlst = from e in Context.Users select (new SelectListItem { Value = e.Id.ToString(), Text = e.Name, Selected = false, Disabled = false });
ChiefList = qlst.ToList().Distinct().ToList();
var slst = from e in Context.Students where e.InterviewTime == Guid.Empty select new SelectListItem { Value = e.Guid.ToString(), Text = e.Name, Selected = false, Disabled = false };
var slst = from e in Context.Students where e.InterviewTime == 0 select new SelectListItem { Value = e.Id.ToString(), Text = e.Name, Selected = false, Disabled = false };
Stulist = slst.ToList().Distinct().ToList();
return Page();
}
@@ -103,7 +103,7 @@ namespace _2021_backend.Pages.Sessions
// more details, see https://aka.ms/RazorPagesCRUD.
public async Task<IActionResult> OnPostAsync()
{
var ssn = Context.Sessions.Find(Guid.Parse(CurGuid));
var ssn = Context.Sessions.Find(int.Parse(Curint));
ssn.SendSMS = sendSMS;
ssn.Day = newDay;
ssn.BeginTime = newTime;
@@ -116,73 +116,73 @@ namespace _2021_backend.Pages.Sessions
public async Task<IActionResult> OnPostDeleteAsync(string id)
{
CurSession = Context.Sessions.Find(Guid.Parse(CurGuid));
var guid = Guid.Parse(id);
CurSession = Context.Sessions.Find(int.Parse(Curint));
var idx = int.Parse(id);
if (!string.IsNullOrEmpty(id))
{
if (Context.Students.Any(it => it.Guid == guid))
if (Context.Students.Any(it => it.Id == idx))
{
Context.Students.Find(guid).InterviewTime = Guid.Empty;
CurSession.Students.RemoveAll(it => it == guid);
Context.Students.Find(idx).InterviewTime = 0;
CurSession.Students.RemoveAll(it => it == idx);
}
Context.SaveChanges();
}
return Construct(CurGuid);
return Construct(Curint);
}
public async Task<IActionResult> OnPostAddAsync()
{
CurSession = Context.Sessions.Find(Guid.Parse(CurGuid));
var guid = Guid.Parse(addedStu);
CurSession = Context.Sessions.Find(int.Parse(Curint));
var idx = int.Parse(addedStu);
if (!string.IsNullOrEmpty(addedStu))
{
if (Context.Students.Any(it => it.Guid == guid))
if (Context.Students.Any(it => it.Id == idx))
{
var stu = Context.Students.Find(guid);
if(stu.InterviewTime != Guid.Empty)
var stu = Context.Students.Find(idx);
if(stu.InterviewTime != 0)
{
var oldtime = Context.Sessions.Find(stu.InterviewTime);
if(oldtime != null)
{
oldtime.Students.RemoveAll(s => s == stu.Guid);
oldtime.Students.RemoveAll(s => s == stu.Id);
Context.SaveChanges();
}
}
stu.InterviewTime = CurSession.Guid;
stu.InterviewTime = CurSession.Id;
stu.Status = status.已选时间;
CurSession.Students.Add(guid);
CurSession.Students.Add(idx);
}
Context.SaveChanges();
}
return Construct(CurGuid);
return Construct(Curint);
}
public async Task<IActionResult> OnPostAddChiefAsync()
{
CurSession = Context.Sessions.Find(Guid.Parse(CurGuid));
if (Context.Users.Any(it => it.Guid == addedChief))
CurSession = Context.Sessions.Find(int.Parse(Curint));
if (Context.Users.Any(it => it.Id == addedChief))
{
CurSession.Chiefs.Add(addedChief);
}
Context.SaveChanges();
return Construct(CurGuid);
return Construct(Curint);
}
public async Task<IActionResult> OnPostDeleteChiefAsync(string id)
{
var guid = Guid.Parse(id);
CurSession = Context.Sessions.Find(Guid.Parse(CurGuid));
if (CurSession.Chiefs.Contains(guid))
var idx = int.Parse(id);
CurSession = Context.Sessions.Find(int.Parse(Curint));
if (CurSession.Chiefs.Contains(idx))
{
CurSession.Chiefs.Remove(guid);
CurSession.Chiefs.Remove(idx);
}
Context.SaveChanges();
return Construct(CurGuid);
return Construct(Curint);
}
private bool InterviewTimeExists(Guid id)
private bool InterviewTimeExists(int id)
{
return Context.Sessions.Any(e => e.Guid == id);
return Context.Sessions.Any(e => e.Id == id);
}
}
}
+3 -3
View File
@@ -157,9 +157,9 @@
}
</td>
<td>
<a asp-page="./Edit" asp-route-id="@item.Guid">编辑</a> |
<a asp-page="./Delete" asp-route-id="@item.Guid">删除</a> |
<a asp-page-handler="Reset" asp-route-id="@item.Guid">重置</a>
<a asp-page="./Edit" asp-route-id="@item.Id">编辑</a> |
<a asp-page="./Delete" asp-route-id="@item.Id">删除</a> |
<a asp-page-handler="Reset" asp-route-id="@item.Id">重置</a>
</td>
</tr>
}
+19 -19
View File
@@ -89,16 +89,16 @@ namespace _2021_backend.Pages.Sessions
return Construct(errmsg);
}
public async Task<IActionResult> OnGetResetAsync(Guid id)
public async Task<IActionResult> OnGetResetAsync(int id)
{
if(Context.Sessions.Any(it => it.Guid == id))
if(Context.Sessions.Any(it => it.Id == id))
{
var s = Context.Sessions.Find(id);
foreach(var st in s.Students)
{
var e = Context.Students.Find(st);
e.Status = status.需调整时间;
e.InterviewTime = Guid.Empty;
e.InterviewTime = 0;
}
s.Students.Clear();
}
@@ -132,7 +132,7 @@ namespace _2021_backend.Pages.Sessions
{
foreach(var s in Context.Students)
{
s.InterviewTime = Guid.Empty;
s.InterviewTime = 0;
s.Status = status.需调整时间;
s.Timelist.Clear();
}
@@ -152,9 +152,9 @@ namespace _2021_backend.Pages.Sessions
{
if(s.Status == status.已选时间)
{
s.InterviewTime = Guid.Empty;
s.Timelist.RemoveAll(it => !Context.Sessions.Any(k => k.Guid == it));
s.Timelist.Sort((Guid a, Guid b) =>
s.InterviewTime = 0;
s.Timelist.RemoveAll(it => !Context.Sessions.Any(k => k.Id == it));
s.Timelist.Sort((int a, int b) =>
{
var x = Context.Sessions.Find(a);
var y = Context.Sessions.Find(b);
@@ -193,7 +193,7 @@ namespace _2021_backend.Pages.Sessions
var ntm = new List<Session>();
foreach(var j in tm)
{
var k = sess.Find(it => it.Guid == j);
var k = sess.Find(it => it.Id == j);
ntm.Add(k);
}
ntm.Sort((Session a,Session b) =>
@@ -202,17 +202,17 @@ namespace _2021_backend.Pages.Sessions
var y = a.BeginTime.CompareTo(b.BeginTime);
return x != 0 ? x : y;
});
List<Guid> nl = new List<Guid>();
List<int> nl = new List<int>();
foreach(var j in ntm)
{
if(i.Status != status.不通过 && i.Status != status.通过 && i.Status != status.已确认时间)
{
if (j.Day.Date.Add(j.BeginTime.TimeOfDay).CompareTo(DateTime.Now) < 0 || (j.Students.Count >= j.Capacity && !j.Students.Any(k => k ==i.Guid) )) continue;
nl.Add(j.Guid);
if (j.Day.Date.Add(j.BeginTime.TimeOfDay).CompareTo(DateTime.Now) < 0 || (j.Students.Count >= j.Capacity && !j.Students.Any(k => k ==i.Id) )) continue;
nl.Add(j.Id);
}
else
{
nl.Add(j.Guid);
nl.Add(j.Id);
}
}
@@ -236,9 +236,9 @@ namespace _2021_backend.Pages.Sessions
{
if (s.Status == status.已选时间)
{
s.InterviewTime = Guid.Empty;
s.Timelist.RemoveAll(it => !Context.Sessions.Any(k => k.Guid == it));
s.Timelist.Sort((Guid a, Guid b) =>
s.InterviewTime = 0;
s.Timelist.RemoveAll(it => !Context.Sessions.Any(k => k.Id == it));
s.Timelist.Sort((int a, int b) =>
{
var x = Context.Sessions.Find(a);
var y = Context.Sessions.Find(b);
@@ -256,7 +256,7 @@ namespace _2021_backend.Pages.Sessions
Context.SaveChanges();
foreach(var item in loads)
{
Session s = Context.Sessions.Find(item.Guid);
Session s = Context.Sessions.Find(item.Id);
if(s != null)
{
s.BeginTime = item.BeginTime;
@@ -264,12 +264,12 @@ namespace _2021_backend.Pages.Sessions
s.Capacity = item.Capacity;
s.SendSMS = item.SendSMS;
s.Chiefs = item.Chiefs;
s.Students = new List<Guid>();
s.Students = new List<int>();
foreach(var s2 in item.Students)
{
if (Context.Students.Any(k => k.Guid == s2))
if (Context.Students.Any(k => k.Id == s2))
{
Context.Students.Find(s2).InterviewTime = item.Guid;
Context.Students.Find(s2).InterviewTime = item.Id;
s.Students.Add(s2);
}
}