/// <summary> /// Removes not actual section in workplace registration for <paramref name="workplace"/>. /// </summary> /// <param name="workplace"><see cref="Workplace"/> instance.</param> private void DeleteRemovedSections(Workplace workplace) { var delete = new Delete(_userConnection) .From("SysModuleInWorkplace") .Where("SysWorkplaceId").IsEqual(Column.Parameter(workplace.Id)); if (workplace.HasSections()) { delete = delete.And("SysModuleId").Not().In(Column.Parameters(workplace.GetSectionIds())); } delete.Execute(); }
/// <summary> /// Creates section in workplace registration for <paramref name="workplace"/>. /// Existing items skipped. /// </summary> /// <param name="workplace"><see cref="Workplace"/> instance.</param> private void RegisterNewSections(Workplace workplace) { var schema = _entitySchemaManager.GetInstanceByName("SysModuleInWorkplace"); foreach (var sectionId in workplace.GetSectionIds()) { var entity = schema.CreateEntity(_userConnection); entity.SetDefColumnValues(); if (entity.FetchFromDB(new Dictionary <string, object> { { "SysModule", sectionId }, { "SysWorkplace", workplace.Id } })) { continue; } entity.PrimaryColumnValue = Guid.NewGuid(); entity.SetColumnValue("SysModuleId", sectionId); entity.SetColumnValue("SysWorkplaceId", workplace.Id); entity.Save(); } }