private void AddNewRequirementRecord() { RequirementModel reqModel; string tableName; string applyToName; reqModel = new RequirementModel(); tableName = comboCategory.SelectedItem.ToString(); applyToName = comboApplyTo.SelectedItem.ToString(); reqModel.TableNamesId = TableNamesModel.GetIdFromTableName(tableName); if (tableName == "Ability") { reqModel.ApplytoId = AbilityModel.GetIdFromName(applyToName); } else if (tableName == "Alignments") { reqModel.ApplytoId = AlignmentModel.GetIdFromName(applyToName); } else if (tableName == "Attribute") { reqModel.ApplytoId = AttributeModel.GetIdFromName(applyToName); } else if (tableName == "Class") { reqModel.ApplytoId = ClassModel.GetIdFromName(applyToName); } else if (tableName == "Enhancement") { reqModel.ApplytoId = GetEnhancementId(); } else if (tableName == "EnhancementSlot") { reqModel.ApplytoId = GetSlotId(); } else if (tableName == "Feat") { reqModel.ApplytoId = FeatModel.GetIdFromName(applyToName); } else if (tableName == "Race") { reqModel.ApplytoId = RaceModel.GetIdFromName(applyToName); } else if (tableName == "Skill") { reqModel.ApplytoId = SkillModel.GetIdFromName(applyToName); } else { Debug.WriteLine("Error: CategoryName isn't listed :: RequirementDialogClass: AddNewRequirement"); } reqModel.Save(); SelectedRequirementId = reqModel.Id; }
private Guid GetApplyToId() { Guid applyToId; string tableName; applyToId = Guid.Empty; tableName = comboCategory.SelectedItem.ToString(); if (tableName == "Ability") { applyToId = AbilityModel.GetIdFromName(comboApplyTo.SelectedItem.ToString()); } if (tableName == "Alignments") { applyToId = AlignmentModel.GetIdFromName(comboApplyTo.SelectedItem.ToString()); } if (tableName == "Attribute") { applyToId = AttributeModel.GetIdFromName(comboApplyTo.SelectedItem.ToString()); } if (tableName == "Character") { applyToId = Guid.Empty; } if (tableName == "Class") { applyToId = ClassModel.GetIdFromName(comboApplyTo.SelectedItem.ToString()); } if (tableName == "Enhancement") { applyToId = GetEnhancementId(); } if (tableName == "EnhancementSlot") { applyToId = GetSlotId(); } if (tableName == "Feat") { applyToId = FeatModel.GetIdFromName(comboApplyTo.SelectedItem.ToString()); } if (tableName == "Race") { applyToId = RaceModel.GetIdFromName(comboApplyTo.SelectedItem.ToString()); } if (tableName == "Skill") { applyToId = SkillModel.GetIdFromName(comboApplyTo.SelectedItem.ToString()); } return(applyToId); }