public ActionResult Create(DqValidatorModel mdmRegex, bool continueEditing) { if (!User.Identity.IsAuthenticated) { return(AccessDeniedView()); } var identity = ((CustomPrincipal)User).CustomIdentity; if (ModelState.IsValid) { MdmRegex mdmCat = new MdmRegex { REGEX_NAME = mdmRegex.REGEX_NAME, REGEX_STRING = mdmRegex.REGEX_STRING, REGEX_DESC = mdmRegex.REGEX_DESC }; db.MdmRegex.Add(mdmCat); db.SaveChanges(); db.Entry(mdmCat).GetDatabaseValues(); //_localizationService.GetResource("Admin.Configuration.Stores.Added") SuccessNotification("New Validator has been Added"); //do activity log return(continueEditing ? RedirectToAction("Edit", new { id = mdmCat.REGEX_ID }) : RedirectToAction("Index")); //return RedirectToAction("Index"); } return(View(mdmRegex)); }
// GET: MdmValidators/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MdmRegex mdmRegex = db.MdmRegex.Find(id); if (mdmRegex == null) { return(HttpNotFound()); } var model = new DqValidatorModel { REGEX_ID = mdmRegex.REGEX_ID, REGEX_NAME = mdmRegex.REGEX_NAME, REGEX_DESC = mdmRegex.REGEX_DESC, REGEX_STRING = mdmRegex.REGEX_STRING, }; return(View(model)); }
public ActionResult Edit(DqValidatorModel mdmRegex, bool continueEditing) { if (!User.Identity.IsAuthenticated) { return(AccessDeniedView()); } var identity = ((CustomPrincipal)User).CustomIdentity; if (ModelState.IsValid) { using (var db = new AppDbContext()) { var entity = db.MdmRegex.FirstOrDefault(o => o.REGEX_ID == mdmRegex.REGEX_ID); if (entity == null) { string errorMessage = string.Format("Cannot update record with Id:{0} as it's not available.", mdmRegex.REGEX_ID); ModelState.AddModelError("", errorMessage); } else { entity.REGEX_NAME = mdmRegex.REGEX_NAME; entity.REGEX_STRING = mdmRegex.REGEX_STRING; entity.REGEX_DESC = mdmRegex.REGEX_DESC; db.MdmRegex.Attach(entity); db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); } } SuccessNotification("Validator Updated"); return(continueEditing ? RedirectToAction("Edit", new { id = mdmRegex.REGEX_ID }) : RedirectToAction("Index")); //return RedirectToAction("Index"); } //PrepareModel(mdmCatalog); return(View(mdmRegex)); }