Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Security.ADODataAccess/3.2/TableAdapterWrapper/GrantedPermissionsAdapterWrapper.cs @ 2273

Last change on this file since 2273 was 1729, checked in by svonolfe, 16 years ago

Fixed some bugs in the Security DAL (#597)

File size: 2.6 KB
RevLine 
[1720]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.DataAccess.ADOHelper;
6using System.Data.SqlClient;
7using HeuristicLab.Security.Contracts.BusinessObjects;
8using System.Data.Common;
9
10namespace 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}
Note: See TracBrowser for help on using the repository browser.