public ActionResult Create(InformationCollection.Models.SourceRegexView sourceregex) { if (ModelState.IsValid) { var sourceRegexGroup = db.SourceRegexGroups.Where(p => p.Name == sourceregex.SourceRegexGroup).FirstOrDefault(); if (sourceRegexGroup == null) { sourceRegexGroup = new SourceRegexGroup() { Name = sourceregex.SourceRegexGroup }; db.SourceRegexGroups.Add(sourceRegexGroup); db.SaveChanges(); } sourceRegexGroup.SourceRegexes.Add(new SourceRegex { IsMatched = sourceregex.IsMatched, RegexType = sourceregex.RegexType, Name = sourceregex.Name, Regex = sourceregex.Regex }); db.SaveChanges(); return RedirectToAction("Index", new { id = sourceRegexGroup.SourceRegexGroupId }); } return View(sourceregex); }
public ActionResult Create(SourceRegexGroup sourceregexgroup) { if (ModelState.IsValid) { db.SourceRegexGroups.Add(sourceregexgroup); db.SaveChanges(); return RedirectToAction("Index"); } return View(sourceregexgroup); }
public ActionResult Edit(SourceRegexGroup sourceregexgroup) { if (ModelState.IsValid) { db.Entry(sourceregexgroup).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(sourceregexgroup); }