Exemplo n.º 1
0
        public ActionOutput SubmitSubscriberEmail(SubscriberModel SubscriberModel)
        {
            var existingSubscriber = Context.Subscribers.Where(z => z.IsDeleted == false && z.EmailID == SubscriberModel.EmailID).FirstOrDefault();

            if (existingSubscriber != null)
            {
                return(new ActionOutput
                {
                    Status = ActionStatus.Error,
                    Message = "This Subscriber email already exists and is also not marked as deleted."
                });
            }
            else
            {
                var Subscriber = Context.Subscribers.Create();
                Subscriber.AddedOn   = DateTime.UtcNow;
                Subscriber.IsDeleted = false;
                Subscriber.EmailID   = SubscriberModel.EmailID;
                Context.Subscribers.Add(Subscriber);
                Context.SaveChanges();
                MailChimpService.AddOrUpdateListMember(subscriberEmail: SubscriberModel.EmailID, listId: System.Configuration.ConfigurationManager.AppSettings["SubListId"]);
                return(new ActionOutput
                {
                    Status = ActionStatus.Successfull,
                    Message = "Subscriber Details Added Successfully."
                });
            }
        }
Exemplo n.º 2
0
 public ActionOutput GetTheGuideEmail(GetGuideModel GetGuideModel)
 {
     try
     {
         var    email     = GetGuideModel.EMAIL;
         var    emaildata = GetTemplate(Convert.ToInt32(TemplateTypes.GetTheGuideEmail));
         var    lt        = "<%";
         var    gt        = "%>";
         var    Domain    = Config.Link;
         string Durl      = string.Format("{0}/Home/DownloadGuide", Domain);
         string Jurl      = "https://mailchi.mp/3a986420cc90/join-hyggemail-newsletter";
         emaildata.TemplateContent = emaildata.TemplateContent.Replace(lt + "DURL" + gt, Durl);
         emaildata.TemplateContent = emaildata.TemplateContent.Replace(lt + "JURL" + gt, Jurl);
         // emaildata.TemplateContent = emaildata.TemplateContent.Replace(lt + "DATETIME" + gt, Convert.ToDateTime(DateTime.UtcNow).ToString("MMM dd yyyy hh:mm tt"));
         var result = Utilities.SendEMail(email, emaildata.EmailSubject, emaildata.TemplateContent);
         MailChimpService.AddOrUpdateListMember(subscriberEmail: GetGuideModel.EMAIL, listId: System.Configuration.ConfigurationManager.AppSettings["SubListId"]);
         return(new ActionOutput
         {
             Status = ActionStatus.Successfull,
             Message = "Guide Sent Successfully."
         });
     }
     catch (Exception ex)
     {
         return(new ActionOutput
         {
             Status = ActionStatus.Error,
             Message = ex.Message
         });
     }
 }