public BulgarianPhoneBook(string filePathAndName) : base() { StreamReader file = GetFileFromFilePathAndName(filePathAndName); string line; while ((line = file.ReadLine()) != null) { KeyValuePair <string, string> pair; try { pair = GetDataFromRecord(line); string normalizedName = NormalizeName(pair.Key); string value = GetValueByKey(normalizedName); if (value == null) { ContactsList.Add(normalizedName, pair.Value); OutgoingCallHistory.Add(new Tuple <int, string>(0, normalizedName)); } } catch (InvalidDataException) { continue; } } file.Close(); ChachedHasToChange = true; }
private void Add() { Console.Clear(); config.WriteFore("Name: ", "white", false); string name = Console.ReadLine(); config.WriteFore("Email: ", "white", false); string email = Console.ReadLine(); config.WriteFore("Age: ", "white", false); string answer = Console.ReadLine(); int age = 0; if (answer != "") { age = Convert.ToInt32(answer); } config.WriteFore("Telephone: ", "white", false); string telephone = Console.ReadLine(); config.WriteFore("Address: ", "white", false); string adress = Console.ReadLine(); config.WriteFore("Country: ", "white", false); string country = Console.ReadLine(); config.WriteFore("Observations: ", "white", false); string observations = Console.ReadLine(); listContact.Add(new Contact( name, email, age, telephone, adress, country, observations)); listContact.Save(); }
private void Search() { ContactsList.Clear(); var contacts = new List <Model.Contact>(); using (var sqlCon = new SqlConnection(@"Server=localhost\SQLEXPRESS;Database=PhoneBook;Trusted_Connection=True;")) { sqlCon.Query <Model.Contact, City, Phone, PhoneType, Model.Contact>("searchContact", (contact, city, phone, phoneType) => { var contactForList = contacts.FirstOrDefault(con => con.Id == contact.Id); if (contactForList == null) { contactForList = contact; contactForList.City = new City(); contactForList.PhoneNumbers = new List <Phone>(); contacts.Add(contactForList); } contactForList.City = city; phone.PhoneType = phoneType; contactForList.PhoneNumbers.Add(phone); return(contact); }, new { SearchString = SearchString }, commandType: System.Data.CommandType.StoredProcedure).ToList(); } foreach (Model.Contact con in contacts) { var contactViewModel = new ContactViewModel(con, _cities, _phoneTypes); contactViewModel.OnCotactDeleted += SingleContactDeleted; contactViewModel.EditContactClicked += SingleContactEdit; ContactsList.Add(contactViewModel); } }
public HomeViewModel(ObservableCollection<Contact> contacts) { ContactsList.Add(new Contact("Maria Pi", "809232323")); ContactsList.Add(new Contact("Charlin Agramonte", "809232323")); AddCommand = new Command(OnAddContact); MoreCommand = new Command<Contact>(OnMoreCommand); DeleteCommand = new Command<Contact>(OnDeleteCommand); }
public async void LoadData() { ContactsList.Clear(); List <ContactModel> database = await App.Database.GetContactsAsync().ConfigureAwait(false); foreach (ContactModel contact in database) { ContactsList.Add(contact); } IsLoading = false; }
private void PopulateContacts(object sender, RoutedEventArgs e) { for (int i = 0; i < 10; i++) { ContactsList.Add(new Contact() { Name = "Jan" + i, Surname = "Kowalski" + i, PhoneNumber = "12345678" + i, Sex = i % 2 == 0 ? PersonSex.Male : PersonSex.Female, BirthDate = DateTime.Now, City = "Chicago" }); } }
public void OpenFile(string[] filepath) { try { foreach (var path in filepath) { var VCards = fileService.Open(path); foreach (var vCard in VCards) { ContactsList.Add(new VCardViewModel(imageDialogService, vCard)); } } } catch { throw; } }
public void Reload() { if (Settings.LstContacts != null) { ContactsList.Clear(); foreach (Contact c in Settings.LstContacts) { ContactsList.Add(new Models.Contact() { Name = $"{c.Name} {c.LastName}", Email = c.EmailsAddress.FirstOrDefault(), Number = c.PhoneNumbers.FirstOrDefault().Number, Photo = c.Photo, }); } OnPropertyChanged("ContactsList"); } }
private void OpenNewContactDialog(object sender, RoutedEventArgs e) { AddItemWindow dialog = new AddItemWindow() { Owner = this }; OverlayVisibility = Visibility.Visible; bool?result = dialog.ShowDialog(); OverlayVisibility = Visibility.Collapsed; if (!result.HasValue || !result.Value) { return; } ContactsList.Add(dialog.NewContact); }
public void AddNewPair(string name, string phoneNumber) { string normalizedName = NormalizeName(name); string value = GetValueByKey(normalizedName); if (value != null) { throw new Exception("Key already exist"); } int counter = phoneNumber.Length - 1; StringBuilder data = GetPhoneNumberFromRecord(ref counter, phoneNumber); ContactsList.Add(normalizedName, data.ToString()); OutgoingCallHistory.Add(new Tuple <int, string>(0, normalizedName)); ChachedHasToChange = true; }