private void Validate(DBEntities context, MetaFormBlockModel model) { }
public ActionResult EditBlock(Guid? id, Guid? FormId, MetaFormBlockModel model, string button) { if (string.IsNullOrEmpty(button)) return View(model); if (!ModelState.IsValid) { return View(model); } using (DBEntities context = Settings.CreateDataContext()) { MetaFormBlock target = null; if (model.Id != Guid.Empty) { target = MetaFormHelper.GetBlock(model.Id, context); if (target == null) { ModelState.AddModelError("", Resources.Resource.RowNotFound); return View(model); } } else { target = new MetaFormBlock(); target.Id = model.Id = Guid.NewGuid(); context.AddToMetaFormBlock(target); } MetaFormBlockModel.CreateMap(); target = Mapper.Map(model, target); try { context.SaveChanges(); } catch (Exception ex) { ModelState.AddModelError("", Resources.Resource.SaveError + ": " + ex.Message); } } if (button == "SaveAndExit") return RedirectToAction("Edit", new {id = model.MetaFormId}); else { return RedirectToAction("EditBlock", new {id = model.Id}); } }