public ActionResult GetSettings() { var menuList = WsFactory.GetMenu((byte)0); var objectList = MetaViewHelper.GetAll(); dynamic data = new { general = new { id = SecurityCache.CurrentUser.Id, name = SecurityCache.CurrentUser.Name, email = SecurityCache.CurrentUser.Email }, menu = menuList, objects = objectList.Select(c => new { c.Id, c.Name, c.Caption }), security = new { }, subscribe = new { } }; return(new ContentResult { ContentType = "text/html", Content = JsonSerializer.SerializeToString(data) }); }
public ActionResult EditExternalMethod(Guid?id, Guid?ViewId, MetaViewExternalMethodModel model, string button) { if (string.IsNullOrEmpty(button)) { return(View(model)); } if (!ModelState.IsValid) { return(View(model)); } using (DBEntities context = Settings.CreateDataContext()) { MetaViewExternalMethod target = null; if (model.Id != Guid.Empty) { target = MetaViewHelper.GetExternalMethod(model.Id, context); if (target == null) { ModelState.AddModelError("", Resources.Resource.RowNotFound); return(View(model)); } } else { target = new MetaViewExternalMethod(); target.Id = model.Id = Guid.NewGuid(); context.AddToMetaViewExternalMethod(target); } MetaViewExternalMethodModel.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.MetaViewId })); } else { return(RedirectToAction("EditExternalMethod", new { id = model.Id })); } }
public virtual ActionResult EMDeleteRows(Guid[] checkedRecords) { checkedRecords = checkedRecords ?? new Guid[] { }; try { MetaViewHelper.EMDelete(checkedRecords); } catch (Exception ex) { return(Content(MessageHelper.FormedMessageWarning(ex), "")); } return(Content(MessageHelper.FormedMessageSuccess(Resources.Resource.RowsDeleted + "!"), "")); }
public ActionResult Copy(Guid id) { Guid newId; try { newId = MetaViewHelper.Copy(id); } catch (Exception ex) { return(Content(MessageHelper.FormedMessageWarning(ex))); } string res = string.Format("Запись скопирована. <a href='{0}/{1}'>Перейти к новой записи</a>", Url.Action("Edit"), newId); return(Content(MessageHelper.FormedMessageSuccess(res), "")); }
public virtual ActionResult EMUpdateRow(Guid metaviewId, byte type, Guid emId, string param) { try { MetaViewHelper.EMUpdateRow(null, metaviewId, type, emId, param); } catch (NotValidationException ex) { return(Content(MessageHelper.FormedMessageNote(ex.Message), "")); } catch (Exception ex) { return(Content(MessageHelper.FormedMessageWarning(ex), "")); } return(Content(MessageHelper.FormedMessageSuccess("Запись добавлена!"), "")); }
public static List <MetaViewColumnModel> GetColumnsForView(Guid viewId, Guid masterEntityId, Guid?parentId) { MetaViewColumnModel.CreateMap(); List <MetaViewColumn> col; List <MetadataEntityAttribute> metadataEntityAttribute; using (DBEntities context = Settings.CreateDataContext()) { col = MetaViewHelper.GetColumnsByViewId(viewId, context); metadataEntityAttribute = MetadataEntityHelper.GetAttributes(context); } List <MetaViewColumnModel> res = Mapper.Map <IList <MetaViewColumn>, List <MetaViewColumnModel> >(col); AddEntities(viewId, res, metadataEntityAttribute, masterEntityId, null); return(res); }
public ActionResult ExternalMethodDeleteRows(Guid[] checkedRecords) { checkedRecords = checkedRecords ?? new Guid[] { }; try { MetaViewHelper.EMDelete(checkedRecords); } catch (NotValidationException ex) { return(Content(MessageHelper.FormedMessageNote(ex.Message), "")); } catch (Exception ex) { return(Content(MessageHelper.FormedMessageWarning(ex), "")); } return(Content(MessageHelper.FormedMessageSuccess(Resources.Resource.RowsDeleted + "!"), "")); }
public ActionResult Edit(Guid?id) { if (id.HasValue) { MetaView obj = MetaViewHelper.Get(id.Value); if (obj == null) { return(MessageHelper.FormedContentObjectNotFound()); } MetaViewModel.CreateMap(); MetaViewModel model = Mapper.Map <MetaView, MetaViewModel>(obj); return(View(model)); } else { return(View(new MetaViewModel())); } }
public ActionResult EditExternalMethod(Guid?id, Guid?ViewId) { MetaViewExternalMethodModel model = null; if (id.HasValue) { var att = MetaViewHelper.GetExternalMethod(id.Value); if (att == null) { return(MessageHelper.FormedContentObjectNotFound()); } MetaViewExternalMethodModel.CreateMap(); model = Mapper.Map <MetaViewExternalMethod, MetaViewExternalMethodModel>(att); return(View(model)); } else if (ViewId.HasValue) { MetaView item = MetaViewHelper.Get(ViewId.Value); if (item != null) { return(View(new MetaViewExternalMethodModel { MetaViewId = item.Id, MetaViewCaption = item.Caption, })); } else { return(MessageHelper.FormedContentObjectNotFound()); } } else { return(MessageHelper.FormedContentObjectNotFound()); } }
public ActionResult Edit(Guid id, MetaViewModel model, List <MetaViewColumnModel> columns, string button) { using (DBEntities context = Settings.CreateDataContext()) { Validate(context, model); if (!ModelState.IsValid) { return(View(model)); } MetaView target = null; if (model.Id != Guid.Empty) { target = MetaViewHelper.Get(model.Id, context); if (target == null) { ModelState.AddModelError("", Resources.Resource.RowNotFound); return(View(model)); } } else { target = new MetaView { Id = Guid.NewGuid() }; context.AddToMetaView(target); } MetaViewModel.CreateMap(); Mapper.Map(model, target); if (columns != null) { SyncViewColumns(target, columns, context); } try { context.SaveChanges(); } catch (Exception ex) { var sb = new StringBuilder(Resources.Resource.SaveError + ": " + ex.Message); if (ex.InnerException != null) { sb.AppendLine(ex.InnerException.Message); } ModelState.AddModelError("", sb.ToString()); return(View(model)); } if (button == "SaveAndExit") { return(RedirectToAction("Index")); } else { return(RedirectToAction("Edit", new { target.Id })); } } }
protected override void OnRestoreRows(Guid[] checkedRecords) { MetaViewHelper.Restore(checkedRecords); }
protected override void OnRemoveRows(Guid[] checkedRecords) { MetaViewHelper.Delete(checkedRecords, true); }