public override List <Receiver> GetSubscribersForSendOut(string listItemValue, SendOutParams parameters) { var listAll = new List <TeaReceiver>(); IRecordsReader dr; dr = Application.SqlHelper.ExecuteReader("select Id, Firstname, Lastname, Email, DateFinalized FROM TeaCommerce_Order WHERE Email is not null AND DateFinalized != ''"); while (dr.Read()) { var dataProviderKey = dr.Get <int>("Id").ToString(); var email = dr.Get <string>("Email"); var fullname = string.Format("{0} {1}", dr.Get <string>("Firstname"), dr.Get <string>("Lastname")); var orderDate = dr.Get <DateTime>("DateFinalized"); // Not in the list? if (Common.IsValidEmail(email) && listAll.Count(x => x.Email == email) == 0) { var newReciver = new TeaReceiver() { DataProviderKey = dataProviderKey, Email = email, Fullname = fullname, OrderDate = orderDate }; listAll.Add(newReciver); } } dr.Close(); // Filter list if only no order in last 3 months if (listItemValue == "1") { var delList = listAll.Where(x => x.OrderDate < DateTime.Now.AddMonths(-3)); foreach (var item in delList) { listAll.Remove(item); } } return((from item in listAll select new Receiver() { DataProviderKey = item.DataProviderKey, Email = item.Email, Fullname = item.Fullname }).ToList()); }
public override List<Receiver> GetSubscribersForSendOut(string listItemValue, SendOutParams parameters) { var listAll = new List<TeaReceiver>(); IRecordsReader dr; dr = Application.SqlHelper.ExecuteReader("select Id, Firstname, Lastname, Email, DateFinalized FROM TeaCommerce_Order WHERE Email is not null AND DateFinalized != ''"); while (dr.Read()) { var dataProviderKey = dr.Get<int>("Id").ToString(); var email = dr.Get<string>("Email"); var fullname = string.Format("{0} {1}", dr.Get<string>("Firstname"), dr.Get<string>("Lastname")); var orderDate = dr.Get<DateTime>("DateFinalized"); // Not in the list? if (Common.IsValidEmail(email) && listAll.Count(x => x.Email == email) == 0) { var newReciver = new TeaReceiver() { DataProviderKey = dataProviderKey, Email = email, Fullname = fullname, OrderDate = orderDate }; listAll.Add(newReciver); } } dr.Close(); // Filter list if only no order in last 3 months if (listItemValue == "1") { var delList = listAll.Where(x => x.OrderDate < DateTime.Now.AddMonths(-3)); foreach (var item in delList) { listAll.Remove(item); } } return (from item in listAll select new Receiver() {DataProviderKey = item.DataProviderKey, Email = item.Email, Fullname = item.Fullname}).ToList(); }
public override List <Receiver> GetSubscribersForSendOut(string listItemValue, SendOutParams parameters) { var listAll = new List <TeaReceiver>(); var db = ApplicationContext.Current.DatabaseContext.Database; var listOfCustomers = db.Fetch <TeaCustomer>("select Id, Firstname, Lastname, Email, DateFinalized FROM TeaCommerce_Order WHERE Email is not null AND DateFinalized != ''"); foreach (var customer in listOfCustomers) { // Not in the list? if (Common.IsValidEmail(customer.Email) && listAll.Any(x => x.Email == customer.Email)) { var newReciver = new TeaReceiver() { DataProviderKey = customer.Id.ToString(), Email = customer.Email, Fullname = string.Format("{0} {1}", customer.Firstname, customer.Lastname), OrderDate = customer.DateFinalized }; listAll.Add(newReciver); } } // Filter list if only no order in last 3 months if (listItemValue == "1") { var delList = listAll.Where(x => x.OrderDate < DateTime.Now.AddMonths(-3)); foreach (var item in delList) { listAll.Remove(item); } } return((from item in listAll select new Receiver() { DataProviderKey = item.DataProviderKey, Email = item.Email, Fullname = item.Fullname }).ToList()); }
public override List<Receiver> GetSubscribersForSendOut(string listItemValue, SendOutParams parameters) { var listAll = new List<TeaReceiver>(); var db = ApplicationContext.Current.DatabaseContext.Database; var listOfCustomers = db.Fetch<TeaCustomer>("select Id, Firstname, Lastname, Email, DateFinalized FROM TeaCommerce_Order WHERE Email is not null AND DateFinalized != ''"); foreach (var customer in listOfCustomers) { // Not in the list? if (Common.IsValidEmail(customer.Email) && listAll.Any(x => x.Email == customer.Email)) { var newReciver = new TeaReceiver() { DataProviderKey = customer.Id.ToString(), Email = customer.Email, Fullname = string.Format("{0} {1}", customer.Firstname, customer.Lastname), OrderDate = customer.DateFinalized }; listAll.Add(newReciver); } } // Filter list if only no order in last 3 months if (listItemValue == "1") { var delList = listAll.Where(x => x.OrderDate < DateTime.Now.AddMonths(-3)); foreach (var item in delList) { listAll.Remove(item); } } return (from item in listAll select new Receiver() {DataProviderKey = item.DataProviderKey, Email = item.Email, Fullname = item.Fullname}).ToList(); }