public async Task <int> CreateAccount(WebUserAccountModel webUserAccountModel) { try { var userAccountModel = ModelConverterService.ConvertTo(webUserAccountModel, new UserAccountModel()); var userAccountId = await _userAccountRepository.CreateAccount(userAccountModel); return(userAccountId); } catch (SqlCustomException e) { throw new SqlCustomException(e.Message, e.InnerException); } }
public async Task <IActionResult> Register([FromBody] RegisterAccountDto item) { var account = await _accountRepository.GetByUserName(item.UserName); if (account != null) { return(Error($"Account with username :{item.UserName} already registered.")); } await _accountRepository.CreateAccount(new UserAccounts { UserName = item.UserName, Password = item.Password.ToSha256(), Role = item.Role }); return(Ok()); }