Exemplo n.º 1
0
        public override void React(SoftwareMonkeys.SiteStarter.Entities.IEntity entity)
        {
            // Set the entity ID if needed
            if (entity.ID == Guid.Empty)
                entity.ID = Guid.NewGuid();

            base.React(entity);
        }
        public override void React(SoftwareMonkeys.SiteStarter.Entities.IEntity entity)
        {
            IAuthored authoredEntity = (IAuthored)entity;

            // Set the author of the entity
            authoredEntity.Author = AuthenticationState.User;

            base.React(entity);
        }
 public override bool ExecuteSave(SoftwareMonkeys.SiteStarter.Entities.IEntity entity)
 {
     if (entity is User)
     {
         return ExecuteSave((User)entity);
     }
     else
         throw new ArgumentException("The provided entity type '" + entity.GetType().FullName + "' is not supported. The entity must be of type 'User'.");
 }
        public override bool IsValid(SoftwareMonkeys.SiteStarter.Entities.IEntity entity, System.Reflection.PropertyInfo property, SoftwareMonkeys.SiteStarter.Entities.IValidatePropertyAttribute attribute)
        {
            if (property.PropertyType != typeof(String))
                throw new InvalidOperationException("Cannot validate email address because the property type is '" + property.PropertyType.Name + "' when it needs to be string.");

            string value = GetStringValue(entity, property);

            RegExAttribute regExAttribute = (RegExAttribute)attribute;

            return Regex.IsMatch(value, regExAttribute.Expression);
        }
        public override bool IsAuthorised(SoftwareMonkeys.SiteStarter.Entities.IEntity entity)
        {
            if (!AuthenticationState.IsAuthenticated)
                return false;

            IAuthored authoredEntity = (IAuthored)entity;

            ActivateStrategy.New(authoredEntity).Activate(authoredEntity, "Author");

            return authoredEntity.IsPublic
                || (authoredEntity != null && authoredEntity.Author.ID == AuthenticationState.User.ID);
        }
        public override bool IsAuthorised(SoftwareMonkeys.SiteStarter.Entities.IEntity entity)
        {
            IAuthored authoredEntity = (IAuthored)entity;

            // If the user is an administrator they are authorised
            if (AuthenticationState.UserIsInRole("Administrator"))
                return true;

            // If the current user is the author
            if (UserIsAuthor((IAuthored)entity))
                return true;
            else
                // otherwise NOT authorised
                return false;
        }
 public override bool IsAuthorised(SoftwareMonkeys.SiteStarter.Entities.IEntity entity)
 {
     return true;
 }
        public override void React(SoftwareMonkeys.SiteStarter.Entities.IEntity entity)
        {
            entity.DateCreated = DateTime.Now;

            base.React(entity);
        }
 public override bool IsValid(SoftwareMonkeys.SiteStarter.Entities.IEntity entity, System.Reflection.PropertyInfo property, SoftwareMonkeys.SiteStarter.Entities.IValidatePropertyAttribute attribute)
 {
     return true;
 }