示例#1
0
        public async Task <IdentityResult> CreateAsync(UserBE user, CancellationToken token)
        {
            try
            {
                if (string.IsNullOrEmpty(user.Email) ||
                    user.Email.Count() > 100 ||
                    string.IsNullOrEmpty(user.UserName) ||
                    user.UserName.Count() > 20
                    )
                {
                    throw new ArgumentException();
                }

                await _data.AddUser(user, token);

                return(IdentityResult.Success);
            }
            catch (Exception ex)
            {
                _logError.Log(ex);
                return(IdentityResult.Failed(new IdentityError {
                    Description = ex.ToString()
                }));
            }
        }
 /// <summary>
 /// Add New User
 /// </summary>
 /// <param name="user">User</param>
 /// <returns>int</returns>
 public int AddUser(User user)
 {
     return(userContext.AddUser(user));
 }