//** GetRecord ** //Return a record public BodySubtype GetRecord(int id) { BodySubtype recReturn = new BodySubtype(); recReturn = records.Find(x => x.ID == id); return(recReturn); }
//** AddRecord ** //Add a record public int AddRecord(string name) { int newID = 1; if (records.Count > 0) { newID = records.OrderBy(x => x.ID).Last().ID + 1; } BodySubtype toAdd = new BodySubtype(); toAdd.ID = newID; toAdd.Name = name; records.Add(toAdd); return(newID); }
//** DeleteRecord ** //Delete a record public int DeleteRecord(int id) { int errorReturn = 0; //Need to check first if the record is used in another table if (errorReturn == 0) { //Not found in another table, proceed to deletion BodySubtype itemToRemove = records.SingleOrDefault(x => x.ID == id); if (itemToRemove != null) { records.Remove(itemToRemove); } } return(errorReturn); }