private static RequirementModel Create(DbDataReader reader) { RequirementModel model; model = new RequirementModel(); model.Load(reader); return(model); }
public void Delete() { QueryInformation query; if (this.Id == Guid.Empty) { Debug.WriteLine("Error: You can delete this record as an actual Database record doesn't exist for it. FeatModel : Delete()"); return; } //We need to delete any associated records first before deleting this Feat record CharacterBonusFeatModel.DeleteAllbyFeatId(this.Id); ClassBonusFeatModel.DeleteAllbyFeatId(this.Id); //TODO: DestinySpherePastLifeFeatModel.DeleteAllByFeatId(this.Id); FeatFeatTypeModel.DeleteAllByFeatId(this.Id); FeatModifierModel.DeleteAllByFeatId(this.Id); FeatRequirementModel.DeleteAllByFeatId(this.Id); ModifierModel.DeleteAllByFeatId(this.Id); RaceBonusFeatModel.DeleteAllByFeatId(this.Id); RequirementModel.DeleteAllbyFeatId(this.Id); //We need to remove any feat entries in other tables for this Feat //Class - PastLifeFeatId ClassModel.UpdatePastLifeFeatIdWithNull(this.Id); //Feat - ParentFeat FeatModel.UpdatedParentFeatWithNull(this.Id); //Race - PastLifeFeatId RaceModel.UpdatePastLifeFeatIdWithNull(this.Id); query = QueryInformation.Create(FeatModel.DeleteQuery); query.CommandType = CommandType.Text; query.Parameters.Add(new QueryParameter("@" + FeatModel.IdField, DbType.Guid, this.Id)); BaseModel.RunCommand(query); //lets reset the ID to empty so the model knows its a new record in case someone calls the save() method afterwards for some reason this.Id = Guid.Empty; }