Ejemplo n.º 1
0
        /// <summary>
        /// Register User if Id and NickName are Unique
        /// </summary>
        /// <param name="appUser"></param>
        /// <returns></returns>
        public async Task <AppUser> RegisterAsync(AppUser appUser)
        {
            var idMatchingUserT       = _userDal.GetAppUserByIdAsync(appUser.Id);
            var nickNameMatchingUserT = _userDal.GetAppUserByIdAsync(appUser.NickName);

            await Task.WhenAll(idMatchingUserT, nickNameMatchingUserT);

            if (idMatchingUserT.Result != null || nickNameMatchingUserT.Result != null)
            {
                return(null);
            }

            appUser.Password = BCrypt.Net.BCrypt.HashPassword(appUser.Password, 17);

            if ((await _userDal.CreateNewAppUserAsync(appUser)))
            {
                return(appUser);
            }
            else
            {
                return(null);
            }
        }