/// <summary>
        /// Adds the user to the Izenda database
        /// See the link below for more details:
        /// https://www.izenda.com/docs/ref/api_user.html?highlight=user%20integration#post-user-integration-saveuser
        /// </summary>
        public static async Task <bool> CreateIzendaUser(WebformsIntegratedBE_Standalone.Models.ApplicationUser appUser, string roleName, string authToken)
        {
            var izendaTenant = appUser.Tenant != null ? await GetIzendaTenantByName(appUser.Tenant.Name, authToken) : null;

            var izendaUser = new UserDetail
            {
                FirstName       = izendaTenant != null ? izendaTenant.Name : "Admin",
                LastName        = appUser.UserName.Split('@')[0],
                Username        = appUser.UserName,
                TenantDisplayId = izendaTenant != null ? izendaTenant.Name : string.Empty,
                TenantId        = izendaTenant != null ? (Guid?)izendaTenant.Id : null,
                InitPassword    = true,
                SystemAdmin     = izendaTenant == null,
                Active          = true
            };

            if (!string.IsNullOrWhiteSpace(roleName))
            {
                var izendaRole = await CreateRole(roleName, izendaTenant, authToken);

                izendaUser.Roles.Add(izendaRole);
            }

            bool success = await WebAPIService.Instance.PostReturnValueAsync <bool, UserDetail>("user/integration/saveUser", izendaUser, authToken);

            return(success);
        }
        public static async Task <UserDetail> CreateUser(WebformsIntegratedBE_Standalone.Models.ApplicationUser hostingUser, string roleName, string authToken)
        {
            var izendaTenant = hostingUser.Tenant != null ? await GetIzendaTenantByName(hostingUser.Tenant.Name, authToken) : null;

            var izendaUser = new UserDetail
            {
                FirstName       = izendaTenant != null ? izendaTenant.Name : string.Empty,
                LastName        = hostingUser.UserName.Split('@')[0],
                Username        = hostingUser.UserName,
                TenantDisplayId = izendaTenant != null ? izendaTenant.Name : string.Empty,
                TenantId        = izendaTenant != null ? (Guid?)izendaTenant.Id : null
            };

            if (!string.IsNullOrWhiteSpace(roleName))
            {
                var izendaRole = await CreateRole(roleName, izendaTenant, authToken);

                izendaUser.Roles.Add(izendaRole);
            }

            izendaUser = await WebAPIService.Instance.PostReturnValueAsync <UserDetail, UserDetail>("user", izendaUser, authToken);

            return(izendaUser);
        }