public void DeleteContact(int id) { if (this.Contacts % id == 0) { this.Contacts /= id; MyDatabase.DeleteColumn(table, "C" + id * this.Id); int oldContact1 = MyDatabase.RetrieveInt(table, "Contacts", "ID", this.Id); int oldContact2 = MyDatabase.RetrieveInt(table, "Contacts", "ID", id); MyDatabase.ChangeInt(table, "Contacts", oldContact1 / id, "ID", this.Id); MyDatabase.ChangeInt(table, "Contacts", oldContact2 / id, "ID", id); } }
public Contact AddNewContact(int id) { if (!Methods.IsPrime(id) || Contacts % id == 0) { return(null); // check for the number to be possible to be an ID } IDs = new List <int>(); MyDatabase.RetrieveInfo(table, "ID", ref IDs); if (!Methods.IntBelongsToArray(id, IDs.ToArray(), IDs.Count - 1)) { return(null); } this.AddContactToDatabase(id); int oldContact2 = MyDatabase.RetrieveInt(table, "Contacts", "ID", id); MyDatabase.ChangeInt(table, "Contacts", oldContact2 * this.Id, "ID", id); Conversation.AddConversationToDatabase(id, this.Id); this.Contacts *= id; return(new Contact(id)); }
public Contact AddNewContact(string username) { Usernames = new List <string>(); MyDatabase.RetrieveInfo(table, "Username", ref Usernames); foreach (string uname in Usernames) { if (uname == username && this.Username != username && username != "admin") { int id = MyDatabase.RetrieveInt(table, "ID", "Username", username); if (this.Contacts % id == 0) { return(null); } MyDatabase.ChangeInt(table, "Contacts", this.Contacts * id, "Username", this.Username); int contacts = MyDatabase.RetrieveInt(table, "Contacts", "ID", id); MyDatabase.ChangeInt(table, "Contacts", contacts * this.Id, "ID", id); Conversation.AddConversationToDatabase(id, this.Id); this.Contacts *= id; return(new Contact(id)); } } return(null); }