Ejemplo n.º 1
0
        public ActionResult FillIn(int id, bool embed = false)
        {
            using (var formManager = new FormAccessManager(GetLoginUser()))
            {
                TemplateViewModel model = null;

                var template = formManager.FindTemplate(id);

                if (template != null)
                {
                    model = TemplateViewModel.CreateFromObject(template, Constants.TemplateFieldMode.INPUT);

                    if (!model.IsPublic && !IsUserAuthenticated())
                    {
                        return(RedirectToError("Unauthorized access"));
                    }

                    model.Embed = embed;
                }
                else
                {
                    return(RedirectToError("invalid id"));
                }

                return(View(model));
            }
        }
Ejemplo n.º 2
0
        public ActionResult SubmitConfirmation(int id, bool?embed)
        {
            using (var formManager = new FormAccessManager(GetLoginUser()))
            {
                var template = formManager.FindTemplate(id);
                if (template != null)
                {
                    var templateView = TemplateViewModel.CreateFromObject(template);
                    templateView.Embed  = embed ?? embed.Value;
                    TempData["success"] = templateView.ConfirmationMessage;
                    return(View(templateView));
                }

                return(RedirectToError("invalid id"));
            }
        }
Ejemplo n.º 3
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));
                }
            }
        }