[1720] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using HeuristicLab.DataAccess.ADOHelper;
|
---|
| 6 | using System.Data.SqlClient;
|
---|
| 7 | using HeuristicLab.Security.Contracts.BusinessObjects;
|
---|
| 8 | using System.Data.Common;
|
---|
| 9 |
|
---|
| 10 | namespace HeuristicLab.Security.ADODataAccess.TableAdapterWrapper {
|
---|
| 11 | class GrantedPermissionsAdapterWrapper :
|
---|
| 12 | TableAdapterWrapperBase<
|
---|
| 13 | dsSecurityTableAdapters.GrantedPermissionsTableAdapter,
|
---|
| 14 | GrantedPermission,
|
---|
| 15 | dsSecurity.GrantedPermissionsRow> {
|
---|
| 16 | public override void UpdateRow(dsSecurity.GrantedPermissionsRow row) {
|
---|
| 17 | TransactionalAdapter.Update(row);
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | public override dsSecurity.GrantedPermissionsRow
|
---|
| 21 | InsertNewRow(GrantedPermission relation) {
|
---|
| 22 | dsSecurity.GrantedPermissionsDataTable data =
|
---|
| 23 | new dsSecurity.GrantedPermissionsDataTable();
|
---|
| 24 |
|
---|
| 25 | dsSecurity.GrantedPermissionsRow row = data.NewGrantedPermissionsRow();
|
---|
| 26 | row.PermissionOwnerId = relation.PermissionOwnerId;
|
---|
| 27 | row.PermissionId = relation.PermissionId;
|
---|
| 28 | row.EntityId = relation.EntityId;
|
---|
| 29 |
|
---|
| 30 | data.AddGrantedPermissionsRow(row);
|
---|
[1729] | 31 | TransactionalAdapter.Update(row);
|
---|
[1720] | 32 |
|
---|
| 33 | return row;
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | public bool DeleteRow(GrantedPermission perm) {
|
---|
| 37 | dsSecurity.GrantedPermissionsRow row =
|
---|
| 38 | FindByPermissionPermissionOwnerEntityId(perm.PermissionId, perm.PermissionOwnerId, perm.EntityId);
|
---|
| 39 |
|
---|
| 40 | if (row != null) {
|
---|
| 41 | row.Delete();
|
---|
| 42 | UpdateRow(row);
|
---|
| 43 |
|
---|
| 44 | return true;
|
---|
| 45 | } else {
|
---|
| 46 | return false;
|
---|
| 47 | }
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | public override IEnumerable<dsSecurity.GrantedPermissionsRow>
|
---|
| 51 | FindById(Guid id) {
|
---|
| 52 | return TransactionalAdapter.GetDataByPermissionOwnerId(id);
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | public dsSecurity.GrantedPermissionsRow
|
---|
| 56 | FindByPermissionPermissionOwnerEntityId(Guid permissionId,
|
---|
| 57 | Guid permissionOwnerId, Guid entityId) {
|
---|
| 58 | IEnumerable<dsSecurity.GrantedPermissionsRow> result =
|
---|
| 59 | TransactionalAdapter.GetDataByPermissionPermissionOwnerEntityId(
|
---|
| 60 | permissionId, permissionOwnerId, entityId);
|
---|
| 61 |
|
---|
[1729] | 62 | if (result.Count() == 1)
|
---|
| 63 | return result.First();
|
---|
[1720] | 64 | else
|
---|
| 65 | return null;
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | public override IEnumerable<dsSecurity.GrantedPermissionsRow>
|
---|
| 69 | FindAll() {
|
---|
| 70 | return TransactionalAdapter.GetData();
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | protected override void SetConnection(DbConnection connection) {
|
---|
| 74 | adapter.Connection = connection as SqlConnection;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | protected override void SetTransaction(DbTransaction transaction) {
|
---|
| 78 | adapter.Transaction = transaction as SqlTransaction;
|
---|
| 79 | }
|
---|
| 80 | }
|
---|
| 81 | }
|
---|