//GET: Edit public ActionResult Edit(int Id) { Form f = _context.Form.Include(c => c.Status).Include(u => u.User).FirstOrDefault(x => x.id == Id); if (f == null) { return(RedirectToAction("Index", "Home")); } FormEditViewModel model = new FormEditViewModel(f); model.StatusList = _context.FormStatus.ToList(); return(View(model)); }
public FormEditViewModel GetEdit(ApiCall call) { FormEditViewModel edit = new FormEditViewModel(); var form = call.WebSite.SiteDb().Forms.Get(call.ObjectId); if (form != null) { edit.Id = form.Id; edit.Body = form.Body; edit.IsEmbedded = form.IsEmbedded; edit.Name = form.Name; edit.Fields = form.Fields; edit.Style = form.Style; foreach (var item in Kooboo.Sites.HtmlForm.FormManager.List) { edit.AvailableSubmitters.Add(new FormSubmitterViewModel() { Name = item.Name, Settings = item.Settings(call.Context) }); } // should be ignored. edit.Settings = form.Setting; if (!string.IsNullOrEmpty(edit.Submitter)) { var submitter = edit.AvailableSubmitters.Find(o => o.Name == edit.Submitter); if (submitter != null) { foreach (var item in submitter.Settings) { if (edit.Settings.ContainsKey(item.Name)) { item.DefaultValue = edit.Settings[item.Name]; } } } } return(edit); } else { return(new FormEditViewModel()); } }
public ActionResult Edit(FormEditViewModel model) { if (model != null) { var formDb = _context.Form.FirstOrDefault(x => x.id == model.Id); if (formDb == null) { return(View(model)); } formDb.Comment = model.Comment; formDb.StatusId = model.StatusID; formDb.Text = model.Text; formDb.Title = model.Title; _context.SaveChanges(); return(RedirectToAction("Index", "Solution", new { id = formDb.SolutionId })); } return(RedirectToAction("Index", "Home")); }