예제 #1
0
        public async Task <int> AddSubscribeUser(string Email, string FName, string Lname, string Location, int Gender, bool InterestInAll, string Interest)
        {
            try
            {
                NL_Controller objCon  = new NL_Controller();
                NL_UserInfo   objUser = new NL_UserInfo
                {
                    ClientIP        = _context.HttpContext?.Connection?.RemoteIpAddress?.ToString(),
                    AddedBy         = "SubcribeComponent",
                    SubscriberEmail = Email,
                    FirstName       = FName,
                    LastName        = Lname,
                    Location        = Location,
                    InterestInAll   = InterestInAll,
                    Interest        = Interest,
                    Gender          = (UserGender)Gender,
                    IsImported      = false
                };
                int status = await objCon.SaveEmailSubscriber(objUser);

                await objCon.SendMailToUser(Email);

                return(status);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
 public async Task <int> AddUpdateSubscribeUser(NL_UserInfo objUser)
 {
     try
     {
         NL_Controller objCon = new NL_Controller();
         objUser.IsImported = true;
         objUser.AddedBy    = GetUsername;
         return(await objCon.SaveEmailSubscriber(objUser));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #3
0
        // Import code

        private async Task <bool> SaveImportedData(DataTable data)
        {
            NL_Controller objCon  = new NL_Controller();
            NL_UserInfo   objInfo = new NL_UserInfo();

            customEmaillstInfo = new List <string>();
            string chkdgrpLst = GetSelectedGroup();
            Regex  regEmail   = new Regex(@"^\w.+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$");

            if (data != null && data.Rows.Count > 0)
            {
                int RowCount = 2;
                foreach (DataRow row in data.Rows)
                {
                    if (data.Rows.IndexOf(row) != 0)
                    {
                        Match match = regEmail.Match(row[1].ToString());
                        try
                        {
                            if (string.IsNullOrEmpty(row[1].ToString()))
                            {
                                customEmaillstInfo.Add("Empty record found in row " + RowCount);
                            }
                            //else if (match.Success)
                            //    customEmaillstInfo.Add("Invalid Email Added in row" + RowCount);
                            else if (string.IsNullOrEmpty(row[2].ToString()))
                            {
                                customEmaillstInfo.Add("Empty record found in row " + RowCount);
                            }
                            else if (string.IsNullOrEmpty(row[3].ToString()))
                            {
                                customEmaillstInfo.Add("Empty record found in row " + RowCount);
                            }
                            else if (string.IsNullOrEmpty(row[4].ToString()))
                            {
                                customEmaillstInfo.Add("Empty record found in row " + RowCount);
                            }
                            else if (string.IsNullOrEmpty(row[5].ToString()))
                            {
                                customEmaillstInfo.Add("Empty record found in row " + RowCount);
                            }
                            else if (string.IsNullOrEmpty(row[6].ToString()))
                            {
                                customEmaillstInfo.Add("Empty record found in row " + RowCount);
                            }
                            else
                            {
                                objInfo.SubscriberEmail = row[1].ToString();
                                objInfo.FirstName       = row[2].ToString();
                                objInfo.LastName        = row[3].ToString();
                                objInfo.Location        = row[5].ToString();
                                objInfo.Gender          = getGender(row[6].ToString().ToLower());
                                objInfo.IsImported      = true;
                                objInfo.ClientIP        = null;
                                if (row[4].ToString().ToLower() == "all")
                                {
                                    objInfo.InterestInAll = true;
                                    objInfo.Interest      = "";
                                }
                                else
                                {
                                    objInfo.InterestInAll = false;
                                    objInfo.Interest      = row[4].ToString().Trim();
                                }
                                objInfo.AddedBy        = GetUsername;
                                objInfo.RecipientGroup = chkdgrpLst;
                                int status = await objCon.SaveEmailSubscriber(objInfo);

                                if (status == 2)
                                {
                                    customEmaillstInfo.Add(string.Format("Email of row {0} already exists in the database.", RowCount));
                                }

                                //foreach (ListItem item in SrvrChkGrp.Items)
                                //{
                                //    if (item.Selected)
                                //        item.Selected = false;
                                //}
                                //EmailListLedger.PostedFile.InputStream.Dispose();
                            }
                        }
                        catch (Exception ex)
                        {
                            customEmaillstInfo.Add(string.Format("Error in row {0}. Error Message: {1}", RowCount, ex.Message));
                            return(false);
                        }
                        RowCount++;
                    }
                }
            }
            return(true);
        }