Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/15/17 17:51:28 (5 years ago)
Author:
jzenisek
Message:

#2839

  • worked on Job operations add&update
  • worked on ProjectPermission handling
  • worked on Project-Resource assignment
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ProjectPermissionDao.cs

    r15379 r15530  
    3737    }
    3838
    39     public void DeleteByProjectAndGrantedUserId(Guid projectId, IEnumerable<Guid> grantedUserId) {
    40       string paramIds = string.Join(",", grantedUserId.Select(x => string.Format("'{0}'", x)));
     39    public bool CheckUserGrantedForProject(Guid projectId, IEnumerable<Guid> userAndGroupIds) {
     40      string paramUserAndGroupIds = string.Join(",", userAndGroupIds.Select(x => string.Format("'{0}'", x)));
     41      if(!string.IsNullOrWhiteSpace(paramUserAndGroupIds)) {
     42        string queryString = string.Format(CheckUserGrantedForProjectQueryString, projectId, paramUserAndGroupIds);
     43        return DataContext.ExecuteQuery<int>(queryString).First() > 0;
     44      }
     45      return false;
     46    }
     47
     48    public void DeleteByProjectIdAndGrantedUserIds(Guid projectId, IEnumerable<Guid> grantedUserIds) {
     49      string paramIds = string.Join(",", grantedUserIds.Select(x => string.Format("'{0}'", x)));
    4150      if (!string.IsNullOrWhiteSpace(paramIds)) {
    42         string query = string.Format(DeleteByGrantedUserQuery, projectId, paramIds);
     51        string query = string.Format(DeleteByProjectIdAndGrantedUserIdsQueryString, projectId, paramIds);
     52        DataContext.ExecuteCommand(query);
     53      }
     54    }
     55
     56    public void DeleteByProjectIdsAndGrantedUserIds(IEnumerable<Guid> projectIds, IEnumerable<Guid> grantedUserIds) {
     57      string paramProjectIds = string.Join(",", projectIds.Select(x => string.Format("'{0}'", x)));
     58      string paramUserIds = string.Join(",", grantedUserIds.Select(x => string.Format("'{0}'", x)));
     59      if (!string.IsNullOrWhiteSpace(paramProjectIds) && !string.IsNullOrWhiteSpace(paramUserIds)) {
     60        string query = string.Format(DeleteByProjectIdsAndGrantedUserIdsQueryString, paramProjectIds, paramUserIds);
    4361        DataContext.ExecuteCommand(query);
    4462      }
     
    5472
    5573    #region String queries
    56     private const string DeleteByGrantedUserQuery =
    57       @"DELETE FROM [ProjectPermission]
    58          WHERE ProjectId = '{0}'
    59            AND GrantedUserId IN ({1});";
     74    private const string DeleteByProjectIdAndGrantedUserIdsQueryString = @"
     75      DELETE FROM [ProjectPermission]
     76      WHERE ProjectId = '{0}'
     77      AND GrantedUserId IN ({1});
     78    ";
     79    private const string DeleteByProjectIdsAndGrantedUserIdsQueryString = @"
     80      DELETE FROM [ProjectPermission]
     81      WHERE ProjectId IN '({0})'
     82      AND GrantedUserId IN ({1});
     83    ";
     84    private const string CheckUserGrantedForProjectQueryString = @"
     85      SELECT COUNT(pp.ProjectId)
     86      FROM [ProjectPermission] pp
     87      WHERE pp.ProjectId = {0}
     88      AND pp.GrantedUserId IN ({1})
     89    ";
    6090    #endregion
    6191  }
Note: See TracChangeset for help on using the changeset viewer.