示例#1
0
 public int CreateNewsLetter(NewsLetter C)
 {
     try
     {
         this.db.NewsLetters.Add(C);
         return db.SaveChanges();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
示例#2
0
 public int UpdateNewsLetter(NewsLetter C)
 {
     try
     {
         db.Entry(C).State = EntityState.Modified;
         return db.SaveChanges();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
        //protected void btnSave_Click(object sender, EventArgs e)
        //{
        //    try
        //    {
        //        NewsLetter objNl = new NewsLetter();
        //        NewsLetterRepository objnlRepo = new NewsLetterRepository();
        //        foreach (ListItem listItem in chkUser.Items)
        //        {
        //            if (listItem.Selected)
        //            {
        //                objNl.Id = Guid.NewGuid();
        //                objNl.Subject = txtSubject.Text;
        //                objNl.NewsLetterDetail = Editor.Text;
        //               // objNl.SendDate = DateTime.Parse(txtSendDate.Text);
        //                objNl.SendStatus = false;
        //                objNl.UserId = Guid.Parse(listItem.Value);
        //                if (!objnlRepo.checkNewsLetterExists(Editor.Text))
        //                    objnlRepo.AddNewsLetter(objNl);
        //                else
        //                    objnlRepo.UpdateNewsLetter(objNl);
        //            }
        //        }

        //    }
        //    catch (Exception Err)
        //    {
        //        logger.Error(Err.Message);
        //        Response.Write(Err.StackTrace);
        //    }
        //}

        protected void sendmail_Click(object sender, EventArgs e)
        {
            string username         = ConfigurationManager.AppSettings["username"];
            string host             = ConfigurationManager.AppSettings["host"];
            string port             = ConfigurationManager.AppSettings["port"];
            string pass             = ConfigurationManager.AppSettings["password"];
            string from             = ConfigurationManager.AppSettings["fromemail"];
            int    noofuserselected = 0;

            foreach (ListItem listItem in chkUser.Items)
            {
                if (listItem.Selected == true)
                {
                    noofuserselected++;
                }
            }



            if (txtSubject.Text == "" || Editor.Text == "" || noofuserselected == 0)
            {
                if (noofuserselected == 0)
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please fill subject/Email or select users!');", true);
                    return;
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please fill subject/Email content!');", true);
                    return;
                }
            }

            try
            {
                NewsLetter           objNl             = new NewsLetter();
                User                 objUser           = new User();
                UserRepository       objUserRepository = new UserRepository();
                NewsLetterRepository objnlRepo         = new NewsLetterRepository();
                foreach (ListItem listItem in chkUser.Items)
                {
                    if (listItem.Selected)
                    {
                        objUser = objUserRepository.getUsersById(Guid.Parse(listItem.Value));
                        if (objUser != null)
                        {
                            MailHelper.SendSendGridMail(host, Convert.ToInt32(port), from, "", objUser.EmailId.ToString(), string.Empty, string.Empty, txtSubject.Text, Editor.Text, username, pass);


                            objNl.Id             = Guid.NewGuid();
                            objNl.Subject        = txtSubject.Text;
                            objNl.NewsLetterBody = Editor.Text;
                            objNl.SendDate       = DateTime.Parse(txtSendDate.Text);
                            objNl.SendStatus     = false;
                            objNl.UserId         = Guid.Parse(listItem.Value);
                            objNl.EntryDate      = DateTime.Now;
                            //if (!objnlRepo.checkNewsLetterExists(Editor.Text))
                            //    objnlRepo.AddNewsLetter(objNl);
                            //else
                            //objnlRepo.UpdateNewsLetter(objNl);
                            objnlRepo.AddNewsLetter(objNl);
                        }
                    }
                }
                txtSubject.Text = "";
                Editor.Text     = "";
                clearAll();
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('News Letter has been Added!');", true);
            }
            catch (Exception Err)
            {
                txtSubject.Text = "";
                Editor.Text     = "";
                clearAll();
                logger.Error(Err.Message);
                Console.Write(Err.StackTrace);
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert(" + Err.Message + "'!');", true);
            }
        }
示例#4
0
        public void SendNewsletterEmail(string path, NewsLetter newsLetter, List <AppUser> appUsers)
        {
            try
            {
                var client = new SmtpClient();
                //Smtp Server
                var smtpServer = new AppConfig().EmailServer;
                //Smtp Port Number
                var smtpPortNumber = new AppConfig().Port;

                client.Connect(smtpServer, smtpPortNumber);
                // Note: only needed if the SMTP server requires authentication
                // Error 5.5.1 Authentication
                client.Authenticate(new AppConfig().SupportEmail, new AppConfig().SupportEmailPassword);
                foreach (var item in appUsers)
                {
                    //From Address
                    var fromAddress     = "*****@*****.**";
                    var fromAdressTitle = "Afriplugz Newsletter";
                    //To Address
                    var toVendor = item.Email;
                    //var toCustomer = email;
                    var toAdressTitle = item.Email;
                    var subject       = newsLetter.Subject;
                    //var BodyContent = message;

                    var mimeMessageVendor = new MimeMessage();
                    mimeMessageVendor.From.Add(new MailboxAddress(fromAdressTitle, fromAddress));
                    var check = false;
                    try
                    {
                        mimeMessageVendor.To.Add(new MailboxAddress(toAdressTitle, toVendor));
                    }
                    catch (Exception e)
                    {
                        check = true;
                    }

                    if (check == false)
                    {
                        mimeMessageVendor.Subject  = subject;
                        mimeMessageVendor.Priority = MessagePriority.Urgent;
                        var bodyBuilder = new BodyBuilder();
                        using (var data = File.OpenText(path))
                        {
                            {
                                //manage content

                                bodyBuilder.HtmlBody = data.ReadToEnd();
                                var body = bodyBuilder.HtmlBody;

                                var replace = body.Replace("URL", new AppConfig().AppUrl +
                                                           "Home/UnSubscription?email=" + item.Email);
                                replace = replace.Replace("CONTENTBODY", newsLetter.Body);
                                replace = replace.Replace("USER", item.Name);
                                replace = replace.Replace("LOGO", new AppConfig().AppLogo);
                                replace = replace.Replace("APPURL", new AppConfig().AppUrl);
                                replace = replace.Replace("TC", new AppConfig().Terms);
                                replace = replace.Replace("PRIVACY", new AppConfig().PrivacyPolicy);
                                bodyBuilder.HtmlBody   = replace;
                                mimeMessageVendor.Body = bodyBuilder.ToMessageBody();
                            }
                        }

                        client.Send(mimeMessageVendor);
                    }
                }

                client.Disconnect(false);
            }
            catch (Exception)
            {
                // ignored
            }
        }
示例#5
0
        public ActionResult SendAddNewsLatter(string Subject, string NewsBody, string SendDate, string UserIds, string UserEmails, string UserNames)
        {
            if (Session["User"] != null)
            {
                Domain.Socioboard.Domain.User _User = (Domain.Socioboard.Domain.User)Session["User"];
                if (_User.UserType != "SuperAdmin")
                {
                    return(RedirectToAction("Index", "Index"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Index"));
            }
            DateTime dt = Convert.ToDateTime(SendDate).Date;

            string[] UsersId   = UserIds.Split(',');
            string[] UserEmail = UserEmails.Split(',');
            string[] UserName  = UserNames.Split(',');
            //string mailsender = null;
            string returnmsg = string.Empty;
            int    i         = 0;

            foreach (var item in UsersId)
            {
                Api.User.User ApiObjUser = new Api.User.User();
                //Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(ApiObjUser.getUsersById(item.ToString(), Session["access_token"].ToString()), typeof(Domain.Socioboard.Domain.User)));
                Domain.Socioboard.Domain.NewsLetter objNewsLatter = new NewsLetter();
                //if (dt == DateTime.Now.Date)
                //{

                //    try
                //    {
                //        Api.MailSender.MailSender ApiObjMailForNewsLtr = new Api.MailSender.MailSender();
                //        mailsender = ApiObjMailForNewsLtr.SendAddNewsLatterMail(objUser.EmailId.ToString(), NewsBody, Subject);
                //        ObjNewsLatter.Id = Guid.NewGuid();
                //        ObjNewsLatter.Subject = Subject;
                //        ObjNewsLatter.NewsLetterBody = NewsBody;
                //        ObjNewsLatter.SendDate = DateTime.Parse(SendDate);
                //        ObjNewsLatter.SendStatus = true;
                //        ObjNewsLatter.UserId = Guid.Parse(item.ToString());
                //        ObjNewsLatter.EntryDate = DateTime.Now;
                //        string Objltr=new JavaScriptSerializer().Serialize(ObjNewsLatter);
                //        Api.NewsLetter.NewsLetter objApiNewsltr = new Api.NewsLetter.NewsLetter();
                //        returnmsg = (string)(new JavaScriptSerializer().Deserialize(objApiNewsltr.AddNewsLatter(Objltr), typeof(string)));

                //    }
                //    catch (Exception ex)
                //    {
                //        Console.WriteLine(ex.StackTrace);
                //    }
                //}
                //else {
                objNewsLatter.Id             = Guid.NewGuid();
                objNewsLatter.Subject        = Subject;
                objNewsLatter.NewsLetterBody = NewsBody;
                objNewsLatter.SendDate       = DateTime.Parse(SendDate);
                objNewsLatter.SendStatus     = false;
                objNewsLatter.UserId         = Guid.Parse(item.ToString());
                objNewsLatter.Email          = UserEmail[i];
                objNewsLatter.Name           = UserName[i];
                objNewsLatter.EntryDate      = DateTime.Now;
                string objltr = new JavaScriptSerializer().Serialize(objNewsLatter);
                Api.NewsLetter.NewsLetter objApiNewsltr = new Api.NewsLetter.NewsLetter();
                returnmsg = objApiNewsltr.AddNewsLatter(objltr);
                //}
                i++;
            }


            return(Content(returnmsg));
        }
示例#6
0
 public override string BuildNewsLetterHTML(NewsLetter newsLetter)
 {
     return(_letter);
 }
示例#7
0
    private void UpdateEmailSubscriber(string email, string emailOld)
    {
        StoreRetriever storeRetriever = new StoreRetriever();
        Store          store          = storeRetriever.GetStore();
        string         emailHash      = SecurityUtilities.HashMD5(email + WebConfiguration.SecretKey);

        if (uxSubscribeCheckBox.Checked)
        {
            NewsLetter newsLetterOld = DataAccessContext.NewsLetterRepository.GetOne(emailOld, store);
            NewsLetter newsLetter    = DataAccessContext.NewsLetterRepository.GetOne(email, store);

            if (newsLetterOld.IsNull)
            {
                if (newsLetter.IsNull)
                {
                    newsLetter.Email     = email;
                    newsLetter.EmailHash = emailHash;
                    newsLetter.JoinDate  = DateTime.Now;
                    newsLetter.StoreID   = store.StoreID;
                    DataAccessContext.NewsLetterRepository.Create(newsLetter);
                }
            }
            else
            {
                if (MoreThanOneUserSubscribeWithEmail(emailOld))
                {
                    // No need to delete old email
                    if (newsLetter.IsNull)
                    {
                        newsLetter.Email     = email;
                        newsLetter.EmailHash = emailHash;
                        newsLetter.JoinDate  = DateTime.Now;
                        newsLetter.StoreID   = store.StoreID;
                        DataAccessContext.NewsLetterRepository.Create(newsLetter);
                    }
                }
                else
                {
                    if (String.Compare(email, emailOld) != 0)
                    {
                        // No need to keep old email
                        if (newsLetter.IsNull)
                        {
                            newsLetterOld.EmailHash = emailHash;
                            DataAccessContext.NewsLetterRepository.Update(newsLetterOld, email, store.StoreID);
                        }
                        else
                        {
                            DataAccessContext.NewsLetterRepository.DeleteEmailNoHash(emailOld, store);
                        }
                    }
                }
            }
        }
        else
        {
            if (!MoreThanOneUserSubscribeWithEmail(email))
            {
                DataAccessContext.NewsLetterRepository.DeleteEmail(emailHash, store);
            }
        }
    }
示例#8
0
    private void AddCustomer()
    {
        if (Page.IsValid)
        {
            StoreRetriever storeRetriever = new StoreRetriever();
            Store          store = storeRetriever.GetStore();
            bool           validateCountry, validateState, validateShippingCountry, validateShippingState;
            bool           validateBilling, validateShipping;
            validateBilling = uxCountryState.Validate(out validateCountry, out validateState);

            if (uxUseBillingAsShipping.Checked)
            {
                if (!validateBilling)
                {
                    uxBillingCountryStateDiv.Visible  = true;
                    uxBillingCountryStateMessage.Text = ValidateCountryAndState(validateCountry, validateState);
                    return;
                }
            }
            else
            {
                validateShipping = uxShippingCountryState.Validate(out validateShippingCountry, out validateShippingState);
                if (!validateBilling && !validateShipping)
                {
                    uxBillingCountryStateDiv.Visible   = true;
                    uxBillingCountryStateMessage.Text  = ValidateCountryAndState(validateCountry, validateState);
                    uxShippingCountryStateDiv.Visible  = true;
                    uxShippingCountryStateMessage.Text = ValidateCountryAndState(validateShippingCountry, validateShippingState);
                    return;
                }
                else if (!validateBilling)
                {
                    uxBillingCountryStateDiv.Visible  = true;
                    uxBillingCountryStateMessage.Text = ValidateCountryAndState(validateCountry, validateState);
                    return;
                }
                else if (!validateShipping)
                {
                    uxShippingCountryStateDiv.Visible  = true;
                    uxShippingCountryStateMessage.Text = ValidateCountryAndState(validateShippingCountry, validateShippingState);
                    return;
                }
            }

            MembershipUser user = Membership.GetUser(uxUserName.Text.Trim());
            if (user == null && !UsernameExits(uxUserName.Text.Trim()))
            {
                if (uxUseBillingAsShipping.Checked)
                {
                    CopyBillingDetailsToShipping();
                }

                if (uxSubscribeCheckBox.Checked)
                {
                    string Email     = uxEmail.Text.Trim();
                    string EmailHash =
                        SecurityUtilities.HashMD5(Email + WebConfiguration.SecretKey);
                    NewsLetter newsLetter = DataAccessContext.NewsLetterRepository.GetOne(Email, store);
                    if (newsLetter.IsNull)
                    {
                        newsLetter.Email     = Email;
                        newsLetter.EmailHash = EmailHash;
                        newsLetter.JoinDate  = DateTime.Now;
                        newsLetter.StoreID   = store.StoreID;
                        DataAccessContext.NewsLetterRepository.Create(newsLetter);
                    }
                }

                string id;

                Customer customer = SetUpCustomer();
                customer = DataAccessContext.CustomerRepository.Save(customer);
                id       = customer.CustomerID;

                Membership.CreateUser(uxUserName.Text.Trim(), uxPassword.Text, uxEmail.Text.Trim());
                Roles.AddUserToRole(uxUserName.Text, "Customers");

                if (IsCustomerAutoApprove)
                {
                    FormsAuthentication.SetAuthCookie(uxUserName.Text, false);
                }

                SetCartShippingAddress(customer);
                SetTaxExempt();
                try
                {
                    SendMailToCustomer(uxEmail.Text, uxUserName.Text);
                    SendMailToMerchant(uxEmail.Text, uxUserName.Text, id);
                    AffiliateHelper.UpdateAffiliateReference(uxUserName.Text);
                    RedirectPage();
                }
                catch (Exception)
                {
                    ErrorMessage = "[$SentErrorMessage]";
                    ClearData();
                }
            }
            else
            {
                ErrorMessage = "[$User Existed]";
            }
        }
    }
示例#9
0
        public int DeleteNewsLetter(int Id)
        {
            NewsLetter order = db.NewsLetters.Where(u => u.ID == Id).FirstOrDefault();

            return(DeleteNewsLetter(order));
        }
        public ActionResult UpdateNewsLetter(int newsletterId)
        {
            NewsLetter newsletter = NewsLetterManager.GetNewsLetterById(newsletterId);

            return(View("~/Views/NewsLetter/InsertNewsLetter.cshtml", newsletter));
        }
示例#11
0
        public virtual ActionResult Edit(Customer customer)
        {
            var emailExists = hopeLingerieEntities.Customers.SingleOrDefault(a => a.CustomerId != customer.CustomerId && a.Email == customer.Email && a.Active);

            if (emailExists != null)
            {
                TempData["Message"]    = "El Email ingresado ya existe en nuestra base de datos!";
                TempData["ActionType"] = ActionType.Back;

                return(Redirect("/Account/Information"));
            }

            var newCustomer = hopeLingerieEntities.Customers.SingleOrDefault(a => a.CustomerId == customer.CustomerId && a.Active);

            newCustomer.BirthDate  = customer.BirthDate;
            newCustomer.Cellular   = customer.Cellular;
            newCustomer.City       = customer.City;
            newCustomer.DNI        = customer.DNI;
            newCustomer.Fax        = customer.Fax;
            newCustomer.FirstName  = customer.FirstName;
            newCustomer.LastName   = customer.LastName;
            newCustomer.NewsLetter = customer.NewsLetter;
            newCustomer.Number     = customer.Number;
            newCustomer.StateId    = customer.StateId;
            newCustomer.Telephone1 = customer.Telephone1;
            newCustomer.Telephone2 = customer.Telephone2;
            newCustomer.Telephone3 = customer.Telephone3;
            newCustomer.ZipCode    = customer.ZipCode;
            newCustomer.Gender     = customer.Gender;
            newCustomer.Address    = customer.Address;

            if (!customer.NewsLetter)
            {
                var newsLetter = hopeLingerieEntities.NewsLetters.SingleOrDefault(x => x.Email == newCustomer.Email);
                hopeLingerieEntities.NewsLetters.DeleteObject(newsLetter);
            }
            else
            {
                var newsLetter = hopeLingerieEntities.NewsLetters.SingleOrDefault(x => x.Email == newCustomer.Email);

                if (newsLetter != null)
                {
                    newsLetter.Email = customer.Email;
                    newsLetter.Name  = customer.LastName + ", " + customer.FirstName;
                }
                else
                {
                    newsLetter           = new NewsLetter();
                    newsLetter.Email     = customer.Email;
                    newsLetter.Name      = customer.LastName + ", " + customer.FirstName;
                    newsLetter.AddedDate = DateTime.Now;
                    hopeLingerieEntities.NewsLetters.AddObject(newsLetter);
                }
            }

            // Si hay cambio de mail lo desloguea.
            if (newCustomer.Email != customer.Email)
            {
                newCustomer.Email = customer.Email;
                hopeLingerieEntities.SaveChanges();
                FormsService.SignOut();

                TempData["Message"]    = "Tu cuenta ha sido modificada con éxito! Al modificar el Email deberás ingresar nuevamente al sitio";
                TempData["ActionType"] = ActionType.Catalogue;
                return(Redirect("/Account/Information"));
            }

            hopeLingerieEntities.SaveChanges();
            TempData["Message"]    = "Tu cuenta ha sido modificada con éxito!";
            TempData["ActionType"] = ActionType.Catalogue;
            return(Redirect("/Account/Information"));
        }
示例#12
0
        protected void btnAdicionar_Click(object sender, EventArgs e)
        {
            NewsLetter objNewsLetter = new NewsLetter();

            objNewsLetter.adicionar(txtEmail.Text);
        }
        protected void btnEnviar_Click(object sender, EventArgs e)
        {
            NewsLetter objNewsLetter = new NewsLetter();

            objNewsLetter.enviarEmail(txtEmailOrigin.Text, txtEmailDestino.Text, txtTituloMensagem.Text, txtCorpoMensagem.Text);
        }
示例#14
0
        public bool DoesEmailExist(string email)
        {
            NewsLetter newsLetter = db.NewsLetters.Where(c => c.Email == email).FirstOrDefault();

            return(newsLetter != null);
        }
        //
        // GET: /NewsLetterList/Details/5

        public ViewResult Details(int id)
        {
            NewsLetter newsletter = db.NewsLetters.Single(n => n.NewsLetterID == id);

            return(View(newsletter));
        }
        //
        // GET: /NewsLetterList/Delete/5

        public ActionResult Delete(int id)
        {
            NewsLetter newsletter = db.NewsLetters.Single(n => n.NewsLetterID == id);

            return(View(newsletter));
        }
 public void insert(NewsLetter Entity)
 {
     Sn.insert(Mappers <NewsLetter, Gl.NewsLetter> .VueToEntities(Entity));
 }