public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Course).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseExists(Course.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } if (ModelState.IsValid) { curentUserId = User.Identity.Name; var survey = new Models.Survey { ApplicationUserId = curentUserId, Answer1 = Input.Answer1, Answer2 = Input.Answer2, Answer3 = Input.Answer3, Answer4 = Input.Answer4, Answer5 = Input.Answer5, Answer6 = Input.Answer6, Answer7 = Input.Answer7 }; _context.ApplicationUsers.Where(u => u.Email == survey.ApplicationUserId).FirstOrDefault().Survey = survey; _context.ApplicationUsers.Where(u => u.Email == survey.ApplicationUserId).FirstOrDefault().Completed = true; _context.Surveys.Add(survey); } await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Courses.Add(Course); await _context.SaveChangesAsync(); Course.ApplicationUser.Completed = true; return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Course = await _context.Courses.FindAsync(id); if (Course != null) { _context.Courses.Remove(Course); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }