/// <summary>
        /// Checks whether the current user is authorised to update the provided entity.
        /// </summary>
        /// <param name="entity">The entity to be updated.</param>
        /// <returns>A value indicating whether the current user is authorised to update the provided entity.</returns>
        public override bool IsAuthorised(IEntity entity)
        {
            bool isAuthorised = false;

            using (LogGroup logGroup = LogGroup.Start("Checking whether the current user is authorised to update the provided entity.", NLog.LogLevel.Debug))
            {
                if (entity == null)
                {
                    throw new ArgumentNullException("entity");
                }

                if (!RequireAuthorisation)
                {
                    isAuthorised = true;
                }
                else
                {
                    isAuthorised = IsAuthorised(entity.ShortTypeName);

                    AuthoriseReferencesStrategy.New(entity).Authorise(entity);
                }

                LogWriter.Debug("Is authorised: " + isAuthorised);
            }
            return(isAuthorised);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Checks whether the current user is authorised to save the provided entity.
        /// </summary>
        /// <param name="entity">The entity to be saved.</param>
        /// <returns>A value indicating whether the current user is authorised to save the provided entity.</returns>
        public override bool IsAuthorised(IEntity entity)
        {
            bool isAuthorised = false;

            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            using (LogGroup logGroup = LogGroup.StartDebug("Authorising the save of a '" + entity.ShortTypeName + "' entity."))
            {
                AuthoriseReferencesStrategy.New(entity).Authorise(entity);

                isAuthorised = IsAuthorised(entity.ShortTypeName);

                LogWriter.Debug("Is authorised: " + isAuthorised);
            }
            return(isAuthorised);
        }