//--------------menage mothers---------------// /// <summary> /// adds a mother to the data base /// Exception: /// in the data base is are a mother with the same ID /// </summary> /// <param name="mam">mother object to add</param> public void addMother(Mother mam) { if (DataSourceXml.MotherRoot.Elements().Any(x => (Convert.ToInt32(x.Element("Id").Value)) == mam.Id)) { throw new DALException("ERROR: There is the same mother id already"); } DataSourceXml.MotherRoot.Add(mam.MotherToXML()); DataSourceXml.saveMothers(); }
public void removeMother(int id) { XElement result = (from mother in DataSourceXml.MotherRoot.Elements() where Convert.ToInt32(mother.Element("Id").Value) == id select mother).FirstOrDefault(); if (result != null) { result.Remove(); DataSourceXml.saveMothers(); } else { throw new DALException("ERROR: There is no Mother with this id to remove"); } }