| Milos Quick Start |
| Typical modifications to BusinessObject source code |
protected override void Configure() { this.PrimaryKeyField = "PK_Users"; this.ForeignKeyField = "FK_Names"; this.ParentTableName = "Users"; this.ParentTablePrimaryKeyField = "PK_UserId"; // Required Field Checking for Users table this.BusinessRules.AddRequiredField("Department", "Users", "The Department is required."); this.BusinessRules.AddRequiredField("Password", "Users", "A Password is required."); }
/// <summary> /// NewInstance /// Used to create a new instance of business object. /// </summary> public static PatientBusinessObject NewInstance() { return new PatientBusinessObject(); }
/// <summary> /// Override PopulateNewRecord /// </summary> /// <param name="newRow"></param> /// <param name="tableName"></param> protected override void PopulateNewRecord(System.Data.DataRow newRow, string tableName) { base.PopulateNewRecord(newRow, tableName); //Create a new guid for a MiscInfo record to be inserted after this record is saved newRow["FK_MiscInfo"] = Guid.NewGuid(); }
public class UserMustHaveEmailAddress : BusinessRule { /// <summary> /// Enforce user email address /// </summary> public UserMustHaveEmailAddress() : base("CommInfo", RuleViolationType.Violation) { } /// <summary> /// Verify that the user has an email address and that it is the primary communication /// </summary> /// <param name="currentRow"></param> /// <param name="rowIndex"></param> public override void VerifyRow(System.Data.DataRow currentRow, int rowIndex) { // Verify that comm types of email do not have an empty value if ((currentRow["iCommType"].ToString() == "2") && (string.IsNullOrEmpty(currentRow["cValue"].ToString()))) { this.LogBusinessRuleViolation(currentRow, rowIndex, "CommInfo", "The email address cannot be empty."); } else { //TODO - search for an email address } } }
/// <summary> /// Gets User table entry corresponding to the User FK in a Names entry. /// </summary> /// <param name="usersKey"></param> /// <returns></returns> public DataSet GetUsersByName(Guid usersKey) { IDbCommand command = this.NewDbCommand("milos_getUsersByFK_Name"); command.CommandType = CommandType.StoredProcedure; this.AddDbCommandParameter(command, "@FK_Name", usersKey); return this.ExecuteQuery(command); }