/// <summary>
 /// Initializes a new instance of the <see cref="User"/> class.
 /// </summary>
 /// <param name="p">the instance of class User</param>
 /// <see cref="User" /> class
 public User(User p)
 {
     this.Id = p.Id;
     this.Login = p.Login;
     this.Password = p.Password;
     this.RolesId = p.RolesId;
 }
 /// <summary>
 /// Special interface for logged user
 /// </summary>
 /// <param name="user">Logged user</param>
 private static void LoggedInterface(User user)
 {
     List<UserAbbilities> abbilities = new List<UserAbbilities>();
 }
 /// <summary>
 /// Method for creating abbility list for user
 /// </summary>
 /// <param name="user">Logged user</param>
 /// <returns>list of UserAbbilities</returns>
 private static List<UserAbbilities> BuildAbbilityList(User user)
 {
     List<UserAbbilities> abbilities = new List<UserAbbilities>();
     foreach (int i in user.RolesId)
     {
         AbbilitiesAdd(abbilities, UserControls.GetRoleById(i));
     }
     return abbilities;
 }
 private static void SaveUserDB(XmlDocument doc, User myUser)
 {
     XmlNode root = doc.DocumentElement;
     XmlElement newID = doc.CreateElement("UserId");
     XmlAttribute attrID = doc.CreateAttribute("user_id");
     attrID.Value = myUser.Id.ToString();
     newID.SetAttributeNode(attrID);
     root.InsertAfter(newID, root.LastChild);
     XmlElement uLogin = doc.CreateElement("UserLogin");
     XmlElement uPassword = doc.CreateElement("UserPassword");
     XmlElement uRole = doc.CreateElement("UserRole");
     XmlText usLog = doc.CreateTextNode(myUser.Login);
     XmlText usPass = doc.CreateTextNode(myUser.Password);
     string temp = "";
     foreach (int i in myUser.RolesId)
     {
         temp = temp + i.ToString() + "|";
     }
     XmlText usRole = doc.CreateTextNode(temp);
     uLogin.AppendChild(usLog);
     uPassword.AppendChild(usPass);
     uRole.AppendChild(usRole);
     root.InsertAfter(uLogin, root.LastChild);
     root.InsertAfter(uPassword, root.LastChild);
     root.InsertAfter(uRole, root.LastChild);
 }
 public User GetUserById(int id)
 {
     User retUsr = new User();
     bool found = false;
     foreach (User usr in this.Users)
     {
         if (usr.Id == id)
         {
             retUsr = usr;
             found = true;
             break;
         }
         else
         {
             continue;
         }
     }
     if (found)
     {
         return retUsr;
     }
     else
     {
         throw new ArgumentException("No order with id: >" + id.ToString() + "< found");
     }
 }
 public void Add(User newUser)
 {
     this.users.Add(newUser);
 }