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 CreateChart(EditChartModel model) { if (ModelState.IsValid) { var entity = new Chart(); model.CopyTo(entity); entity.ChartId = Guid.NewGuid(); entity.StateCode = RecordState.Enabled; entity.OrganizationId = CurrentUser.OrganizationId; _chartCreater.Create(entity); return(CreateSuccess(new { id = entity.ChartId })); } var msg = GetModelErrors(ModelState); return(CreateFailure(msg)); }