public ActionResult Create()
 {
     var viewModel = new FormViewModel();
     var newField = new FormFieldViewModel {FormFieldTypes = GetFormFieldTypes()};
     viewModel.FormFields.Add(newField);
     return View(viewModel);
 }
 public ActionResult Edit(Guid id)
 {
     var viewModel = new FormViewModel { Form = _mvcForms.Forms.Single(form => form.Uid == id) };
     var formFields = _mvcForms.FormFields.Where(items => items.FormUid == id && items.IsHidden == 0).OrderBy(items => items.SortOrder);
     if (formFields.Count() > 0)
     {
         var countFields = 1;
         var listFields = String.Empty;
         foreach (var formField in formFields)
         {
             var thisField = formField;
             var thisFieldType =
                 _mvcForms.FormFieldTypes.Single(fieldtype => fieldtype.Uid == thisField.FormFieldTypeUid);
             var editFormField = new FormFieldViewModel
             {
                 Uid = formField.Uid,
                 FormFieldName = formField.FormFieldName,
                 FormFieldPrompt = formField.FormFieldPrompt,
                 ControlType = thisFieldType.ControlType,
                 SelectedFormFieldType = thisFieldType.Uid.ToString(),
                 IsRequired = Convert.ToBoolean(formField.IsRequired),
                 ShowDelete = (countFields > 1) ? true : false,
                 FormFieldTypes = GetFormFieldTypes(),
                 //TODO: Not sure if this is per field type, but it shouldn't matter
                 Options = formField.Options,
                 Orientation = formField.Orientation,
                 IsMultipleSelect = Convert.ToBoolean(formField.IsMultipleSelect),
                 ListSize = formField.ListSize,
                 IsEmptyOption = Convert.ToBoolean(formField.IsEmptyOption),
                 EmptyOption = formField.EmptyOption,
                 Rows = formField.Rows,
                 Cols = formField.Cols,
                 ValidExtensions = formField.ValidExtensions,
                 ErrorExtensions = formField.ErrorExtensions,
                 MaxSizeBytes = formField.MaxSizeBytes,
                 LiteralText = formField.LiteralText
             };
             viewModel.FormFields.Add(editFormField);
             listFields += "," + thisField.Uid;
             countFields++;
         }
         ViewData["ListFields"] = listFields.Substring(1); //Starts at 0; remove the first ','
     }
     else
     {
         var createFormField = new FormFieldViewModel
         {
             Uid = Guid.NewGuid(),
             ShowDelete = false,
             FormFieldTypes = GetFormFieldTypes()
         };
         viewModel.FormFields.Add(createFormField);
     }
     return View(viewModel);
 }
 public AjaxViewResult NewFormField(string formId, Guid selectedFieldType)
 {
     var fieldType = _mvcForms.FormFieldTypes.Single(type => type.Uid == selectedFieldType);
     var viewModel = new FormFieldViewModel
                         {
                             Uid = Guid.NewGuid(),
                             ShowDelete = true,
                             FormFieldTypes = GetFormFieldTypes(),
                             SelectedFormFieldType = selectedFieldType.ToString(),
                             //TODO: Not sure if this is per field type, but it shouldn't matter
                             //Create a default radiobutton selection
                             Orientation = "vertical"
                         };
     return new AjaxViewResult(fieldType.ControlType, viewModel) { UpdateValidationForFormId = formId };
 }