protected override void ValidationRules() { AddRule("EmptyName", ResourceStringLoader.GetResourceString("Pet_EmptyName"), string.IsNullOrEmpty(this.Name)); AddRule("MaxNameLength", ResourceStringLoader.GetResourceString("Pet_MaxNameLength"), !string.IsNullOrEmpty(this.Name) && this.Name.Length > 100); AddRule("EmptyCreatedBy", ResourceStringLoader.GetResourceString("Pet_EmptyCreatedBy"), string.IsNullOrEmpty(this.CreatedBy)); AddRule("MaxCreatedByLength", ResourceStringLoader.GetResourceString("Pet_MaxCreatedByLength"), !string.IsNullOrEmpty(this.CreatedBy) && this.CreatedBy.Length > 256); AddRule("DuplicatedName", ResourceStringLoader.GetResourceString("Pet_DuplicatedName", new { this.Name }), !string.IsNullOrEmpty(this.Name) && this.ChangedProperties.Contains("Name") && Pet.GetPets(null, this.Name).Count(m => m.ID != this.ID) > 0); AddRule("EmptyLastUpdatedBy", ResourceStringLoader.GetResourceString("Pet_EmptyLastUpdatedBy"), !this.IsNew && this.IsChanged && string.IsNullOrEmpty(this.LastUpdatedBy)); AddRule("MaxLastUpdatedByLength", ResourceStringLoader.GetResourceString("Pet_MaxLastUpdatedByLength"), !this.IsNew && this.IsChanged && !string.IsNullOrEmpty(this.LastUpdatedBy) && this.LastUpdatedBy.Length > 256); }
protected override void ValidationRules() { AddRule("EmptyName", ResourceStringLoader.GetResourceString("StateEntity_EmptyName"), string.IsNullOrEmpty(this.Name)); AddRule("MaxNameLength", ResourceStringLoader.GetResourceString("StateEntity_MaxNameLength"), !string.IsNullOrEmpty(this.Name) && this.Name.Length > 100); AddRule("EmptyCreatedBy", ResourceStringLoader.GetResourceString("StateEntity_EmptyCreatedBy"), string.IsNullOrEmpty(this.CreatedBy)); AddRule("MaxCreatedByLength", ResourceStringLoader.GetResourceString("StateEntity_MaxCreatedByLength"), !string.IsNullOrEmpty(this.CreatedBy) && this.CreatedBy.Length > 256); AddRule("DuplicatedName", ResourceStringLoader.GetResourceString("StateEntity_DuplicatedName", new { this.Name }), !string.IsNullOrEmpty(this.Name) && this.ChangedProperties.Contains("Name") && StateEntity.GetStateEntities(this.Name).Where(m => m.ID != this.ID).Count() > 0); AddRule("EmptyLastUpdatedBy", ResourceStringLoader.GetResourceString("StateEntity_EmptyLastUpdatedBy"), !this.IsNew && this.IsChanged && string.IsNullOrEmpty(this.LastUpdatedBy)); AddRule("MaxLastUpdatedByLength", ResourceStringLoader.GetResourceString("StateEntity_MaxLastUpdatedByLength"), !this.IsNew && this.IsChanged && !string.IsNullOrEmpty(this.LastUpdatedBy) && this.LastUpdatedBy.Length > 256); AddRule("HasConcurrencyConflict", "The item has been already changed or processed. Click on refresh to get latest changes.", !this.IsNew && this.HasConcurrencyConflict); }