public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Survey).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SurveyExists(Survey.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostVoteAsync(int?id) { if (!ModelState.IsValid) { return(Page()); } try { PointedOption = await _context.SurveyOptions.FindAsync(id); PointedOption.Point += 1; _context.Attach(PointedOption).State = EntityState.Modified; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SurveyOptionExists(PointedOption.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("/Surveys/Index")); }