示例#1
0
        public string GetUserNameType(string UserName)
        {
            var item1 = new UserNameType
            {
                UserName = "******",
                UserType = "Paciente"
            };
            var item2 = new UserNameType
            {
                UserName = "******",
                UserType = "Doctor"
            };
            var UserNameTypeTable = new List <UserNameType> {
                item1, item2
            };

            foreach (var item in UserNameTypeTable)
            {
                if (item.UserName == UserName)
                {
                    return(item.UserType);
                }
            }
            return(null);
        }
示例#2
0
        public async Task <Account> FindByUserNameAsync(string userName, UserNameType type = UserNameType.PhoneNumber)
        {
            if (string.IsNullOrEmpty(userName))
            {
                return(null);
            }

            if (type == UserNameType.PhoneNumber)
            {
                return(await _context.Accounts.FirstOrDefaultAsync(a => a.UserName.ToLower() == userName.ToLower()));
            }
            else
            {
                return(await _context.Accounts.FirstOrDefaultAsync(a => a.UserName.ToLower() == userName.ToLower() || a.Email == userName));
            }
        }
示例#3
0
        public static string UserName(this string value, UserNameType userNameType)
        {
            var spName = value.Split(',');

            if (spName.Length > 1)
            {
                if (userNameType == UserNameType.Last)
                {
                    return(spName[0]);
                }
                else
                {
                    return(spName[1]);
                }
            }
            else
            {
                return(value);
            }
        }
 /// <summary>
 /// Create a user account without email confirmation.
 /// </summary>
 /// <param name="userTimezone">Timezone of user's registration country.</param>
 /// <param name="country">Three letter country code.</param>
 /// <param name="acceptTc">True to accept t&c of the platform. Must set to true to register successfully.</param>
 /// <param name="language">User preferred language.</param>
 /// <param name="usernameType">Type of user account name. E.g., PHONENUMBER</param>
 /// <param name="username">User account name. E.g., +85295271816</param>
 /// <remarks>
 /// This account cannot be login from website/mobile app. The account is only accessible by the master key api.
 /// </remarks>
 /// <returns></returns>
 public async Task <AutoRegisterResponse> AutoRegisterAsync(string userTimezone, string country, bool acceptTc, Language language, UserNameType usernameType, string username)
 {
     return(await QueryPrivateAsync <AutoRegisterResponse>(
                "register/autoRegister",
                new Dictionary <string, string>(6)
     {
         ["userTimezone"] = userTimezone,
         ["country"] = country,
         ["accepttc"] = acceptTc ? "1" : "0",
         ["language"] = language.ToString(),
         ["usernameType"] = usernameType.ToString(),
         ["username"] = username,
     }
                ));
 }