Example #1
0
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            ParseMode = null;
            IList<Logic.Entities.Contact> contacts;
            int alreadyExist = 0;
            if (ValidateContacts(out contacts))
            {
                IList<Logic.Entities.Contact> toAdd = new List<Logic.Entities.Contact>();
                IList<Logic.Entities.Contact> resolved = new List<Logic.Entities.Contact>();
                Endpoint.ResolveContactIdByEmail(CurrentCompany, ref contacts, out resolved, out toAdd);

                alreadyExist = resolved.Count;

                /*
                foreach (Logic.Entities.Contact contact in contacts)
                {
                    Logic.Entities.Contact current = Endpoint.GetContactByEmail(contact.Email, CurrentCompany);
                    if (current != null)
                    {
                        ++alreadyExist;
                    }
                    else
                    {
                        toAdd.Add(contact);
                    }
                }*/

                if (toAdd.Count > 0)
                {
                    Endpoint.AddContactsToCompany(CurrentCompany, toAdd);

                    // Concatinating new list of contacts with all of them having CDM IDs
                    List<Logic.Entities.Contact> c = new List<Logic.Entities.Contact>();
                    c.AddRange(toAdd);
                    c.AddRange(resolved);
                    contacts = c;
                }
                if (toAdd.Count + alreadyExist > 0)
                {
                    string message = string.Format("{0} new participants were added.", toAdd.Count);
                    if (alreadyExist > 0)
                    {
                        message += string.Format(" In addition, {0} participants " +
                            "were already in our database and were not modified.",
                            alreadyExist);
                    }
                    Session[Support.Constants.Session.PeopleUploadInfo] = message;
                }
                Response.Redirect("~/People/Default.aspx");

                /*InitializeCoursePlanningView(contacts);
                mvImportWizard.ActiveStepIndex++;*/
            }
        }
Example #2
0
 protected void btnUpload_Click(object sender, EventArgs e)
 {
     if (fuContacts.HasFile)
     {
         mvImportWizard.ActiveStepIndex ++;
         using (Helpers.ContactFileParser parser =
                new Helpers.ContactFileParser(fuContacts.FileContent))
         {
             List<Logic.Entities.Contact> contacts = parser.Parse();
             if (contacts.Count > 0)
             {
                 if (parser.Errors.Count > 0)
                 {
                     ParseMode = ParseResultMode.Warnings;
                 }
                 else
                 {
                     ParseMode = ParseResultMode.Success;
                 }
                 rptrContacts.DataSource = contacts;
                 rptrContacts.DataBind();
             }
             else
             {
                 ParseMode = ParseResultMode.NoData;
             }
             if (parser.Errors.Count > 0)
             {
                 rptrWarnings.DataSource = parser.Errors;
                 rptrWarnings.DataBind();
             }
         }
     }
     else
     {
         pNoFile.Visible = true;
     }
 }