Exemple #1
0
        public Task <Result> Handle(LogOffCommand request, CancellationToken cancellationToken)
        {
            Result <int> opGetUserIdResult = _currentUserService.GetIdCurrentUser();

            if (opGetUserIdResult.IsSuccess)
            {
                int userId = opGetUserIdResult.Value;
                if (this._accountRepository.ExistsAccount(userId))
                {
                    Account accountDB = this._accountRepository.GetAccount(userId);
                    accountDB.Token = string.Empty;
                    return(Task.FromResult(this._accountRepository.SaveModifications()));
                }
                else
                {
                    return(Task.FromResult(Results.Fail(
                                               new CustomError(ErrorsCodesContants.USER_ID_NOT_FOUND, ErrorsMessagesConstants.USER_ID_NOT_FOUND, 401))));
                }
            }
            else
            {
                return(Task.FromResult(opGetUserIdResult.ToResult()));
            }
        }