// To protect from overposting attacks, please 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.StudentScore.Add(StudentScore); await _context.SaveChangesAsync(); /* * //https://medium.com/better-programming/running-python-script-from-c-and-working-with-the-results-843e68d230e5 * ProcessStartInfo processer = new ProcessStartInfo(); * processer.FileName = "/home/ubuntu/MaineCoon/DataProcesser/encapsulation.py"; * processer.Arguments = string.Format("python3 encapsulation.py {0} {1} {2} {3} {4} {5} {6}", StudentScore.T, StudentScore.G, StudentScore.UR, StudentScore.SOP, StudentScore.SOP, StudentScore.LOR, StudentScore.GPA, StudentScore.RES); * processer.CreateNoWindow = false; * processer.UseShellExecute = false; * processer.RedirectStandardOutput = true; * string score = "0.0 0.0"; * using (Process run = Process.Start(processer)) { * using (StreamReader reader = run.StandardOutput) { * score = reader.ReadToEnd(); * } * } */ return(RedirectToPage("./Index")); }
// To protect from overposting attacks, please 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(StudentScore).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentScoreExists(StudentScore.id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } if (_context.User.Where(usr => usr.email == UserData.email).Any()) { throw new Exception("User Already Existed!"); } else { UserData.registionTime = DateTime.UtcNow; UserData.accountStatus = Models.User.status.Disable; using (HMACSHA256 hasher = new HMACSHA256()) { new Random().NextBytes(hasher.Key); UserData.password = hasher.ComputeHash(UserData.password); UserData.SALT = hasher.Key; } } _context.User.Add(UserData); await _context.SaveChangesAsync(); return(Redirect("./Index?message=RegistSucceed!")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } StudentScore = await _context.StudentScore.FindAsync(id); if (StudentScore != null) { _context.StudentScore.Remove(StudentScore); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }