public void UpdateSequentialStopInfoTravelTime(long firstId, long secondId, TimeSpan travelTime)
        {
            XElement userRootElem = XMLTools.LoadListFromXMLElement(sequentialStopInfoPath);

            GetSequentialStopInfo(firstId, secondId);
            XElement mySeq = (from u in userRootElem.Elements()
                              where u.Element("StationCodeF").Value == firstId.ToString() && u.Element("StationCodeS").Value == secondId.ToString()
                              select u).FirstOrDefault();

            if (mySeq != null)
            {
                mySeq.Element("TravelTime").Value = XmlConvert.ToString(travelTime);
                XMLTools.SaveListToXMLElement(userRootElem, sequentialStopInfoPath);
            }
        }
        public void DeleteSequentialStopInfo(long firstId, long secondId)
        {
            XElement userRootElem = XMLTools.LoadListFromXMLElement(sequentialStopInfoPath);

            GetSequentialStopInfo(firstId, secondId);
            XElement mySeq = (from u in userRootElem.Elements()
                              where u.Element("StationCodeF").Value == firstId.ToString() && u.Element("StationCodeS").Value == secondId.ToString()
                              select u).FirstOrDefault();

            if (mySeq != null)
            {
                mySeq.Element("Valid").Value = false.ToString();
                XMLTools.SaveListToXMLElement(userRootElem, sequentialStopInfoPath);
            }
        }
        public void CreateSequentialStopInfo(SequentialStopInfo sequentialStopInfo)
        {
            XElement userRootElem = XMLTools.LoadListFromXMLElement(sequentialStopInfoPath);

            sequentialStopInfo.Valid = true;

            try
            {
                GetSequentialStopInfo(sequentialStopInfo.StationCodeF, sequentialStopInfo.StationCodeS);
            }

            catch (Exception ex)
            {
                if (ex.Message == "no SequentialStopInfo with such license number!!")
                {
                    XElement sequentialStopInfoElem = new XElement("SequentialStopInfo",
                                                                   new XElement("Valid", sequentialStopInfo.Valid.ToString()),
                                                                   new XElement("StationCodeF", sequentialStopInfo.StationCodeF),
                                                                   new XElement("StationCodeS", sequentialStopInfo.StationCodeS),
                                                                   new XElement("Distance", sequentialStopInfo.Distance),
                                                                   new XElement("AverageTime", ""),
                                                                   new XElement("TravelTime", XmlConvert.ToString(sequentialStopInfo.TravelTime)));

                    userRootElem.Add(sequentialStopInfoElem);
                    XMLTools.SaveListToXMLElement(userRootElem, sequentialStopInfoPath);
                }
                else if (ex.Message == "SequentialStopInfoList is not valid!!")
                {
                    XElement per = (from temSeq in userRootElem.Elements()
                                    where temSeq.Element("StationCodeF").Value == sequentialStopInfo.StationCodeF.ToString() && temSeq.Element("StationCodeS").Value == sequentialStopInfo.StationCodeS.ToString()
                                    select temSeq).FirstOrDefault();

                    per.Element("Valid").Value = sequentialStopInfo.Valid.ToString();

                    XMLTools.SaveListToXMLElement(userRootElem, sequentialStopInfoPath);
                }
                return;
            }
            throw new Exception("sequentialStopInfo already exists!!!");
        }
        /// <summary>
        /// add new user to database
        /// </summary>
        /// <param name="user"></param>
        public void CreateUser(User user)
        {
            XElement userRootElem = XMLTools.LoadListFromXMLElement(usersPath);

            user.Valid = true;

            try
            {
                // GetUser(user.Password);
                GetUser(user.UserName);
            }
            catch (Exception ex)
            {
                if (ex.Message == "no user with such UserName!!")
                {
                    XElement userElem = new XElement("User",
                                                     new XElement("Valid", user.Valid.ToString().ToLower()),
                                                     new XElement("UserName", user.UserName),
                                                     new XElement("Password", user.Password),
                                                     new XElement("Permission", user.Permission.ToString()));

                    userRootElem.Add(userElem);
                    XMLTools.SaveListToXMLElement(userRootElem, usersPath);
                }

                else if (ex.Message == "user is not valid!!")
                {
                    XElement per = (from temUser in userRootElem.Elements()
                                    where temUser.Element("UserName").Value == user.UserName
                                    select temUser).FirstOrDefault();

                    per.Element("Valid").Value = user.Valid.ToString();


                    XMLTools.SaveListToXMLElement(userRootElem, usersPath);
                }
                return;
            }
            throw new Exception("user already exists!!!");
        }
        /// <summary>
        /// update password in database
        /// </summary>
        /// <param name="password"></param>
        /// <param name="nameId"></param>
        public void UpdatePassword(string password, string nameId)
        {
            XElement userRootElem = XMLTools.LoadListFromXMLElement(usersPath);

            XElement myUser = (from u in userRootElem.Elements()
                               where u.Element("UserName").Value == nameId
                               select u).FirstOrDefault();

            if (myUser.Element("Valid").Value == "false")
            {
                throw new Exception("user is not valid!!");
            }

            if (myUser == null)
            {
                throw new Exception("no user with such UserName!!");
            }

            if (myUser != null)
            {
                myUser.Element("Password").Value = password;
                XMLTools.SaveListToXMLElement(userRootElem, usersPath);
            }
        }