public void DeleteLeads(Lead lead)
 {
     try
     {
         context.Leads.Attach(lead);
         context.Entry(lead).State = EntityState.Deleted;
         SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public long InsertLeads(Lead lead)
 {
     try
     {
         lead.CreatedTime = DateTime.Now;
         lead.ModifiedTime = DateTime.Now;
         context.Entry(lead).State = EntityState.Added;
         context.SaveChanges();
         return lead.LeadID;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public long UpdateLeads(Lead lead)
 {
     try
     {
       // var Leads = (context.Leads.Where(lead1 => lead1.LeadID == lead.LeadID)).FirstOrDefault();
         var currentLead = context.Leads.Find(lead.LeadID);
        // currentLead.ModifiedTime = DateTime.Now;
         //context.Entry(Leads).State = EntityState.Modified;
         context.Entry(currentLead).CurrentValues.SetValues(lead);
         context.SaveChanges();
         return lead.LeadID;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#4
0
 public void DeleteLeads(Lead lead)
 {
     leadrepository.DeleteLeads(lead);
 }
示例#5
0
        private void ValidateLead(Lead lead)
        {
            if (lead.ContactID != null)
            {
                int companyid = Convert.ToInt32(HttpContext.Current.Session["CompanyID"]);
                var duplicateLead = leadrepository.GetLeadByContactID(lead.ContactID, companyid).FirstOrDefault();
                if (duplicateLead != null && duplicateLead.LeadID != lead.LeadID)
                {
                    if (duplicateLead.ContactID == lead.ContactID)
                    {
                        throw new DuplicateLeadException(String.Format(
                           "Contact Name {0} is already exist",
                        duplicateLead.Contact.FirstName + " " + duplicateLead.Contact.LastName
                        ));

                    }
                }
            }
        }
示例#6
0
        public long UpdateLeads(Lead lead)
        {
            ValidateLead(lead);
            try
            {
                return leadrepository.UpdateLeads(lead);

            }
            catch (Exception ce)
            {

                throw ce;
            }
        }
示例#7
0
        public long InsertLeads(Lead lead)
        {
            ValidateLead(lead);
            try
            {
                return leadrepository.InsertLeads(lead);

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
示例#8
0
        protected void ImportButton_Click(object sender, EventArgs e)
        {
            long count = 0;
            string firstName=null;
            string lastname=null;
            StreamReader Sr =new StreamReader(@"C:\Users\rizwanul.islam\My Projects\Default Collections\C3\C3App\C3App\LeadImport.csv");
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            // System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
            string s;
            bool passedFirstline = false;
            while (!Sr.EndOfStream)
            {
                s = Sr.ReadLine();
                string[] value = s.Split(',');
                if (passedFirstline)
                {
                    DAL.Contact contact=new DAL.Contact();
                    if (value[0]!=null)
                    {
                        firstName = value[0];
                        contact.FirstName = firstName;
                    }
                    else
                    {
                        contact.FirstName = "None";
                    }
                    if (value[1] != null)
                    {
                        lastname = value[1];
                        contact.LastName = lastname;
                    }
                    else
                    {
                        contact.LastName = "None";
                    }
                    if (value[2] != null)
                    {
                        contact.PrimaryEmail = value[2];
                    }
                    else
                    {
                        contact.PrimaryEmail = "None";
                    }
                    contact.CompanyID = Convert.ToInt32(Session["CompanyID"]);
                    contact.CreatedBy = Convert.ToInt64(Session["UserID"]);
                    contact.CreatedTime = DateTime.Now;
                    contact.ModifiedTime = DateTime.Now;
                    Int64 contactID = contactBL.InsertContact(contact);
                    if (contactID!=null)
                    {
                        Lead lead=new Lead();
                        lead.ContactID = contactID;
                        lead.FirstName = firstName;
                        lead.LastName = lastname;
                        lead.CompanyID = Convert.ToInt32(Session["CompanyID"]);
                        lead.CreatedBy = Convert.ToInt64(Session["UserID"]);
                        lead.CreatedTime = DateTime.Now;
                        lead.ModifiedTime = DateTime.Now;
                        Int64 leadID = leadBL.InsertLeads(lead);
                        if (leadID!=0)
                        {
                            count++;
                        }
                    }
                }
                else
                {
                    passedFirstline = true;
                }

            }
            Literal1.Text = "Successfully Imported";
            Label1.Text = count +" "+"Data has been successfully imported to lead";
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", "ShowAlertModal();", true);
        }