ProviderHostedCustomUIActionsWeb.Models.ContactsListManager.AddNewContact C# (CSharp) Method

AddNewContact() public method

public AddNewContact ( ) : void
return void
        public void AddNewContact()
        {
            ListItem newItem = contactsList.AddItem(new ListItemCreationInformation());
              Customer customer = CustomerFactory.GetRandomCustomer();
              newItem["FirstName"] = customer.FirstName;
              newItem["Title"] = customer.LastName;
              newItem["Company"] = customer.Company;
              newItem["Email"] = customer.EmailAddress;
              newItem["WorkPhone"] = customer.WorkPhone;
              newItem["HomePhone"] = customer.HomePhone;
              newItem.Update();
              clientContext.ExecuteQuery();
        }

Same methods

ContactsListManager::AddNewContact ( string FirstName, string LastName, string Company, string Email, string WorkPhone, string HomePhone ) : void

Usage Example

 public ActionResult AddNewItem(string SPListId)
 {
     ContactsListManager contactsListManager = new ContactsListManager(new Guid(SPListId));
       contactsListManager.AddNewContact();
       return View();
 }