// 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(Term).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TermExists(Term.TermID)) { 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()); } _context.Term.Add(Term); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <JsonResult> CreateAcronymAsync(string acronym, char specialCharacter) { try { var spc = new SpecialCharacters { Acronym = acronym, SpecialCharacter = (int)specialCharacter }; _db.SpecialCharacters.Add(spc); await _db.SaveChangesAsync(); return(Json(new { success = true, spc = new { acronym = spc.Acronym, specialCharacter = char.ConvertFromUtf32(specialCharacter) } })); } catch (Exception ex) { return(Json(new { success = false, exception = ex })); } }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Term = await _context.Term.FindAsync(id); if (Term != null) { _context.Term.Remove(Term); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }