public IActionResult EditChart(Guid id) { EditChartModel model = new EditChartModel(); if (!id.Equals(Guid.Empty)) { var entity = _chartFinder.FindById(id); if (entity != null) { entity.CopyTo(model); model.ChartId = id; return(View(model)); } } return(NotFound()); }
public bool Import(Guid solutionId, IList <Chart> charts) { if (charts.NotEmpty()) { foreach (var item in charts) { var entity = _chartFinder.FindById(item.ChartId); if (entity != null) { entity.DataConfig = item.DataConfig; entity.Description = item.Description; entity.Name = item.Name; entity.PresentationConfig = item.PresentationConfig; entity.StateCode = item.StateCode; _chartUpdater.Update(entity); } else { item.SolutionId = solutionId; item.ComponentState = 0; item.CreatedBy = _appContext.GetFeature <ICurrentUser>().SystemUserId; item.OrganizationId = _appContext.OrganizationId; _chartCreater.Create(item); } } } return(true); }
public IActionResult RenderChart([FromBody] RenderChartModel model) { QueryView.Domain.QueryView view = null; if (model.QueryId.Equals(Guid.Empty) && model.EntityName.IsNotEmpty()) { view = _queryViewFinder.FindEntityDefaultView(model.EntityName); if (view != null) { model.QueryId = view.QueryViewId; } } else if (!model.QueryId.Equals(Guid.Empty)) { view = _queryViewFinder.FindById(model.QueryId); } if (view == null) { return(NotFound()); } var chartEntity = _chartFinder.FindById(model.ChartId); var result = _chartBuilder.Build(view, chartEntity, model.Filter, model.Groups.NotEmpty() ? model.Groups.Last() : string.Empty); model.Chart = result.Chart; model.ChartData = result.ChartData; model.ChartEntity = chartEntity; model.Attributes = result.Attributes; model.DataSource = result.DataSource; return(View($"~/Views/Component/{WebContext.ActionName}.cshtml", model)); }
public IActionResult Post(EditChartModel model) { if (ModelState.IsValid) { var entity = _chartFinder.FindById(model.ChartId); model.CopyTo(entity); entity.OrganizationId = CurrentUser.OrganizationId; _chartUpdater.Update(entity); return(UpdateSuccess(new { id = entity.ChartId })); } var msg = GetModelErrors(ModelState); return(UpdateFailure(msg)); }