public IActionResult Approve(int?id) { if (id == null) { return(NotFound()); } var viewModel = new PendingSchoolViewModel(); PendingSchool pSchool = ctx.PendingSchools.Where(a => a.ID == id).FirstOrDefault(); // make sure we found the school if (pSchool != null) { viewModel.id = pSchool.ID; viewModel.name = pSchool.Name; viewModel.city = pSchool.City; viewModel.state = pSchool.State; } return(View(viewModel)); }
public async Task <IActionResult> Index(PendingSchoolViewModel viewModel) { if (ModelState.IsValid) { var user = await GetCurrentUserAsync(); PendingSchool pSchool = new PendingSchool(); pSchool.Name = viewModel.name; pSchool.City = viewModel.city; pSchool.State = viewModel.state; pSchool.UserID = user.Id; ctx.PendingSchools.Add(pSchool); ctx.SaveChanges(); return(View("Confirm")); } else { return(View(viewModel)); } }