Пример #1
0
        public void AddBus(DO.Bus bus)
        {
            XElement bussRootElem;

            try
            {
                bussRootElem = XmlTools.LoadListFromXMLElement(bussPath);
            }
            catch (DO.XmlFileLoadCreateException ex)
            {
                throw ex;
            }
            var temp = (from b in bussRootElem.Elements()
                        where b.Element("LicenseNum").Value == bus.LicenseNum.ToString()
                        select b).FirstOrDefault();

            if (temp != null)
            {
                if (!bool.Parse(temp.Element("IsDeleted").Value))
                {
                    throw new DO.BadBusException(bus.LicenseNum, "Duplicate License number of bus");
                }
            }

            bussRootElem.Add(XmlTools.CreateElement(bus));
            XmlTools.SaveListToXMLElement(bussRootElem, bussPath);
        }