Ejemplo n.º 1
0
        public override async Task <Empty> RegisterUser(
            RegisterUserParameter request,
            ServerCallContext context)
        {
            if (string.IsNullOrWhiteSpace(request.Username) ||
                string.IsNullOrWhiteSpace(request.Email))
            {
                throw new RpcException(new Status(StatusCode.InvalidArgument, "Invalid fields."));
            }

            try
            {
                new MailAddress(request.Email);
            }
            catch
            {
                throw new RpcException(new Status(StatusCode.InvalidArgument, "Invalid field."));
            }

            var registerResult =
                await _executor
                .ExecuteAsync <RegisterUserParameters, RegisterUserResults>(
                    new RegisterUserParameters(
                        request.Email,
                        request.Username,
                        request.Password))
                .ConfigureAwait(false);

            if (!registerResult.Succeeded)
            {
                throw new RpcException(new Status(StatusCode.Unauthenticated, "Credentials already registered."));
            }

            return(new Empty());
        }
Ejemplo n.º 2
0
        public Task <RegisterResult> RegisterUser(RegisterUserParameter registerUserParameter)
        {
            var result = new RegisterResult()
            {
                IsSuccessful = true,
                User         = _testUser
            };

            return(Task.FromResult(result));
        }
Ejemplo n.º 3
0
        private async Task Accept()
        {
            var userRegistration = new RegisterUserParameter(
                _firstname,
                _lastname,
                _address
                );

            try
            {
                var result = await _userApiService.RegisterUser(userRegistration);

                if (result.IsSuccessful)
                {
                    _appUserModelService.LogInUser(result.User);
                    await HostScreen.Router.Navigate.Execute(new HomeViewModel(_hostScreen, appUserModelService : _appUserModelService, logger : _logger));
                }
            }
            catch (Exception ex)
            {
                _logger.Error(nameof(Accept), ex);
            }
        }