public ActionResult Create(WebForm webForm) { Client client = GStoreDb.Clients.FindById(webForm.ClientId); if (client.WebForms.Any(wf => wf.Name.ToLower() == webForm.Name.ToLower())) { ModelState.AddModelError("Name", "A Web Form with the name '" + webForm.Name + "' already exists. Change the name here or edit the conflicting web form."); } if (ModelState.IsValid) { webForm = GStoreDb.WebForms.Create(webForm); webForm.UpdateAuditFields(CurrentUserProfileOrThrow); webForm = GStoreDb.WebForms.Add(webForm); GStoreDb.SaveChanges(); AddUserMessage("Web Form Created", "Web Form '" + webForm.Name.ToHtml() + "' [" + webForm.WebFormId + "] Created Successfully", UserMessageType.Success); return RedirectToAction("Index"); } int? clientId = null; if (webForm.ClientId != default(int)) { clientId = webForm.ClientId; } this.BreadCrumbsFunc = htmlHelper => this.WebFormBreadcrumb(htmlHelper, webForm.ClientId, webForm); return View(webForm); }
public ActionResult Edit(WebForm webForm) { if (ModelState.IsValid) { webForm.UpdateAuditFields(CurrentUserProfileOrThrow); webForm = GStoreDb.WebForms.Update(webForm); GStoreDb.SaveChanges(); AddUserMessage("Web Form Updated", "Changes saved successfully to Web Form '" + webForm.Name.ToHtml() + "' [" + webForm.WebFormId + "]", UserMessageType.Success); return RedirectToAction("Index"); } this.BreadCrumbsFunc = htmlHelper => this.WebFormBreadcrumb(htmlHelper, webForm.ClientId, webForm); var errors = this.ModelState.Where(v => v.Value.Errors.Any()); return View(webForm); }