public string ImportContacts(GoogleContacts[] obj)
 {
     try
     {
         U_USR_ContactsDAL    ocontactsDAL = new U_USR_ContactsDAL();
         U_USR_Map_ContactDAL omapcntsDAL  = new U_USR_Map_ContactDAL();
         foreach (var item in obj)
         {
             if (string.IsNullOrEmpty(ocontactsDAL.CheckContact_Exist(item.EmailID)))
             {
                 U_USR_Contacts ocontacts = new U_USR_Contacts();
                 ocontacts.Contact_Id     = Guid.NewGuid().ToString();
                 ocontacts.Contact_Source = "Google";
                 ocontacts.Contact_Status = "1";
                 ocontacts.Created_by     = "";
                 ocontacts.Created_Date   = DateTime.Now;
                 ocontacts.Email_Id       = item.EmailID;
                 if (!string.IsNullOrEmpty(item.ContactNo))
                 {
                     ocontacts.Mobile_Number = item.ContactNo;
                 }
                 else
                 {
                     ocontacts.Mobile_Number = "";
                 }
                 ocontacts.Person_Name  = string.IsNullOrEmpty(item.Name) ? string.Empty : item.Name;
                 ocontacts.Updated_by   = "";
                 ocontacts.Updated_Date = DateTime.Now;
                 ocontactsDAL.InsertU_USR_Contacts(ocontacts);
             }
         }
         foreach (var item in obj)
         {
             string contactId = ocontactsDAL.CheckContact_Exist(item.EmailID);
             string mapingId  = omapcntsDAL.CheckMaping_Exist(item.UserId, contactId);
             if (!string.IsNullOrEmpty(contactId) & string.IsNullOrEmpty(mapingId))
             {
                 U_USR_Map_Contact ocontacts = new U_USR_Map_Contact();
                 ocontacts.Id           = Guid.NewGuid().ToString();
                 ocontacts.Contact_Id   = contactId;
                 ocontacts.Usr_Id       = item.UserId;
                 ocontacts.Comments     = "";
                 ocontacts.Created_by   = "";
                 ocontacts.Created_Date = DateTime.Now;
                 ocontacts.Updated_by   = "";
                 ocontacts.Updated_Date = DateTime.Now;
                 bool status = omapcntsDAL.InsertU_USR_Map_Contact(ocontacts);
             }
         }
         return("1"); // 1 successfull
     }
     catch (Exception ex)
     {
         Console.Write(ex);
         return("0"); // 0 indicates unsuccessfull
     }
 }
Esempio n. 2
0
 private void SetParameters(SqlParameter[] U_USR_Map_ContactParms, U_USR_Map_Contact tobjU_USR_Map_Contact)
 {
     U_USR_Map_ContactParms[0].Value = tobjU_USR_Map_Contact.Id;
     U_USR_Map_ContactParms[1].Value = tobjU_USR_Map_Contact.Usr_Id;
     U_USR_Map_ContactParms[2].Value = tobjU_USR_Map_Contact.Contact_Id;
     U_USR_Map_ContactParms[3].Value = tobjU_USR_Map_Contact.Comments;
     U_USR_Map_ContactParms[4].Value = tobjU_USR_Map_Contact.Created_Date;
     U_USR_Map_ContactParms[5].Value = tobjU_USR_Map_Contact.Updated_Date;
     U_USR_Map_ContactParms[6].Value = tobjU_USR_Map_Contact.Created_by;
     U_USR_Map_ContactParms[7].Value = tobjU_USR_Map_Contact.Updated_by;
 }
Esempio n. 3
0
 public bool InsertU_USR_Map_Contact(U_USR_Map_Contact tobjU_USR_Map_Contact)
 {
     if (tobjU_USR_Map_Contact != null)
     {
         //Get the parameter list needed by the given object
         SqlParameter[] lParamArray = GetParameters(tobjU_USR_Map_Contact);
         SetParameters(lParamArray, tobjU_USR_Map_Contact);
         //Get the connection
         SqlConnection con = General.GetConnection();
         if (con == null)
         {
             //Connection is not created
             return(false);
         }
         //Execute the insertion
         int i = SqlHelper.ExecuteNonQuery(
             con,
             CommandType.Text,
             SQL_INSERT_U_USR_Map_Contact,
             lParamArray);
         //Dispose the Sql connection
         con.Dispose();
         if (i == 1)
         {
             //Done and insert the object to the table
             return(true);
         }
         else
         {
             //Fail to execute the insertion
             return(false);
         }
     }
     else
     {
         //No object found to insert
         return(false);
     }
 }
Esempio n. 4
0
 private SqlParameter[] GetParameters(U_USR_Map_Contact tobjU_USR_Map_Contact)
 {
     SqlParameter[] objParamArray = SqlHelperParameterCache.GetCachedParameterSet(General.SQL_CONN_STRING, SQL_INSERT_U_USR_Map_Contact);
     if (objParamArray == null)
     {
         //Represents a parameter to a System.Data.SqlClient.SqlCommand,
         //and optionally, its mapping to System.Data.DataSet columns.
         objParamArray = new SqlParameter[]
         {
             new SqlParameter(PARAM_Id, tobjU_USR_Map_Contact.Id),
             new SqlParameter(PARAM_Usr_Id, tobjU_USR_Map_Contact.Usr_Id),
             new SqlParameter(PARAM_Contact_Id, tobjU_USR_Map_Contact.Contact_Id),
             new SqlParameter(PARAM_Comments, tobjU_USR_Map_Contact.Comments),
             new SqlParameter(PARAM_Created_Date, tobjU_USR_Map_Contact.Created_Date),
             new SqlParameter(PARAM_Updated_Date, tobjU_USR_Map_Contact.Updated_Date),
             new SqlParameter(PARAM_Created_by, tobjU_USR_Map_Contact.Created_by),
             new SqlParameter(PARAM_Updated_by, tobjU_USR_Map_Contact.Updated_by),
         };
         SqlHelperParameterCache.CacheParameterSet(General.SQL_CONN_STRING, SQL_INSERT_U_USR_Map_Contact, objParamArray);
     }
     return(objParamArray);
 }