/// <summary> /// Activates the specified property of the provided entity by retrieving the corresponding references. /// </summary> /// <param name="entity">The entity to activate.</param> /// <param name="propertyName">The name of the property to activate.</param> public virtual void Activate(SoftwareMonkeys.SiteStarter.Entities.IEntity entity, string propertyName) { if (DataAccess.IsInitialized) { DataAccess.Data.Activator.Activate(entity, propertyName); } // DO NOT mark the entity as activated because not all reference properties have been activated }
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); }
/// <summary> /// Activates the provided entity by retrieving the corresponding references. /// </summary> /// <param name="entity">The entity to activate.</param> public virtual void Activate(SoftwareMonkeys.SiteStarter.Entities.IEntity entity) { if (DataAccess.IsInitialized) { DataAccess.Data.Activator.Activate(entity); // Mark the entity as activated because all reference properties have been activated entity.IsActivated = true; } }
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 void React(SoftwareMonkeys.SiteStarter.Entities.IEntity entity) { ActivateStrategy.New(entity).Activate(entity, "Author"); base.React(entity); }
public override bool IsAuthorised(SoftwareMonkeys.SiteStarter.Entities.IEntity entity) { return(true); }