// 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()); } InterviewTime.Students = new List <int>(); if (CreateTwo) { string anotherPlace = InterviewTime.Place == "200" ? "204" : "200"; InterviewTime tmp = await _context.Time.FirstOrDefaultAsync(r => r.Place == anotherPlace && r.Day == InterviewTime.Day && InterviewTime.BeginTime == r.BeginTime); if (tmp == null) { InterviewTime interviewTimeSecond = new InterviewTime() { Day = InterviewTime.Day, BeginTime = InterviewTime.BeginTime, Place = anotherPlace, TakenNum = InterviewTime.TakenNum, Chief = InterviewTime.Chief, SendSMS = InterviewTime.SendSMS, NowNum = 0, Students = new List <int>() }; _context.Add(interviewTimeSecond); await _context.SaveChangesAsync(); } } _context.Time.Add(InterviewTime); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } InterviewTime = await _context.Time.FindAsync(id); if (InterviewTime != null) { if (InterviewTime.Students.Count() > 0) { foreach (var x in InterviewTime.Students) { Record record = await _context.Record.FirstOrDefaultAsync(r => r.rid == x); record.InterviewID = 0; record.InterviewTime = null; await _context.SaveChangesAsync(); } } _context.Time.Remove(InterviewTime); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
// 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()); } InterviewTime interview = await _context.Time.AsNoTracking().FirstOrDefaultAsync(r => r.ID == InterviewTime.ID); InterviewTime.Students = new List <int>(); foreach (var x in interview.Students) { InterviewTime.Students.Add(x); } _context.Attach(InterviewTime).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InterviewTimeExists(InterviewTime.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Record = await _context.Record.FindAsync(id); if (Record != null) { if (!DeleteAll) { if (Record.InterviewID != 0) { InterviewTime interviewTime = await _context.Time.FirstOrDefaultAsync(r => r.ID == Record.InterviewID); if (interviewTime.NowNum > 0) { interviewTime.NowNum -= 1; } interviewTime.Students.Remove(Record.rid); await _context.SaveChangesAsync(); } _context.Record.Remove(Record); await _context.SaveChangesAsync(); } else { foreach (var x in _context.Record) { if (x.name == Record.name && x.id_student == Record.id_student && x.sex == Record.sex && x.phone == Record.phone) { _context.Record.Remove(x); } } await _context.SaveChangesAsync(); } } return(RedirectToPage("./Index")); }
// 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()); } if (await _context.User.AsNoTracking().Where(u => u.stuID == User.stuID).CountAsync() > 0 && (await _context.User.AsNoTracking().Where(u => u.stuID == User.stuID).FirstOrDefaultAsync()).Uid != User.Uid ) { return(new ConflictResult()); } if (User.Secret == null || User.Secret == String.Empty) { var user = await _context.User.AsNoTracking().Where(u => u.Uid == User.Uid).FirstOrDefaultAsync(); user.Name = User.Name; user.stuID = User.stuID; user.isManager = User.isManager; _context.Attach(user).State = EntityState.Modified; } else { var user = await _context.User.AsNoTracking().Where(u => u.Uid == User.Uid).FirstOrDefaultAsync(); user.Name = User.Name; user.stuID = User.stuID; user.isManager = User.isManager; user.Secret = Utils.EvaCryptoHelper.Password2Secret(User.Secret); _context.Attach(user).State = EntityState.Modified; } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(User.Uid)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// 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()); } if (await _context.User.AsNoTracking().Where(u => u.stuID == NowUser.stuID).FirstOrDefaultAsync() != null) { return(new ConflictResult()); } NowUser.Secret = Utils.EvaCryptoHelper.Password2Secret(NowUser.Secret); _context.User.Add(NowUser); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(string id) { if (id == null) { return(NotFound()); } User = await _context.User.FindAsync(id); if (User != null) { _context.User.Remove(User); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
// 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()); } Record.addedDate = DateTime.Now; Record.status = Status.Pending; Record.Times = new List <int>(); foreach (var x in TimeDtos) { if (x.IsChoose) { Record.Times.Add(x.ID); } } if (Record.strguid == null) { Record.strguid = Guid.NewGuid().ToString("N").Substring(0, 12); } var ip = Request.Headers["X-Real-IP"].FirstOrDefault(); if (ip != null) { Record.ip = ip; } else { Record.ip = "miss"; } _context.Record.Add(Record); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Record = await _context.Record.FirstOrDefaultAsync(m => m.rid == id); if (Record == null) { return(NotFound()); } IList <Record> records = await _context.Record.Where(r => r.id_student == Record.id_student).ToListAsync(); foreach (var item in records) { item.FinalResult = 0; item.status = Status.Pending; _context.Record.Update(item); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (FinalDepartment == 0) { return(RedirectToPage("./Index")); } if (Record == null) { return(NotFound()); } IList <Record> records = await _context.Record.Where(r => r.id_student == Record.id_student).ToListAsync(); foreach (var item in records) { item.FinalResult = FinalDepartment; item.status = Status.Pass; _context.Record.Update(item); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
// 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()); } //添加日期 if (SelectDay != null && SelectTime != null) { //注意剩余前面的那个空格! SelectTime = SelectTime.Substring(0, SelectTime.IndexOf(" 剩余")); InterviewTime interviewTime = await _context.Time.FirstOrDefaultAsync(r => r.Day == SelectDay && r.BeginTime + " " + r.Place == SelectTime); if (interviewTime != null) { if (interviewTime.NowNum == interviewTime.TakenNum) { return(RedirectToPage("../Error")); } InterviewTime oldTime = null; foreach (var x in _context.Time) { try { if (x.Students.Contains(Record.rid)) { oldTime = x; break; } } catch (NullReferenceException e) { throw e; } } if (oldTime != null) { if (oldTime.NowNum > 0) { oldTime.NowNum -= 1; } oldTime.Students.Remove(Record.rid); await _context.SaveChangesAsync(); } interviewTime.NowNum += 1; interviewTime.Students.Add(Record.rid); await _context.SaveChangesAsync(); Record.InterviewID = interviewTime.ID; Record.InterviewTime = $"{SelectDay} {interviewTime.BeginTime}"; } } //重新赋值 var record = _context.Record.AsNoTracking().Where(r => r.rid == Record.rid).FirstOrDefault(); Record.status = record.status; Record.addedDate = record.addedDate; Record.ip = record.ip; Record.strguid = record.strguid; Record.Times = new List <int>(); foreach (var x in TimeDtos) { if (x.IsChoose) { Record.Times.Add(x.ID); } } _context.Attach(Record).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RecordExists(Record.rid)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }