public ActionResult SubmitEmail() { if (string.IsNullOrEmpty(GetRequest("name")) || string.IsNullOrEmpty(GetRequest("phone")) || string.IsNullOrEmpty(GetRequest("email")) || string.IsNullOrEmpty(GetRequest("message"))) { return(Err()); } if (!StringHelper.IsValidEmail(GetRequest("email"))) { return(Err()); } try { SubscriberEmail subscriberEmail = new SubscriberEmail(); int id = subscriberEmail.AddEmail(GetRequest("email")); return(id != 0 ? Ret() : Err()); } catch { return(Err()); } }
public ActionResult CancelNewsletterGET(string emailAddress) { SubscriberEmail Subscriber = new SubscriberEmail() { EmailAddress = emailAddress }; return(View(Subscriber)); }
public void SendSubscriberEmail_DoesNotThrow() { SubscriberEmail se = new SubscriberEmail() { EmailAddress = "*****@*****.**", SubscriberList = new List <string>() { "Kultura", "Sport" } }; Assert.DoesNotThrow(() => _emailSP.SendSubscriberEmail(se)); }
public void SendSubscriberEmail_WrongPathToEmailView() { SubscriberEmail se = new SubscriberEmail() { EmailAddress = "*****@*****.**", SubscriberList = new List <string>() { "Kultura", "Sport" } }; Assert.That(() => _emailSPcomb.SendSubscriberEmail(se), Throws.Exception.TypeOf <System.Exception>()); }
public void SendSubscriberEmail_ExceptionWhenEmailAddressIsNull() { SubscriberEmail se = new SubscriberEmail() { EmailAddress = null, SubscriberList = new List <string>() { "Kultura", "Sport" } }; Assert.That(() => _emailSP.SendSubscriberEmail(se), Throws.Exception.TypeOf <InvalidOperationException>()); }
public void SendSubscriberEmail(SubscriberEmail model) { dynamic email = new Email("Email"); email.Id = model.Id.ToString(); email.To = model.EmailAddress; email.SubscriberList = model.SubscriberList; email.From = _emailFrom; email.RssList = _context._rssDocumentCollection.Find(new BsonDocument()).ToList(); email.Subject = "Newsletter RSS Reader RMF24 - " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.AddHours(1).ToShortTimeString() + "."; Task t = _service.SendAsync(email); int attemptsCounter = 1; try { t.Wait(); } catch (Exception) { while (t.Status == TaskStatus.Faulted) { if (attemptsCounter < 6) { attemptsCounter++; Task.Delay(900000); try { t = _service.SendAsync(email); break; } catch (Exception) { } } } } }
public void InsertToMailingList(string emailAddress, ICollection <string> subscriberList) { var result = _subscribers.Find(x => x.EmailAddress == emailAddress).FirstOrDefault(); if (result != null) { result.SubscriberList = subscriberList.ToList(); _subscribers.ReplaceOne(x => x.EmailAddress == result.EmailAddress, result); } else { SubscriberEmail newNewsletterMember = new SubscriberEmail() { EmailAddress = emailAddress, SubscriberList = subscriberList.ToList() }; _subscribers.InsertOne(newNewsletterMember); } }
public ActionResult Export() { SubscriberEmail subscriberEmail = new SubscriberEmail(); DataTable result = subscriberEmail.GetAllEmail(); if (result != null && result.Rows.Count > 0) { var grid = new System.Web.UI.WebControls.GridView(); grid.DataSource = result; grid.DataBind(); Response.ClearContent(); Response.AddHeader("content-disposition", "attachment; filename=SubscriberEmail.xls"); Response.ContentType = "application/excel"; System.IO.StringWriter sw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw); grid.RenderControl(htw); Response.Write(sw.ToString()); Response.End(); } return(Content("Don't result!")); }
public bool HaveColumn(string columnName, string columnValue, out bool retValueMatched) { bool ret = false; bool valueMatched = false; if (columnName == "SubscriberID") { ret = true; if (SubscriberID.ToString() == columnValue) { valueMatched = true; } } if (columnName == "SubscriberGUID") { ret = true; if (SubscriberGUID.ToString() == columnValue) { valueMatched = true; } } if (columnName == "RevisionNo") { ret = true; if (RevisionNo.ToString() == columnValue) { valueMatched = true; } } if (columnName == "SubscriberMessage") { ret = true; if (SubscriberMessage.ToString() == columnValue) { valueMatched = true; } } if (columnName == "SubscriberEmail") { ret = true; if (SubscriberEmail.ToString() == columnValue) { valueMatched = true; } } if (columnName == "CreatedDate") { ret = true; if (CreatedDate.ToString() == columnValue) { valueMatched = true; } } if (columnName == "LastUpdateDate") { ret = true; if (LastUpdateDate.ToString() == columnValue) { valueMatched = true; } } if (columnName == "IsDeleted") { ret = true; if (IsDeleted.ToString() == columnValue) { valueMatched = true; } } retValueMatched = valueMatched; return(ret); }