public string DeleteFlexColumns(FlexColumn model, string culture) { string msg = "OK"; if (model == null) { return(msg); } // Check before delete var columnNames = model.ColumnName; var page = model.PageId; var related = (from fc in context.FlexColumns where fc.PageId == page && columnNames.Contains(fc.ColumnName) join fd in context.FlexData on new { fc.PageId, fc.ColumnName } equals new { fd.PageId, fd.ColumnName } join pd in context.PageDiv on fc.PageId equals pd.Id join m in context.Menus on pd.MenuId equals m.Id select new { name = fc.ColumnName, page = HrContext.TrlsName(m.Name + m.Sequence, culture) }).FirstOrDefault(); if (related != null) { msg = MsgUtils.Instance.Trls(culture, "DeleteRelatedRecord").Replace("{0}", related.page) + ": " + related.name; return(msg); } var Id = model.Id; var titles = context.ColumnTitles.ToList(); var DeleteObj = model; context.FlexColumns.Attach(DeleteObj); context.Entry(DeleteObj).State = EntityState.Deleted; var DeleteTitles = titles.Where(a => a.ColumnName == model.ColumnName).ToList(); RemoveRange(DeleteTitles); return(msg); }
public Tables() { InitializeComponent(); for (int i = 0; i <= 100; i += 10) { var col = new FlexColumn() { ColumnName = i.ToString() }; flexGrid.Columns.Add(col); } for (int i = 500; i <= 9000; i += 250) { var row = new FlexRow() { RowName = i.ToString() }; flexGrid.Rows.Add(row); } _actionHandler = new ActionInvoker(OnAction); MessageBus.Instance.Subscribe(Actions.TABLES_FOCUS_CONTROL, _actionHandler); MessageBus.Instance.Subscribe(Actions.SHOW_EDITOR, _actionHandler); }
public DbEntityEntry <FlexColumn> Entry(FlexColumn flexColumn) { return(Context.Entry(flexColumn)); }
public void Attach(FlexColumn flexColumn) { context.FlexColumns.Attach(flexColumn); }
public void Add(FlexColumn flexColumn) { context.FlexColumns.Add(flexColumn); }
public ActionResult CreateFlexColumns(IEnumerable <FlexColumnsViewModel> models, int pageId, IEnumerable <OptionsViewModel> options) { var result = new List <FlexColumn>(); var datasource = new DataSource <FlexColumnsViewModel>(); datasource.Data = models; datasource.Total = models.Count(); var page = _hrUnitOfWork.Repository <PageDiv>().Where(a => a.Id == pageId).Select(a => new { a.ObjectName, a.Version, a.TableName }).FirstOrDefault(); var titles = _hrUnitOfWork.Repository <ColumnTitle>().Where(a => a.CompanyId == CompanyId && a.Culture == Language && a.ObjectName == page.ObjectName && a.Version == page.Version).ToList(); if (ModelState.IsValid) { if (ServerValidationEnabled) { var errors = _hrUnitOfWork.MenuRepository.Check(new CheckParm { CompanyId = CompanyId, ObjectName = "FlexColumns", Columns = Models.Utils.GetModifiedRows(ModelState), ParentColumn = "PageId", Culture = Language, TableName = page.TableName }); if (errors.Count() > 0) { datasource.Errors = errors; return(Json(datasource)); } } for (var i = 0; i < models.Count(); i++) { { var model = models.ElementAtOrDefault(i); var title = titles.FirstOrDefault(a => a.ColumnName == model.ColumnName); var flexCol = new FlexColumn(); AutoMapper(new Models.AutoMapperParm { Destination = flexCol, Source = model, ObjectName = "FlexColumns", Transtype = TransType.Insert, Options = options.ElementAtOrDefault(i) }); if (title == null) { title = new ColumnTitle { ColumnName = model.ColumnName, Culture = Language, Version = page.Version, ObjectName = page.ObjectName, Title = model.Title, CompanyId = CompanyId }; _hrUnitOfWork.PageEditorRepository.Add(title); } flexCol.PageId = pageId; flexCol.TableName = page.TableName; result.Add(flexCol); _hrUnitOfWork.PageEditorRepository.Add(flexCol); } datasource.Errors = SaveChanges(Language); } } else { datasource.Errors = Models.Utils.ParseErrors(ModelState.Values); } datasource.Data = (from m in models join r in result on m.ColumnName equals r.ColumnName select new FlexColumnsViewModel { Id = r.Id, CodeName = m.CodeName, ColumnOrder = m.ColumnOrder, isVisible = m.isVisible, Max = m.Max, Min = m.Min, InputType = m.InputType, Pattern = m.Pattern, PlaceHolder = m.PlaceHolder, Title = m.Title, Required = m.Required, UniqueColumns = m.UniqueColumns, IsUnique = m.IsUnique, ColumnName = m.ColumnName, PageId = pageId, TableName = page.TableName }).ToList(); if (datasource.Errors.Count() > 0) { return(Json(datasource)); } else { return(Json(datasource.Data)); } }