Exemplo n.º 1
0
        private void NotifyViaEmail(NotificationEmailViewModel model)
        {
            EmailSender emailSender       = new EmailSender("MailTemplates", false);
            var         submimssionDetail = this.RenderPartialViewToString("_SubmissionEmailPartial", model);

            emailSender.SendSubmissionNotificationEmail(model.Email, "New Submission for form \"{0}\"".FormatWith(model.FormName), submimssionDetail);
        }
Exemplo n.º 2
0
        public ActionResult FillIn(IDictionary <string, string> SubmitFields, TemplateViewModel model, FormCollection formCollection)
        {
            InsertValuesIntoTempData(SubmitFields, formCollection);

            using (var formManager = new FormAccessManager(GetLoginUser()))
            {
                var template = formManager.FindTemplate(model.TemplateID.Value);

                var    templateView = TemplateViewModel.CreateFromObject(template, Constants.TemplateFieldMode.INPUT);
                string result       = formManager.FillIn(SubmitFields, model, formCollection);

                if (result.Equals("success"))
                {
                    //send notification
                    if (!templateView.NotificationEmail.IsNullOrEmpty() && WebConfig.Get <bool>("enablenotifications", true))
                    {
                        var notificationView = new NotificationEmailViewModel();
                        notificationView.FormName = templateView.Title;
                        notificationView.Email    = templateView.NotificationEmail;

                        //TODO if need to use this, need to retrieve the entries
                        //notificationView.Entries = ??;

                        NotifyViaEmail(notificationView);
                    }

                    RemoveValuesFromTempData(formCollection);

                    TempData["success"] = templateView.ConfirmationMessage;
                    return(RedirectToRoute("form-submitconfirmation", new
                    {
                        id = template.TemplateID,
                        embed = model.Embed
                    }));
                }

                else
                {
                    TempData["error"] = result;
                    return(View("FillIn", templateView));
                }
            }
        }