public async Task <AccountModel> Register([FromBody] AddAccountModel model) { ValidateInputModel(); var accountFilter = new AccountFilter() { UserName = model.UserName }; var accounts = await accountDao.Filter(accountFilter); if (accounts.Count > 0) { throw new DomainValidateException(new List <string>() { AccountErrorMessages.REGISTER_EXIST_USERNAME }); } var passwordSalt = "-" + model.UserName + "-AuctionHub-" + model.UserName; string passwordHash = StringUtils.ComputeSha256Hash(model.Password + passwordSalt); var accountDto = new MdAccount() { Id = ObjectId.GenerateNewId(), UserName = model.UserName, PasswordSalt = passwordSalt, PasswordHash = passwordHash, Email = model.Email, PhoneNumber = model.PhoneNumber, CreatedAt = DateTime.UtcNow, ModifiedAt = DateTime.UtcNow }; await accountDao.AddAsync(accountDto); var userAccountResponse = GetFromAccount(accountDto); return(userAccountResponse); }
private AccountModel GetFromAccount(MdAccount account) { var accountModel = Mapper.Map <AccountModel>(account); return(accountModel); }