コード例 #1
0
        private async Task ValidateForm(RegistrationRequest registrationRequest)
        {
            if (registrationRequest == null)
            {
                throw new CallerException("Registration Form Cannot be null.");
            }

            if (string.IsNullOrEmpty(registrationRequest.Username))
            {
                throw new CallerException("Username field is required.");
            }

            if (registrationRequest.Username.Any(char.IsWhiteSpace))
            {
                throw new CallerException("Username may not contain spaces.");
            }

            var usernameLogic = new UsernameLogic(Cache, SettingRequester, UserContext);

            await usernameLogic.ValidateUsername(registrationRequest.Username);

            if (string.IsNullOrEmpty(registrationRequest.RegistrationChannel))
            {
                throw new CallerException("Registration Channel is required.");
            }
        }
コード例 #2
0
        public async Task <BudgetUser> Put(int userid, string proposedUsername)
        {
            var usernameLogic = new UsernameLogic(Cache, SettingRequester, Context);

            return(await usernameLogic.UpdateUsername(userid, proposedUsername));
        }