public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); // TODO: refactor: change to OnGet() Faculties = applicationsManager.GetFaculties(); Lecterns = applicationsManager.GetLecterns(); Curriculums = applicationsManager.GetCurriculums(); if (ModelState.IsValid) { if (applicationsManager.ApplicationExist(Input.Email)) { ModelState.AddModelError(string.Empty, "User with this email has already submitted application"); return(Page()); } else { var application = MapToApplication(Input); bool success = await UsersManager.CreateUser(serviceProvider, configuration, application); if (success) { return(RedirectToPage("./ApplicationSent")); } else { ModelState.AddModelError(string.Empty, "Smth went wrong"); } } } return(Page()); }
public async Task <IActionResult> OnPost(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); PopulateData(); if (ModelState.IsValid) { if (applicationsManager.ApplicationExist(Input.Email)) { ModelState.AddModelError(string.Empty, "User with this email has already existed"); return(Page()); } else { var user = ApplicationUserEditPageModel.ComposeApplicationUser(Input, Faculties, Lecterns, Curriculums); await UsersManager.CreateUser(serviceProvider, configuration, user, Input.Password, Input.Email, Input.UserType); return(LocalRedirect("~/Admin/Users")); } } return(Page()); }