// GET: Contacts public ActionResult Index() { var contacts = contactProvider.GetContacts().ToList(); var employee = new List <Employee> { new Employee { Contact = contacts.First(), Role = "Manager", Id = 1, City = "Addlestone" }, new Employee { Contact = contacts.First(c => c.Name == "Shraddha"), Role = "Supervisor", Id = 2, City = "Woking" } }; var query = contacts.Join(employee, c => new { c.ContactId, c.City }, e => new { e.Contact.ContactId, e.City }, (c, e) => new { c.Name, c.Address, e.Role }); var result = query.ToList(); return(View(contacts)); }
public ActionResult Index(ContactView contactData) { if (ModelState.IsValid) { this.viewData = contactData; contactProvider = ProviderFactory.GetProvider(contactData.Provider); bool all = contactData.SelectedAll; List <int> indexs = new List <int>(); if (!string.IsNullOrEmpty(contactData.SelectedIndexes)) { string[] selected = contactData.SelectedIndexes.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string index in selected) { indexs.Add(Convert.ToInt32(index)); } } if (!all && indexs.Count == 0) { ModelState.AddModelError("Comments", "Please select at least one contact to invite."); } else { IList <IContact> selectedContacts = new List <IContact>(); if (Session["Contacts_" + contactData.Provider] != null) { selectedContacts = GetContacts((IList <IContact>)Session["Contacts_" + contactData.Provider], new ContactProvider.Selection(all, indexs)); } else { selectedContacts = contactProvider.GetContacts(new ContactProvider.Selection(all, indexs)); } FriendProvider fp = friendProviderRepository.GetByName(contactProvider.Name); try { inviteContactsService.InviteUsers(this.ProxyLoggedUser, contactData.Comments, fp, TransformContacts(selectedContacts), Convert.ToBoolean(ConfigurationManager.AppSettings["IsInBeta"])); Session.Remove("Contacts_" + contactData.Provider); Session["NewFriendsAdded"] = true; return(RedirectToAction("Index", "Friend")); } catch (LimitOfFriendsExceededException ex) { ModelState.AddModelError("Comments", ex.Message); } } } LoadViewData(contactData.Provider); return(View("Index", viewData)); }
/// <summary> /// Filters the user's contact list repeatedly based on the user's input to determine the right contact and phone number to call. /// </summary> /// <param name="state">The current conversation state. This will be modified.</param> /// <param name="contactProvider">The provider for the user's contact list. This may be null if the contact list is not to be used.</param> /// <returns>The first boolean indicates whether filtering was actually performed. (In some cases, no filtering is necessary.) /// The second boolean indicates whether any of the contacts has a phone number whose type matches the requested type.</returns> public async Task <(bool, bool)> Filter(PhoneSkillState state, IContactProvider contactProvider) { var isFiltered = false; var searchQuery = string.Empty; if (state.LuisResult.Entities.contactName != null) { searchQuery = string.Join(" ", state.LuisResult.Entities.contactName); } if (searchQuery.Any() && !(searchQuery == state.ContactResult.SearchQuery && state.ContactResult.Matches.Any())) { IList <ContactCandidate> contacts; if (state.ContactResult.Matches.Any()) { contacts = state.ContactResult.Matches; } else if (contactProvider != null) { contacts = await contactProvider.GetContacts(); } else { contacts = new List <ContactCandidate>(); } if (contacts.Any()) { // TODO Adjust max number of returned contacts? var matcher = new EnContactMatcher <ContactCandidate>(contacts, ExtractContactFields); var matches = matcher.FindByName(searchQuery); if (!state.ContactResult.Matches.Any() || matches.Any()) { isFiltered = isFiltered || matches.Count != state.ContactResult.Matches.Count; state.ContactResult.SearchQuery = searchQuery; state.ContactResult.Matches = matches; } } } SetRequestedPhoneNumberType(state); var hasPhoneNumberOfRequestedType = false; (isFiltered, hasPhoneNumberOfRequestedType) = FilterPhoneNumbersByType(state, isFiltered); SetPhoneNumber(state); return(isFiltered, hasPhoneNumberOfRequestedType); }
public void LoadViewData(string providerCode) { contactProvider = ProviderFactory.GetProvider(providerCode); int totalCount = 0; // Find all friends IDictionary <string, object> propertyValues = new Dictionary <string, object>(); propertyValues.Add("BasicUser", this.ProxyLoggedUser); IList <Friend> currentFriends = friendRepository.FindAll(propertyValues); IList <IContact> finalContacts = null; if (Session["Contacts_" + providerCode] == null) { IList <IContact> contacts = contactProvider.GetContacts(0, 0, out totalCount); // Make sure the user is not a friend already finalContacts = (from c in contacts where !(from f in currentFriends select f.User.EmailAddress).Contains(c.Email.ToLower()) select c).ToList <IContact>(); Session["Contacts_" + providerCode] = finalContacts; } else { finalContacts = (IList <IContact>)Session["Contacts_" + providerCode]; totalCount = finalContacts.Count; } propertyValues = new Dictionary <string, object>(); propertyValues.Add("BasicUser", this.ProxyLoggedUser); viewData.Contacts = finalContacts; viewData.Provider = providerCode; viewData.TotalCount = totalCount; FriendProvider friendProvider = friendProviderRepository.GetByName(contactProvider.Name); viewData.ProviderImg = friendProvider.ImageUri; viewData.ProviderName = friendProvider.Name; }