示例#1
0
        //** GetRecord **
        //Return a record
        public BodySubtype GetRecord(int id)
        {
            BodySubtype recReturn = new BodySubtype();

            recReturn = records.Find(x => x.ID == id);

            return(recReturn);
        }
示例#2
0
        //** 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);
        }
示例#3
0
        //** 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);
        }