public DataResult <bool> SavePersistedGrant(PersistedGrantModel grant)
        {
            var newGrant = new PersistedGrantEntity
            {
                Key            = grant.Key,
                Type           = grant.Type,
                CreationTime   = grant.CreationTime,
                ExpirationTime = grant.ExpirationTime,
                Data           = grant.Data
            };

            try
            {
                m_persistedGrantUoW.SavePersistedGrant(grant.User.Id, grant.Client.Name, newGrant);
                return(Success(true));
            }
            catch (NoResultException <UserEntity> e)
            {
                m_logger.LogWarning(e);
                return(Error <bool>(m_translator.Translate("invalid-user-id"), DataResultErrorCode.UserNotExistId));
            }
            catch (NoResultException <ClientEntity> e)
            {
                m_logger.LogWarning(e);
                return(Error <bool>(m_translator.Translate("invalid-client-id"), DataResultErrorCode.ClientNotExistId));
            }
            catch (DatabaseException e)
            {
                m_logger.LogWarning(e);
                return(Error <bool>(e.Message));
            }
        }
        public async Task <IActionResult> DeleteAll(PersistedGrantModel model)
        {
            await _persistedGrantService.DeleteAllBySubjectIdAsync(model.SubjectId);

            SuccessNotification("删除成功", "成功");

            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 3
0
        public void persisted_grant_model()
        {
            var model  = NewPersistedGrantModel;
            var model2 = new PersistedGrantModel(model.ToPersistedGrant());

            var model3 = NewPersistedGrantModel;

            model.ShouldBe(model2);
            model.ShouldNotBe(model3);
        }
        public async Task <IActionResult> Delete(PersistedGrantModel model)
        {
            var result = await _persistedGrantService.DeleteByKeyAsync(UrlHelper.QueryStringUnSafeHash(model.Key));

            if (result)
            {
                SuccessNotification("删除成功", "成功");

                return(RedirectToAction(nameof(Index)));
            }

            return(View(model));
        }