Пример #1
0
        public DataResult <bool> SwitchUserRoles(int userId, IEnumerable <string> rolesToRemove, IEnumerable <string> rolesToAdd)
        {
            try
            {
                m_userUoW.SwitchUserRoles(userId, rolesToRemove, rolesToAdd);

                return(Success(true));
            }
            catch (NoResultException <UserEntity> e)
            {
                m_logger.LogWarning(e);
                return(Error <bool>(m_translator.Translate("invalid-user-id"), DataResultErrorCode.UserNotExistId));
            }
            catch (NoResultException <RoleEntity> e)
            {
                m_logger.LogWarning(e);
                return(Error <bool>(m_translator.Translate("invalid-role-id"), DataResultErrorCode.RoleNotExistId));
            }
            catch (DatabaseException e)
            {
                m_logger.LogWarning(e);
                return(Error <bool>(e.Message));
            }
        }