public async Task <IActionResult> Approve(PendingSchoolViewModel viewModel) { // remove the pending book from that table var removeSchool = ctx.PendingSchools.Where(a => a.ID == viewModel.id).FirstOrDefault(); ctx.PendingSchools.Remove(removeSchool); // add to the actual book table School newSchool = new School(); newSchool.Name = viewModel.name; newSchool.City = viewModel.city; newSchool.State = viewModel.state; newSchool.Status = 1; ctx.Schools.Add(newSchool); ctx.SaveChanges(); // Send email notification to User that submitted the school. var user = await usrCtx.FindByIdAsync(removeSchool.UserID); var callbackUrl = Url.Action("Login", "Account", null, protocol: HttpContext.Request.Scheme); await _emailSender.SendEmailAsync(user.Email, "NYBE School Approval", $"Your recent school request for \"{removeSchool.Name}\" has been approved! <a href='{callbackUrl}'>Sign in</a> and check it out!"); return(RedirectToAction("Manage")); }
public IActionResult Enable(PendingSchoolViewModel viewModel) { School school = ctx.Schools.Where(a => a.ID == viewModel.id).FirstOrDefault(); school.Status = 1; ctx.SaveChanges(); return(RedirectToAction("Manage")); }
public IActionResult Enable(int?id) { PendingSchoolViewModel viewModel = new PendingSchoolViewModel(); School school = ctx.Schools.Where(a => a.ID == id).FirstOrDefault(); viewModel.id = school.ID; viewModel.name = school.Name; viewModel.city = school.City; viewModel.state = school.State; return(View(viewModel)); }
public async Task <IActionResult> Deny(PendingSchoolViewModel viewModel) { // remove the pending school from that table var removeSchool = ctx.PendingSchools.Where(a => a.ID == viewModel.id).FirstOrDefault(); ctx.PendingSchools.Remove(removeSchool); ctx.SaveChanges(); // Send email notification to User that submitted the school. var user = await usrCtx.FindByIdAsync(removeSchool.UserID); var callbackUrl = Url.Action("Login", "Account", null, protocol: HttpContext.Request.Scheme); await _emailSender.SendEmailAsync(user.Email, "NYBE School Denial", $"Your recent school request for \"{removeSchool.Name}\" has been denied. =[ <a href='{callbackUrl}'>Sign in</a> and try a different school!"); return(RedirectToAction("Manage")); }
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)); } }
public IActionResult Index() { var viewModel = new PendingSchoolViewModel(); return(View(viewModel)); }