Esempio n. 1
0
        public static void UserControllerSendNewsPostNotificationRequest(int newsPostId)
        {
            var viewModel = new NewsPostNotificationViewModel()
            {
                NewsPostId = newsPostId
            };

            var controllerName = MVC.Users.Name;
            const string actionName = "SendNewsPostNotification"; //MVC.Users.ActionNames.SendNewsPostNotification
            var controllerUrl = string.Format("{0}/{1}/{2}", Utility.GetCurrentWebsiteRoot(), controllerName, actionName);

            try
            {
                using (var client = new WebClient())
                {
                    var values = new NameValueCollection
                    {
                        {"newsPostId", Convert.ToString(newsPostId)}
                    };

                    var result = client.UploadValues(controllerUrl, values);
                }
            }
            catch (Exception ex)
            {
                //ignore any email notifications errors and continue
            }
        }
Esempio n. 2
0
        public virtual void SendNewsPostNotification(NewsPostNotificationViewModel viewModel)
        {
            var users = userRepository.GetAllActiveUsers();
            var recipients = string.Empty;

            foreach (var user in users)
            {
                if (string.IsNullOrEmpty(user.Email))
                    continue;

                recipients += user.Email + ",";
            }

            if (string.IsNullOrEmpty(recipients))
                return;

            //remove trailing comma
            recipients = recipients.Remove(recipients.Length - 1);

            Utility.EmailNewsNotification(recipients, viewModel.NewsPostId);

        }