Exemplo n.º 1
0
        public void VotingIsOverMessage(object model, int id)
        {
            var peopletoreceivemail = _userLogic.GetList(new { SendMail2 = true });
            var todayschoices = _restaurantOptionLogic.GetAllByDate(null).OrderByDescending(f => f.Votes).Take(2).ToList();
            var fromaddress = System.Configuration.ConfigurationManager.AppSettings.Get("FromEmail");
            var allvetos = _vetoLogic.GetAllActive().ToList();

            //send email to each person who is eligible
            foreach (var user in peopletoreceivemail)
            {
                //abort sending this message if the current user has no veto powers
                if (allvetos.All(f => f.UserId != user.Id))
                    continue;

                var baseurl = System.Configuration.ConfigurationManager.AppSettings.Get("BaseURL");
                var link = string.Format("{0}?GUID={1}", baseurl, user.Guid);

                var path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
                var template = File.ReadAllText(new Uri(path + "/Views/_MailTemplates/VotingOver.cshtml").AbsolutePath);
                var messagemodel = new MailDetails() { User = user, Restaurants = todayschoices, Url = link, BaseUrl = baseurl };
                string result = Razor.Parse(template, messagemodel);
                Helpers.SendMail(user.Email, fromaddress, "What's for Lunch - Veto Option", result);

                //add log
                var entity = new JobLog() { JobId = id, Category = "VotingIsOverMessage", Message = string.Format("Voting is over message sent to {0}", user.FullName) };
                _jobLogLogic.SaveOrUpdate(entity);
            }
        }
Exemplo n.º 2
0
        public void MorningMessage(object model, int id)
        {
            var peopletoreceivemail = _userLogic.GetList(new { SendMail1 = true });
            var todayschoices = _restaurantOptionLogic.GetAndSaveOptions().ToList();
            var fromaddress = System.Configuration.ConfigurationManager.AppSettings.Get("FromEmail");

            //send email to each person who is eligible
            foreach (var user in peopletoreceivemail)
            {
                var baseurl = System.Configuration.ConfigurationManager.AppSettings.Get("BaseURL");
                var link = string.Format("{0}?GUID={1}", baseurl, user.Guid);
                var path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
                var template = File.ReadAllText(new Uri(path + "/Views/_MailTemplates/Morning.cshtml").AbsolutePath);
                var messagemodel = new MailDetails() { User = user, Restaurants = todayschoices, Url = link, BaseUrl = baseurl };

                string result = Razor.Parse(template, messagemodel);
                Helpers.SendMail(user.Email, fromaddress, "What's for Lunch - Message of the day", result);

                //add log
                var entity = new JobLog() { JobId = id, Category = "MorningMessage", Message = string.Format("Morning message sent to {0}", user.FullName) };
                _jobLogLogic.SaveOrUpdate(entity);
            }
        }
Exemplo n.º 3
0
        public ActionResult ForgotPassword(ForgotModel model)
        {
            bool isValid = false;
            string resetToken = "";

            if (ModelState.IsValid)
            {
                if (_webSecurityService.GetUserId(model.Email) > -1)
                {
                    resetToken = _webSecurityService.GeneratePasswordResetToken(model.Email);
                    isValid = true;
                }

                var user = _userLogic.Get(model.Email, null);

                if (isValid)
                {
                    string hostUrl = Request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped);
                    string resetUrl = hostUrl + VirtualPathUtility.ToAbsolute("~/Account/PasswordReset?resetToken=" + HttpUtility.UrlEncode(resetToken));

                    var fromaddress = System.Configuration.ConfigurationManager.AppSettings.Get("FromEmail");
                    var path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
                    var template = System.IO.File.ReadAllText(new Uri(path + "/Views/_MailTemplates/ResetPassword.cshtml").AbsolutePath);
                    var messagemodel = new MailDetails() { User = user, Url = resetUrl };

                    string result = Razor.Parse(template, messagemodel);
                    Helpers.SendMail(user.Email, fromaddress, "Password Reset", result);
                }
                return RedirectToAction("ForgotPasswordMessage");
            }
            return View(model);
        }