public RegistrationSuccessPage() { BindingContext = new RegistrationSuccessViewModel(); InitializeComponent(); AddImage(SuccessIcon, "NottCS.Images.Icons.okfixed.png"); //AddImage(Back, "NottCS.Images.Icons.back.png"); }
public IActionResult RegistrationSuccess() { var vm = new RegistrationSuccessViewModel { AdminPanelUrl = Url.Action("Index", "Admin"), RegistrationUrl = Url.Action("Register") }; return(View(vm)); }
public ActionResult Register(UserRegistrationViewModel registration) { if (ModelState.IsValid) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(ConfigurationManager.AppSettings["apiUrl"]); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage Res = client.GetAsync($"api/Registration/IsUsernameAvailable?username={registration.Username}").Result; // TODO: make this async if (Res.IsSuccessStatusCode) { var response = Res.Content.ReadAsStringAsync().Result; bool usernameAvailable = Convert.ToBoolean(response.ToLowerInvariant()); if (usernameAvailable) { var userModel = new UserModel { Username = registration.Username, Password = registration.Password }; var postTask = client.PostAsJsonAsync <UserModel>("api/Registration/PostNewUser", userModel); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { TempData["model"] = new RegistrationSuccessViewModel { Username = registration.Username }; return(RedirectToAction("Success", "Login")); } else { ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator."); } } else { ModelState.AddModelError("Username", "Username already exists!"); } } } } return(View(registration)); }