Ejemplo n.º 1
0
        public void addOrDeleteEntityTypes(EntityTreeViewModel entityTreeViewModel)
        {
            //Remove all maps By tenantId, entitiyId, entityTypePropertyId
            var removeList = _adminRepo.GetEntityProperty()
                             .Where(t => t.TenantId == Tenant.Id &&
                                    t.EntityId == entityTreeViewModel.EntityId);

            _adminRepo.DeleteEntityProperties(removeList.ToList());

            //Add all mpas by add list
            if (entityTreeViewModel.EntityTypeProperties != null && entityTreeViewModel.EntityTypeProperties.Count > 0)
            {
                var mapedEntityProperty =
                    Mapper.Map <IEnumerable <EntityProperty> >(entityTreeViewModel.EntityTypeProperties);
                foreach (var k in mapedEntityProperty)
                {
                    k.TenantId = Tenant.Id;
                    k.EntityId = entityTreeViewModel.EntityId;
                }
                _adminRepo.AddEntityProperties(mapedEntityProperty.ToList());
            }
        }