public void RegisterUser(RegisterUser user) { using (var client = new HttpClient()) { try { client.BaseAddress = new Uri(ConfigurationManager.AppSettings["ServerPath"]); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); dynamic myObject = new JObject(); myObject.login = user.Username; myObject.firstHash = _passwordManager.CreateFirstHash(user.Username, user.Password); myObject.firstName = user.FirstName; myObject.lastName = user.LastName; myObject.phone = user.Phone; myObject.mail = user.Mail; var result = client.PostAsync(ConfigurationManager.AppSettings["RegisterPath"], new StringContent(JsonConvert.SerializeObject(myObject).ToString(), Encoding.UTF8, "application/json")).Result; if (result.StatusCode != HttpStatusCode.OK) { throw new Exception($"Server error. Status: {result.StatusCode}. Message: {result.RequestMessage}"); } } catch (HttpRequestException e) { throw new Exception("Internal server error."); } } }
public ActionResult Register(RegisterUser registerUser) { if (ModelState.IsValid) { _authProvider.Register(registerUser); return RedirectToAction("Index", "Home"); } return View(registerUser); }
public void Register(RegisterUser user) { _registerWebUserStrategy.RegisterUser(user); }