public bool AddAAccount(MobileAccount account)
        {
            var result  = default(bool);
            var results = new List <ValidationResult>();
            var context = new ValidationContext(account);

            if (!Validator.TryValidateObject(account, context, results, true))
            {
                foreach (var error in results)
                {
                    Console.WriteLine(error.ErrorMessage);
                }
            }
            else
            {
                var count = _dictAccount.Count;
                _dictAccount.Add(account.Number, account);
                if (count != _dictAccount.Count)
                {
                    _magazine.Add(account.Number, new DataCallEndMessage());
                    _dictAccount[account.Number].MessageEvent += AcceptAndSend;
                    _dictAccount[account.Number].CallEvent    += AcceptAndSend;
                    result = true;
                }
            }
            return(result);
        }
        public bool AddAAccount(MobileAccount account)
        {
            //XPathDocument xPathDoc = new XPathDocument("mobileOperator.xml");
            //XPathNavigator xPathNavigator= xPathDoc.CreateNavigator();
            //string str = account.Number.ToString();
            //XPathExpression expression = xPathNavigator.Compile("/MobileOperator/_dictAccount/a:KeyValueOfintMobileAccountYbXkmbSP");
            //XPathNodeIterator iterator = xPathNavigator.Select(expression);
            //if (iterator.MoveNext())
            //{
            //    xPathNavigator.AppendChildElement("a:Key", "a:KeyValueOfintMobileAccountYbXkmbSP", "mobileOperator.xml", account.Number.ToString());
            //}

            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load("mobileOperator.xml");
            XmlNodeList xmlNodes = xmlDocument.GetElementsByTagName("a:Key");

            foreach (XmlNode node in xmlNodes)
            {
                if (int.Parse(node.InnerText) == account.Number)
                {
                    return(false);
                }
            }
            XmlNodeList xmlNod = xmlDocument.GetElementsByTagName("_dictAccount");

            foreach (XmlNode node in xmlNod)
            {
                XmlText numberKey  = xmlDocument.CreateTextNode(account.Number.ToString());
                XmlText email      = xmlDocument.CreateTextNode(account.Email.ToString());
                XmlText firstName  = xmlDocument.CreateTextNode(account.FirstNume.ToString());
                XmlText number     = xmlDocument.CreateTextNode(account.Number.ToString());
                XmlText secondName = xmlDocument.CreateTextNode(account.SecondNume.ToString());

                XmlElement userElem1   = xmlDocument.CreateElement("a:KeyValueOfintMobileAccountYbXkmbSP");
                XmlElement userElem11  = xmlDocument.CreateElement("a:Key");
                XmlElement userElem12  = xmlDocument.CreateElement("a:Value");
                XmlElement userElem121 = xmlDocument.CreateElement("Email");
                XmlElement userElem122 = xmlDocument.CreateElement("FirstNume");
                XmlElement userElem123 = xmlDocument.CreateElement("Number");
                XmlElement userElem124 = xmlDocument.CreateElement("SecondNume");
                XmlElement userElem125 = xmlDocument.CreateElement("addressBook");

                userElem11.AppendChild(numberKey);
                userElem121.AppendChild(email);
                userElem122.AppendChild(firstName);
                userElem123.AppendChild(number);
                userElem124.AppendChild(secondName);

                userElem12.AppendChild(userElem121);
                userElem12.AppendChild(userElem122);
                userElem12.AppendChild(userElem123);
                userElem12.AppendChild(userElem124);
                userElem12.AppendChild(userElem125);

                userElem1.AppendChild(userElem11);
                userElem1.AppendChild(userElem12);
                node.AppendChild(userElem1);
                xmlDocument.Save("mobileOperator.xml");
            }


            //var result = default(bool)
            //var results = new List<ValidationResult>();
            //var context = new ValidationContext(account);

            //if (!Validator.TryValidateObject(account, context, results, true))
            //{
            //    foreach (var error in results)
            //    {
            //        Console.WriteLine(error.ErrorMessage);
            //    }
            //}
            //else
            //{
            //    var count = _dictAccount.Count;
            //    _dictAccount.Add(account.Number, account);

            //    if (count != _dictAccount.Count)
            //    {
            //        _magazine.Add(account.Number, new DataCallEndMessage());
            //        _dictAccount[account.Number].MessageEvent += AcceptAndSend;
            //        _dictAccount[account.Number].CallEvent += AcceptAndSend;
            //        result = true;
            //    }
            //}
            return(true);
        }