示例#1
0
        public int GetFormItemTypeIDByName(string name)
        {
            var formItemType = FormItemRepository.GetFormItemTypeByName(name);

            return((formItemType != null) ?
                   formItemType.FormItemTypeID :
                   0);
        }
示例#2
0
        public List <KeyValuePair <string, string> > SaveFormSubmission(FormCollection values, string recipients, DateTime date, int formID, int formSubmissionID = 0)
        {
            Dictionary <string, string> dictValues = values.AllKeys.ToDictionary(k => k, v => values[v]);
            string stringValues = String.Empty;

            foreach (var item in dictValues)
            {
                if (item.Key.Contains("recaptcha") || item.Key.Contains("FormID") || item.Key.Contains("RecipientEmail") || item.Key.Contains("subscribe"))
                {
                    continue;
                }

                if (item.Key.Contains("radio"))
                {
                    var itemID      = int.Parse(item.Key.Replace("radio", ""));
                    var contactItem = FormItemRepository.GetByID(itemID);
                    var value       = contactItem.tbl_FormItemValues.FirstOrDefault(fiv => fiv.FIV_Value == int.Parse(item.Value));
                    stringValues += String.Format("{0}:{1}###", contactItem.FI_Text, value.FIV_Text);
                    continue;
                }

                if (item.Key.Contains("select"))
                {
                    var itemID      = int.Parse(item.Key.Replace("select", ""));
                    var contactItem = FormItemRepository.GetByID(itemID);
                    var value       = contactItem.tbl_FormItemValues.FirstOrDefault(fiv => fiv.FIV_Value == int.Parse(item.Value));
                    stringValues += String.Format("{0}:{1}###", contactItem.FI_Text, value.FIV_Text);
                    continue;
                }

                if (item.Key.Contains("checkbox"))
                {
                    var itemID      = int.Parse(item.Key.Replace("checkbox", ""));
                    var contactItem = FormItemRepository.GetByID(itemID);
                    foreach (var key in item.Value.Split(','))
                    {
                        var value = contactItem.tbl_FormItemValues.FirstOrDefault(fiv => fiv.FIV_Value == int.Parse(key));
                        stringValues += String.Format("{0}:{1}###", contactItem.FI_Text, value.FIV_Text);
                    }
                    continue;
                }

                stringValues += String.Format("{0}:{1}###", item.Key, item.Value);
            }
            stringValues.TrimEnd('#');

            List <KeyValuePair <string, string> > listValues = stringValues.Split(new[] { "###" }, StringSplitOptions.RemoveEmptyEntries).Select(s => new KeyValuePair <string, string>(s.Substring(0, s.IndexOf(':')), s.Substring(s.IndexOf(':') + 1))).ToList();

            FormSubmissionRepository.SaveFormSubmission(stringValues, recipients, date, formID, formSubmissionID);
            return(listValues);
        }
示例#3
0
 public bool SaveFormItemsOrder(int[] orderedFormItemIDs)
 {
     return(FormItemRepository.SaveOrder(orderedFormItemIDs));
 }
示例#4
0
 public tbl_FormItem SaveFormItemVisibility(int formItemID)
 {
     return((formItemID == 0) ?
            null:
            FormItemRepository.SaveVisibility(formItemID));
 }
示例#5
0
 public tbl_FormItem SaveFormItem(string name, string text, int itemTypeID, bool required, int formID, int formItemID, string placeholder)
 {
     return((String.IsNullOrEmpty(name)) ?
            null:
            FormItemRepository.SaveFormItem(name, text, itemTypeID, required, formID, formItemID, placeholder));
 }
示例#6
0
 public SelectList GetAllFormItemTypes()
 {
     return(new SelectList(FormItemRepository.GetAllFormItemTypes(), "FormItemTypeID", "FIT_Name"));
 }
示例#7
0
 public List <tbl_FormItem> GetAllFormItemsLiveByFormID(int formID)
 {
     return(FormItemRepository.GetAllLiveByFormID(formID).ToList());
 }
示例#8
0
 public List <tbl_FormItem> GetAllFormItems()
 {
     return(FormItemRepository.GetAll().ToList());
 }
示例#9
0
 public bool DeleteFormItem(int formItemID)
 {
     return(FormItemRepository.DeleteByID(formItemID));
 }
示例#10
0
 public tbl_FormItem GetFormItemByID(int formItemID)
 {
     return(FormItemRepository.GetByID(formItemID));
 }