private void LabelNumberTappedEvent(object sender, System.EventArgs e) { PhoneContact.CreateContact(new Account() { Name = labelName.Text, Number = labelNumber.Text, Company = labelCompany.Text, Email = labelEmail.Text, Skype = labelSkype.Text }); }
public PhoneContactWrapper(PhoneContact pc) { FirstName = pc.FirstName; LastName = pc.LastName; PhoneNumber = pc.PhoneNumber; ImageSource = pc.ImageSource; }
public ActionResult UpdateContact(PhoneContact contact) { try { PhoneContact selectedContact = phoneContactContext.phoneContacts.Find(contact.Id); if (selectedContact == null) { ViewBag.message = "No suche user"; } else { ViewBag.message = "Ok"; selectedContact.Id = contact.Id; selectedContact.Name = contact.Name; selectedContact.Surname = contact.Surname; selectedContact.BirthDay = contact.BirthDay; selectedContact.Usluga = contact.Usluga; selectedContact.PhoneNumber = contact.PhoneNumber; phoneContactContext.SaveChanges(); } return(View()); } catch (Exception exp) { return(View()); } }
public void WritePhoneContact() { string exceptionMes = string.Empty; Contact phoneContact = new PhoneContact(); Contact standard = new PhoneContact("Yuriy", "5432167890"); StreamWriter streamWriter = new StreamWriter("../../PhoneContactOutput.txt"); try { standard.Write(streamWriter); streamWriter.Close(); streamWriter.Dispose(); StreamReader streamReader = new StreamReader("../../PhoneContactOutput.txt"); phoneContact.Read(streamReader); streamReader.Close(); streamReader.Dispose(); } catch (ArgumentException mes) { exceptionMes = mes.Message; } Assert.AreEqual(phoneContact.Name, standard.Name); Assert.AreEqual(phoneContact.Data, standard.Data); Assert.AreEqual(exceptionMes, string.Empty); }
public async Task <Response> SaveResident(ResidentRequest residentResquest) { var residentId = GetMaterializeResidentId(residentResquest.BlockNumber, residentResquest.HouseNumber); var getResidentDuplicated = _securityPaymentContext.ResidentInformation.ToList() .Find(x => x.ResidentInformationId == residentId); if (getResidentDuplicated == null) { ControlTransactionFields transactionInfo = TransactionInfo.GetTransactionInfo(); IDbContextTransaction transaction = _securityPaymentContext.Database.BeginTransaction(); ResidentInformation residentInformation = MaterializeGeneralResidentInformation(residentResquest, residentId, transactionInfo); PhoneContact phoneContact = MaterializeContactInformation(residentResquest, residentId, transactionInfo); EmailContact emailContact = MaterializeEmailContact(residentResquest, residentId, transactionInfo); HouseInformation houseInformation = MaterializeHouseInformation(residentResquest, residentId, transactionInfo); await _securityPaymentContext.AddAsync <ResidentInformation>(residentInformation); await _securityPaymentContext.AddAsync <PhoneContact>(phoneContact); await _securityPaymentContext.AddAsync <EmailContact>(emailContact); await _securityPaymentContext.AddAsync <HouseInformation>(houseInformation); await _securityPaymentContext.SaveChangesAsync(); transaction.Commit(); return(new Response { Data = residentInformation }); } return(new Response { Message = "Failed, the resident already exist!" }); }
public ActionResult UpdateSave(PhoneContact phoneContact) { _phoneContacts = _phoneContacts.Select(c => c.Id == phoneContact.Id ? new PhoneContact(phoneContact.Id, phoneContact.Name, phoneContact.Phone) : c).ToList(); _phoneContacts = ContactsHandler.WriteToJsonFile(_phoneContacts); return(RedirectToAction("Index")); }
public MethodResult RemindContact(RemindRequest remindRequest) { Guid requestorId = new Guid(remindRequest.RequestorId); var resCode = Context.GetUserCountryCode(requestorId); string initiatorCountryCode = resCode.FirstOrDefault().ToString(); remindRequest.ContactNumbersForRemindFormatted = new List <PhoneContact>(); if (remindRequest.UserIdsForRemind == null) { remindRequest.UserIdsForRemind = new List <string>(); if (remindRequest.EventId == null) { throw new Exception("No event or contacts specified."); } } if (remindRequest.UserIdsForRemind.Count > 0) { remindRequest.ContactNumbersForRemindFormatted = remindRequest.UserIdsForRemind.Select(userId => { //PhoneContact pc = PhoneNumberHelper.FormatMobileNumberAndCountryCode(initiatorCountryCode, new PhoneContact() { MobileNumber = contact, MobileNumberStoredInRequestorPhone = contact }, this.countryCodes); //pc.GCMClientId = GetGcmClientIdForMobile(new GcmClientIdRequest() { MobileNumber = pc.MobileNumber, CountryCode = pc.CountryCode}); PhoneContact pc = new PhoneContact(); pc.UserId = userId; pc.GCMClientId = GetGcmClientIdOfUser(userId); return(pc); }).ToList(); } else { Event currentEvent = GetEventsInternal(new EventRequest() { EventId = remindRequest.EventId.ToString(), RequestorId = remindRequest.RequestorId.ToString() }).FirstOrDefault(); remindRequest.EventName = currentEvent.Name; foreach (EventParticipant user in currentEvent.UserList) { PhoneContact pc = new PhoneContact() { UserId = user.UserId, MobileNumber = user.MobileNumber, CountryCode = user.CountryCode }; pc.GCMClientId = GetGcmClientIdOfUser(pc.UserId); remindRequest.ContactNumbersForRemindFormatted.Add(pc); } } pushNotifier = new DefaultNotificationManager(); MethodResult mr = new MethodResult(); mr.Status = pushNotifier.NotifyRemindContact(remindRequest); return(mr); }
public ActionResult AddSave(PhoneContact phoneContact) { _phoneContacts.Add(phoneContact); _phoneContacts = ContactsHandler.WriteToJsonFile(_phoneContacts); return(RedirectToAction("Index")); }
/// <summary> /// /// </summary> /// <param name="number"></param> /// <returns></returns> public static PhoneContact ParseNumber(string number, string requestorCountryCode) { PhoneContact pc = new PhoneContact(); pc.MobileNumberStoredInRequestorPhone = number; try { var phoneNumberUtil = PhoneNumbers.PhoneNumberUtil.GetInstance(); int countryCode = phoneNumberUtil.MaybeExtractCountryCode(number, null, new StringBuilder(number), true, new PhoneNumber.Builder()); string region = "IN"; if (countryCode == 0) { countryCode = int.Parse(requestorCountryCode.Split("+", StringSplitOptions.None)[1]); } region = phoneNumberUtil.GetRegionCodeForCountryCode(countryCode); var phoneNumber = phoneNumberUtil.Parse(number, region); pc.CountryCode = "+" + phoneNumber.CountryCode.ToString(); pc.MobileNumber = phoneNumber.NationalNumber.ToString(); } catch { } return(pc); }
public ActionResult DeleteSave(PhoneContact phoneContact) { _phoneContacts.RemoveAll(c => c.Id == phoneContact.Id); _phoneContacts = ContactsHandler.WriteToJsonFile(_phoneContacts); return(RedirectToAction("Index")); }
public PhoneContactViewModel(PhoneContact contact) { Contact = contact; NotifyOfPropertyChange(nameof(ContactName)); NotifyOfPropertyChange(nameof(ContactNumber)); NotifyOfPropertyChange(nameof(ContactAddress)); }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { FriendViewModel friendsCategory = item as FriendViewModel; if (friendsCategory != null) { return(IsFriends); } else { PhoneContact contactCategory = item as PhoneContact; if (contactCategory != null) { return(IsContacts); } else { UserInfo info = item as UserInfo; if (info != null) { return(IsOtherUsers); } } } return(base.SelectTemplate(item, container)); }
private static void AddPhoneNumbersToPhoneContact(IEnumerable<string> phoneNumbers, PhoneContact phoneContact) { foreach (var phoneNumber in phoneNumbers) { phoneContact.PhoneEntries.Add(phoneNumber); } }
public IEnumerable <PhoneContact> GetAllContacts() { var phoneContacts = new List <PhoneContact>(); using (var phones = Android.App.Application.Context.ContentResolver.Query( ContactsContract.CommonDataKinds.Phone.ContentUri, null, null, null, null)) { if (phones != null) { while (phones.MoveToNext()) { try { string name = phones.GetString( phones.GetColumnIndex( ContactsContract.Contacts.InterfaceConsts.DisplayName)); string photoUri = phones.GetString( phones.GetColumnIndex( ContactsContract.Contacts.InterfaceConsts.PhotoUri)); string phoneNumber = phones.GetString( phones.GetColumnIndex( ContactsContract.CommonDataKinds.Phone.Number)); string[] words = name.Split(' '); var contact = new PhoneContact(); contact.FirstName = words[0]; if (words.Length > 1) { contact.LastName = words[1]; } else { contact.LastName = ""; //no last name } contact.PhoneNumber = phoneNumber; contact.PhotoUri = photoUri; phoneContacts.Add(contact); } catch { //something wrong with one contact, may be display name is completely empty, decide what to do } } phones.Close(); } // if we get here, we can't access the contacts. Consider throwing an exception to display to the user } return(phoneContacts); }
public async Task AcquirePhoneContacts(Boolean sort) { var permission = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Contacts); if (permission.Equals(PermissionStatus.Granted)) { PhoneContacts.Clear(); List <string> contactNumbers = new List <string>(); var contacts = await Plugin.ContactService.CrossContactService.Current.GetContactListAsync(); if (sort) { contacts = contacts.OrderBy(c => c.Name).ToList(); } string[] splitParam = new string[] { "stringValue=" }; foreach (Contact c in contacts) { // TODO: look at this logic again // Contact.Number contains string listed below: // <CNPhoneNumber: 0x1c4a33520: stringValue=5127994767, initialCountryCode=(null)> PhoneContact pc = new PhoneContact() { Status = FriendStatus.NotRegistered, Name = c.Name, PhoneNumber = ExtractPhoneNumber(c.Number), PhoneNumbers = new List <String>() { ExtractPhoneNumber(c.Number) } }; contactNumbers.Add(pc.PhoneNumber); foreach (string str in c.Numbers) { string multi = ExtractPhoneNumber(str); if (!pc.PhoneNumber.Equals(multi)) { contactNumbers.Add(multi); pc.PhoneNumbers.Add(multi); } } PhoneContacts.Add(pc); } UserPhoneNumbers upn = new UserPhoneNumbers() { Numbers = contactNumbers, UserId = App.AppUser.id }; await AcquireUsersFromPhoneNumbers(upn); } else { throw new InvalidOperationException("contacts permission is not granted"); //await Navigation.PopAsync(); //await Navigation.PushAsync(new IssuePage("Please provide permission to access contacts.")); //await App.Current.MainPage.Navigation.PushAsync(new IssuePage("Please provide permission to access contacts.")); //await Navigation.PushAsync(new IssuePage("Please provide permission to access contacts.")); //await Navigation.PopAsync(); } }
public async Task <PhoneContact> AddContact(PhoneContact phoneContact) { _phoneContactsContext.PhoneContacts.Add(phoneContact); await _phoneContactsContext.SaveChangesAsync(); return(phoneContact); }
public async void OnEdit(PhoneContact phoneContact) { App.ContatoVM.PhoneContactModel = phoneContact; await App.Current.MainPage.Navigation.PushAsync(new ContactView() { BindingContext = App.ContatoVM }); }
public async Task <PhoneContact> UpdatePhoneContact(PhoneContact phoneContact) { _phoneContactsContext.Entry(phoneContact).State = EntityState.Modified; await _phoneContactsContext.SaveChangesAsync(); return(phoneContact); }
public FormLayoutContactInfo() { Email = new EmailContact(); Phone = new PhoneContact(); SMS = new SMSContact(); InstantMessenger = new InstantMessengerContact(); PostalService = new PostalServiceContact(); }
Task OpenDetailPage(PhoneContact contact) { if (contact == null) { return(Task.CompletedTask); } return(Navigation.PushAsync(new ContactDetailPage(contact))); }
public async Task <IEnumerable <PhoneContact> > GetAllContacts() { var contactList = new List <PhoneContact>(); //var uri = ContactsContract.CommonDataKinds.Phone.ContentUri; var uri = ContactsContract.Contacts.ContentUri; //string[] projection = { ContactsContract.Contacts.InterfaceConsts.Id, //ContactsContract.Contacts.InterfaceConsts.DisplayName, //ContactsContract.CommonDataKinds.Phone.Number, //ContactsContract.CommonDataKinds.Email.Address //}; //var uri = ContactsContract.Contacts.ContentUri; var projection = new string[] { ContactsContract.Contacts.InterfaceConsts.LookupKey, ContactsContract.Contacts.InterfaceConsts.DisplayName, ContactsContract.CommonDataKinds.Phone.Number, ContactsContract.Contacts.InterfaceConsts.PhotoThumbnailUri }; await Task.Run(() => { //var cursor = Android.App.Application.Context.ContentResolver.Query(uri, projection, null, null, null); ICursor cursorLookUpKey = Application.Context.ContentResolver.Query(uri, projection, null, null, null); if (cursorLookUpKey.MoveToFirst()) { do { try { var lookupKey = cursorLookUpKey.GetString(cursorLookUpKey.GetColumnIndex(projection[0])); string fullName = cursorLookUpKey.GetString(cursorLookUpKey.GetColumnIndex(projection[1])); string phone = cursorLookUpKey.GetString(cursorLookUpKey.GetColumnIndex(projection[2])); var photoUri = Android.Net.Uri.Parse(new System.Uri(cursorLookUpKey.GetString(cursorLookUpKey.GetColumnIndex(projection[3]))).ToString()); var stream = Application.Context.ContentResolver.OpenInputStream(photoUri); if (!string.IsNullOrEmpty(lookupKey) && !string.IsNullOrEmpty(fullName) && !fullName.ToLower().Contains('@')) { //Add contacto to list var muser = new PhoneContact { Id = lookupKey, FullName = fullName.Trim(), PhoneNumber = phone, Email = phone, //PhotoThumbnail = Xamarin.Forms.ImageSource.FromStream(() => stream) }; contactList.Add(muser); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } while (cursorLookUpKey.MoveToNext()); } cursorLookUpKey.Close(); }); //var OrderContactList = contactList.OrderBy(item => item.FullName); return(contactList); }
public void AddPhoneContact(PhoneContact phoneContactRepository) { PhoneContact phoneContact = new PhoneContact(); phoneContact.PhoneNumber = phoneContactRepository.PhoneNumber; phoneContact.ContactId = phoneContactRepository.ContactId; applicationDbContext.PhoneContacts.Add(phoneContact); applicationDbContext.SaveChanges(); }
public void PhoneContactEquels() { PhoneContact contact1 = new PhoneContact("Oleg", 12345); object result = contact1.Clone(); PhoneContact actual = (PhoneContact)result; Assert.AreEqual(contact1.name, actual.name); }
public MessagingViewModel(PhoneContact contact) { Contact = contact; SendMessageCommand = new Command(SendMessage); NumberIsNotInTheContactList = !App.Instance.Contacts.Any(c => c.PhoneNumber.Equals(contact.PhoneNumber)); MessageList = new ObservableCollection <MessageWrapper>(); ManageMessagingCenter(); ReadMessages(); }
public void CompareToTestReturns1() { PhoneContact phoneContact1 = new PhoneContact("natalia", "12345"); PhoneContact phoneContact2 = new PhoneContact("anna", "8654569"); int actual = phoneContact1.CompareTo(phoneContact2); Assert.AreEqual(actual, 1); }
public void CopyTo_Should_Throw_ArgumentException_When_Copy_Target_Is_Not_The_Same_Type_As_Copy_Origin() { Contact emailContact = new EmailContact(); Contact phoneContact = new PhoneContact(); Action act = () => emailContact.CopyTo(phoneContact); act.Should().Throw <ArgumentException>().WithMessage("Copy origin and copy target must be of the same type."); }
public void Address_Property_Should_Throw_ArgumentException_When_Set_To_An_Invalid_Email_Address() { PhoneContact phoneContact = new PhoneContact { PhoneNumber = "1234-4321" }; Action act = () => phoneContact.PhoneNumber = "invalidNumber"; act.Should().Throw <ArgumentException>().WithMessage("'invalidNumber' is not a valid phone number!"); }
public void Address_Property_Should_Throw_ArgumentException_When_Set_To_Null() { PhoneContact phoneContact = new PhoneContact { PhoneNumber = "1234-4321" }; Action act = () => phoneContact.PhoneNumber = null; act.Should().Throw <ArgumentException>().WithMessage("*PhoneNumber cannot be null or empty.*"); }
public IActionResult UpdatePhone(PhoneContact phoneContact) { var item = phoneContactRepository.GetById(phoneContact.PhoneContactId); item.PhoneNumber = phoneContact.PhoneNumber; phoneContactRepository.Save(); return(RedirectToAction("Index")); }
public void PhoneComparator() { PhoneContact contact1 = new PhoneContact("Oleg", 22345); PhoneContact contact2 = new PhoneContact("Wasyl", 12345); int expected = 1; int result = contact1.CompareTo(contact2); Assert.AreEqual(expected, result); }
public void AddContact(PhoneContact phoneContact) { var maxId = _phoneContacts.Count != 0 ? _phoneContacts.Max(x => x.Id) : 0; phoneContact.Id = maxId + 1; _phoneContacts.Add(phoneContact); WriteToFile(); }
public bool AddPhone(string contactName, IEnumerable<string> phoneNumbers) { var phoneEntriesForThisContactName = this.GetAllPhoneEntriesByContactName(contactName); var phoneContactEntry = phoneEntriesForThisContactName.FirstOrDefault(); var isNewEntry = phoneContactEntry == null; if (isNewEntry) { phoneContactEntry = new PhoneContact(contactName); this.phonebookEntries.Add(phoneContactEntry); } AddPhoneNumbersToPhoneContact(phoneNumbers, phoneContactEntry); return isNewEntry; }