public virtual ActionResult UpdateWidget(FormBuilderWidgetViewModel model)
        {
            if (model.SendEmail && String.IsNullOrEmpty(model.RecipientEmail))
            {
                ModelState.AddModelError("RecipientEmail", HttpContext.Translate("Messages.EmailRequired", ResourceHelper.GetControllerScope(this)));
            }
            if (ModelState.IsValid)
            {
                model = FormsBuilderWidgetHelper.SaveFormBuilderWidget(model);
            }

            return PartialView("EditWidget", model);
        }
        public virtual ActionResult UpdateWidget(FormBuilderWidgetViewModel model)
        {
            if (model.SendEmail && String.IsNullOrEmpty(model.RecipientEmail))
            {
                ModelState.AddModelError("RecipientEmail", HttpContext.Translate("Messages.EmailRequired", ResourceHelper.GetControllerScope(this)));
            }
            if (ModelState.IsValid)
            {
                model = FormsBuilderWidgetHelper.SaveFormBuilderWidget(model);
            }

            return(PartialView("EditWidget", model));
        }
        /// <summary>
        /// Saves the form builder widget.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public static FormBuilderWidgetViewModel SaveFormBuilderWidget(FormBuilderWidgetViewModel model)
        {
            var widgetService = ServiceLocator.Current.GetInstance<IFormBuilderWidgetService>();
            var widget = new FormBuilderWidget();
            if (model.Id>0)
                widget = widgetService.Find(model.Id);

            var contentViewer = model.MapTo(widget);

            if (widget!=null)
            {
                widgetService.Save(contentViewer);
            }
          
            return new FormBuilderWidgetViewModel().MapFrom(contentViewer);
        }
Example #4
0
        /// <summary>
        /// Saves the form builder widget.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public static FormBuilderWidgetViewModel SaveFormBuilderWidget(FormBuilderWidgetViewModel model)
        {
            var widgetService = ServiceLocator.Current.GetInstance <IFormBuilderWidgetService>();
            var widget        = new FormBuilderWidget();

            if (model.Id > 0)
            {
                widget = widgetService.Find(model.Id);
            }

            var contentViewer = model.MapTo(widget);

            if (widget != null)
            {
                widgetService.Save(contentViewer);
            }

            return(new FormBuilderWidgetViewModel().MapFrom(contentViewer));
        }