// Create a new (empty) record // and put the form into Adding mode private void Add() { RoleCl newRecord = new RoleCl { RoleId = 0 }; this.recordList.Insert(recordIndex, newRecord); this.IsAdding = true; this.OnPropertyChanged(nameof(Current)); }
// Helper method to validate record details private bool ValidateRecord(RoleCl record) { string validationErrors = string.Empty; bool hasErrors = false; if (string.IsNullOrWhiteSpace(record.Rep)) { hasErrors = true; validationErrors = "Role Name must not be empty\n"; } this.LastError = validationErrors; return(!hasErrors); }
// Utility method for copying the details of a record private void CopyRecord(RoleCl source, RoleCl destination) { destination.RoleId = source.RoleId; destination.Rep = source.Rep; }
private void Edit() { this.oldRecord = new RoleCl(); this.CopyRecord(this.Current, this.oldRecord); this.IsEditing = true; }