public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Calling).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CallingExists(Calling.CallingID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } Calling = await _context.Calling.FirstOrDefaultAsync(m => m.CallingID == CurrentCalling.CallingID); Member = await _context.Member.FirstOrDefaultAsync(m => m.ID == CurrentCalling.MemberID); if (Calling.CallingGender != GenderCl.Both && Calling.CallingGender.ToString() != Member.MembersGender.ToString()) { Message = "Member is wrong gender for this calling."; ViewData["CallingID"] = new SelectList(_context.Calling, "CallingID", "Display"); ViewData["MemberID"] = new SelectList(_context.Member, "ID", "FullName"); return(Page()); } _context.Attach(CurrentCalling).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CurrentCallingExists(CurrentCalling.CurrentCallingID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }