public async Task <bool> AddOrUpdateUserAsync(UserInfo user, CancellationToken cancellationToken)
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            var result = false;

            if (!string.IsNullOrWhiteSpace(user.Username))
            {
                using (var tx = this.StateManager.CreateTransaction())
                {
                    await this.usersDictionary.SetAsync(tx, user.Username, user,
                                                        TimeSpan.FromSeconds(5), cancellationToken);

                    await tx.CommitAsync();

                    result = true;
                }

                try
                {
                    var userProxy = this.actorFactory.Create <IUserActor>(new ActorId(user.Username),
                                                                          new Uri(UriConstants.UserActorUri));

                    await userProxy.UpdateUserInfoAsync(user.ToUserActorUserInfo(), cancellationToken);
                }
                catch { }
            }

            return(result);
        }
        public override async Task ExecuteAsync(IEnumerable <string> args)
        {
            var user = new iRentCar.UsersService.Interfaces.UserInfo()
            {
                FirstName = this.firstName,
                LastName  = this.lastName,
                Email     = this.mail,
                Username  = this.username,
                IsEnabled = this.isEnabled
            };
            var response = await UsersServiceProxy.Instance.AddOrUpdateUserAsync(user, default(CancellationToken));

            Console.WriteLine($"AddOrUpdateUserAsync --> {response}");
            WriteMessage(null);
        }
        public async Task <UserInfo> GetUserByUserNameAsync(string username, CancellationToken cancellationToken)
        {
            if (string.IsNullOrWhiteSpace(username))
            {
                throw new ArgumentException(nameof(username));
            }

            UserInfo user = null;

            using (var tx = this.StateManager.CreateTransaction())
            {
                var tryUser = await this.usersDictionary.TryGetValueAsync(tx, username, TimeSpan.FromSeconds(5), cancellationToken);

                if (tryUser.HasValue)
                {
                    user = tryUser.Value;
                }
            }

            return(user);
        }