/// <exception cref="System.Exception">Thrown when the UserManager was not able to create the useraccount</exception> /// <exception cref="System.ArgumentException">Thrown when the UserAccount parameter was null or invalid</exception> public async Task <IBLUserAccount> CreateByAccountAsync(IPLUserAccount userAccount) { if (userAccount == null || String.IsNullOrEmpty(userAccount.Email) || String.IsNullOrEmpty(userAccount.Password)) { throw new ArgumentException("Parameter cannot be null or invalid"); } var dalUserAccount = new DALUserAccount(); PropertyCopier <PLUserAccount, DALUserAccount> .Copy((PLUserAccount)userAccount, dalUserAccount); dalUserAccount.UserName = dalUserAccount.Email; dalUserAccount.Id = Guid.NewGuid().ToString(); IdentityResult result = await _userManager.CreateAsync(dalUserAccount, userAccount.Password); return(await HandleAccountCreationResult(result, dalUserAccount)); }
public async Task <IdentityResult> WriteAsync(IPLUserAccount blUserAccount) { if (blUserAccount == null || String.IsNullOrEmpty(blUserAccount.Email) || String.IsNullOrEmpty(blUserAccount.Id)) { throw new ArgumentException("Parameter cannot be null or ivalid"); } var dalUserAccount = await _userManager.FindByIdAsync(blUserAccount.Id); if (dalUserAccount == null) { throw new Exception("Ef useraccount was null"); } PropertyCopier <PLUserAccount, DALUserAccount> .Copy((PLUserAccount)blUserAccount, dalUserAccount); return(await _userManager.UpdateAsync(dalUserAccount)); }