Exemplo n.º 1
0
        //--------------menage nannis----------------//

        /// <summary>
        /// adds a nanny to the data base
        /// Exception:
        /// in the data base is are a nanny with the same ID
        /// </summary>
        /// <param name="nan">nanny object to add</param>
        public void addNanny(Nanny nan)
        {
            var check = (from nanny in DataSourceXml.NannyRoot.Elements()
                         where (Convert.ToInt32(nanny.Element("Id").Value)) == nan.Id
                         select nanny).FirstOrDefault();

            if (check == null)
            {
                DataSourceXml.NannyRoot.Add(nan.Clone().NannyToXml());
                DataSourceXml.saveNannis();
            }
            else
            {
                throw new Exception("There is the same nanny already");
            }
        }