public void AddRoot(int fileId, int gateId) { using (var tx = Session.BeginTransaction()) { var fileAccessTree = new FileAccessTree { File = Session.Load <File>(fileId), Gate = Session.Load <Gate>(gateId) }; Session.SaveOrUpdate(fileAccessTree); tx.Commit(); } }
public void AddGate(int parentId, int gateId) { using (var tx = Session.BeginTransaction()) { var fileAccessTree = new FileAccessTree { Gate = Session.Load <Gate>(gateId), Parent = Session.Load <FileAccessTree>(parentId) }; Session.SaveOrUpdate(fileAccessTree); tx.Commit(); } }
public void AddAttribute(int parentId, int attributeTypeId, string value) { using (var tx = Session.BeginTransaction()) { var attribute = new FileAttribute { AttributeType = Session.Load <AttributeType>(attributeTypeId), Value = value }; Session.SaveOrUpdate(attribute); var fileAccessTree = new FileAccessTree { FileAttribute = attribute, Parent = Session.Load <FileAccessTree>(parentId) }; Session.SaveOrUpdate(fileAccessTree); tx.Commit(); } }
public static FileAccessTreeDto MapToDto(FileAccessTree fileAccessTree) { if (fileAccessTree == null) { return(null); } var fileAccessTreeDto = new FileAccessTreeDto { AccessTreeId = fileAccessTree.AccessTreeId, Gate = GateMapper.MapToDto(fileAccessTree.Gate), File = FileMapper.MapToDto(fileAccessTree.File), FileAttribute = FileAttributeMapper.MapToDto(fileAccessTree.FileAttribute), Children = new List <FileAccessTreeDto>() }; foreach (var child in fileAccessTree.Children) { fileAccessTreeDto.Children.Add(MapToDto(child)); } return(fileAccessTreeDto); }