public ActionResult Edit(Form form)
        {
            ViewBag.EditMode = "edit";

            string duplicateId = HasDuplicateIds(form.FormJson);
            if (string.IsNullOrEmpty(duplicateId)) {
                if (ModelState.IsValid) {
                    Form dbForm = db.Forms.Where(f => f.FormId == form.FormId).SingleOrDefault();
                    if (dbForm != null) {
                        dbForm.FormName = form.FormName;
                        dbForm.FormJson = form.FormJson;
                        dbForm.FormBuilderJson = form.FormBuilderJson;
                        dbForm.UpdatedOn = DateTime.Now;
                        //ToDo                    dbForm.RowVersion = form.RowVersion;
                        db.SaveChanges();
                        return Json(string.Empty);
                    }
                    else {
                        return new HttpStatusCodeResult(HttpStatusCode.NotFound);
                    }
                }
            }
            else {
                var errorMessage = string.Format(Messages.DuplicateIdsInForm, duplicateId);
                return Json(new { result = "Error", errorMessage = errorMessage });
            }
            return View(form);
        }
 public ActionResult Create()
 {
     Form form = new Form() {
         FormName = "Form Name",
         FormJson = DefaultFormJson(),
         FormBuilderJson = DefaultFormBuilderJson(),
         Guid = Guid.NewGuid(),
         CreatedOn = DateTime.Now
     };
     db.Forms.Add(form);
     db.SaveChanges();
     return RedirectToAction("EditAttributes", new {formId = form.FormId});
 }
 public ActionResult Run(Form form)
 {
     return RedirectToAction("Run", new {formId = form.FormId});
 }
        public ActionResult EditAttributes(Form form, string submitButton)
        {
            Form dbForm = db.Forms.Where(f => f.FormId == form.FormId).SingleOrDefault();
            if (dbForm != null) {
                dbForm.FormDisplayStyle = form.FormDisplayStyle;
                dbForm.OpenDialogBtnBackground = form.OpenDialogBtnBackground;
                dbForm.OpenDialogBtnForeground = form.OpenDialogBtnForeground;
                dbForm.OpenDialogBtnFont = form.OpenDialogBtnFont;
                dbForm.OpenDialogBtnFontSize = form.OpenDialogBtnFontSize;
                dbForm.OpenDialogBtnPosition = form.OpenDialogBtnPosition;
                dbForm.RowVersion = form.RowVersion;
                dbForm.UpdatedOn = DateTime.Now;
                db.SaveChanges();

                if (submitButton.Equals(Messages.EditAttributeSaveAndReturn)) {
                    return RedirectToAction("List");
                }
                else if (submitButton.Equals(Messages.EditAttributeSaveAndBuild)) {
                    return RedirectToAction("Edit", new { formId = form.FormId });
                }
                return RedirectToAction("List");
            }
            return View(form);
        }