public IHttpActionResult PostUserSignUpData([FromBody] CSignUpDto signUpData) { if (signUpData == null) { ModelState.AddModelError($"{nameof(signUpData)}", "Incoming data is null"); s_log.LogError($"{System.Reflection.MethodBase.GetCurrentMethod()}({(CSignUpDto)null})", new ArgumentNullException(nameof(signUpData), "Incoming data is null")); return(BadRequest(ModelState)); } CUserInfo userInfo = new CUserInfo( Guid.Empty, signUpData.Credentials.Login, signUpData.Credentials.Password, default(DateTimeOffset), 0, signUpData.Avatar ); Guid newUserId = _userDataProvider.CreateUser(userInfo); if (newUserId == Guid.Empty) { s_log.LogError($"{System.Reflection.MethodBase.GetCurrentMethod()}({signUpData})", new Exception("Failed to create new user")); return(InternalServerError()); } return(Ok("Signed Up")); //return Created("api/auth/signup", newUserId); }
public String SignUp(String login, String password, String avatar) { Console.WriteLine($@"Supplier method '{nameof(SignUp)}({login}, {avatar})' is called"); _logger.LogInfo($"Supplier method '{nameof(SignUp)}({login}, {avatar})' is called"); CSignUpDto signUpData = new CSignUpDto( new CCredentialsDto( login, password ), avatar ); Console.WriteLine($@"Data to sign up = {signUpData}"); _logger.LogInfo($"Data to sign up = {signUpData}"); return(_service.SignUp(signUpData)); }
public String SignUp(CSignUpDto signUpData) { Console.WriteLine($@"Service method '{nameof(SignUp)}({signUpData})' is called"); _logger.LogInfo($"Service method '{nameof(SignUp)}({signUpData})' is called"); try { HttpResponseMessage response = _client.PostAsync( $"api/auth/signup", new StringContent(JsonConvert.SerializeObject(signUpData), Encoding.UTF8, "application/json") ).Result; return((response.IsSuccessStatusCode) ? response.Content.ReadAsStringAsync().Result : null); } catch (Exception e) { Console.WriteLine(e); _logger.LogError(@"MessengerService Error", e); throw; } }