public static bool DoesUserHaveOperation(this ge_DbContext context, string operation, ge_group group, string userId) { if (context == null || group == null || operation == null || userId == String.Empty) { return(false); } bool retvar = false; ge_user_ops user_group = null; if (group.Id == Guid.Empty) { return(IsUserAnyGroupAdmin(context, userId)); } user_group = context.ge_user_ops .AsNoTracking() .Where(u => u.groupId == group.Id) .Where(u => u.userId == userId).FirstOrDefault(); if (user_group != null) { if (user_group.user_operations.Contains(operation)) { context.Entry <ge_user_ops>(user_group).State = EntityState.Detached; user_group = null; retvar = true; } } return(retvar); }
public async Task <ge_user_ops> CreateUserOps(ge_user_ops newUserOps) { await _unitOfWork.UserOps.AddAsync(newUserOps); await _unitOfWork.CommitAsync(); return(newUserOps); }
public async Task <Boolean> AreGroupOperationsAllowed(string userId, ge_group group, string request_ops) { ge_user_ops group_user = await _unitOfWork.UserOps.GetByUserIdGroupId(userId, group.Id); operation_request req = new operation_request(group, group_user); return(req.AreGroupOperationsAllowed(request_ops)); }
public async Task <operation_request> GetOperationRequest(string userId, ge_group group) { ge_user_ops group_user = await _unitOfWork.UserOps.GetByUserIdGroupId(userId, group.Id); operation_request req = new operation_request(group, group_user); return(req); }
public async Task <string> GetAllowedOperations(string userId, ge_group group) { ge_user_ops group_user = await _unitOfWork.UserOps.GetByUserIdGroupId(userId, group.Id); operation_request req = new operation_request(group, group_user); return(req._effectiveGroup_ops); }
public static bool DoesUserHaveOperation(this ge_DbContext context, string operation, ge_project project, string userId) { if (context == null || project == null || operation == null || userId == null) { return(false); } if (userId == String.Empty) { return(false); } bool retvar = false; ge_user_ops user_proj = null; ge_user_ops user_group = null; if (project.Id == Guid.Empty && operation == geOPS.Create.Name) { if (project.group == null) { return(false); } return(DoesUserHaveOperation(context, geOPS.Create.Name, project.group, userId)); } user_proj = context.ge_user_ops .AsNoTracking() .Where(p => p.userId == userId && p.projectId == project.Id).FirstOrDefault(); if (user_proj != null) { if (user_proj.user_operations.Contains(operation)) { retvar = true; } else { retvar = false; } } else { user_group = context.ge_user_ops .AsNoTracking() .Where(u => u.userId == userId && u.groupId == project.groupId).FirstOrDefault(); if (user_group.user_operations.Contains(operation)) { retvar = true; } else { retvar = false; } } return(retvar); }
public async Task <Boolean> AreProjectOperationsAllowed(string userId, ge_project project, string request_ops) { ge_user_ops group_user = await _unitOfWork.UserOps.GetByUserIdGroupId(userId, project.groupId); ge_user_ops project_user = await _unitOfWork.UserOps.GetByUserIdProjectId(userId, project.Id); operation_request req = new operation_request(project, group_user, project_user); return(req.AreProjectOperationsAllowed(request_ops)); }
public async Task <operation_request> GetOperationRequest(string userId, ge_project project) { ge_user_ops group_user = await _unitOfWork.UserOps.GetByUserIdGroupId(userId, project.groupId); ge_user_ops project_user = await _unitOfWork.UserOps.GetByUserIdProjectId(userId, project.Id); operation_request req = new operation_request(project, group_user, project_user); return(req); }
public async Task <string> GetAllowedOperations(string userId, ge_project project) { ge_user_ops group_user = await _unitOfWork.UserOps.GetByUserIdGroupId(userId, project.groupId); ge_user_ops project_user = await _unitOfWork.UserOps.GetByUserIdProjectId(userId, project.Id); operation_request req = new operation_request(project, group_user, project_user); return(req._effectiveProject_ops); }
public void addUser(ge_user u, string operations) { if (group != null) { if (group.users != null) { ge_user_ops os = new ge_user_ops(); os.user = u; os.operations = operations; group.users.Add(os); } } }
public async Task <IActionResult> OnGetAsync(Guid?groupId, Guid?projectId) { var CurrentUserId = GetUserIdAsync().Result; user = new ge_user(); user_ops = new ge_user_ops(); user_ops.operations = "Read;Update;Delete"; user_ops.user_operations = "Create;Read;Update;Delete"; if (groupId != null) { user_ops.group = _context.ge_group .Where(o => o.Id == groupId).FirstOrDefault(); if (user_ops.group != null) { bool IsUserGroupAdmin = _context.DoesUserHaveOperation(Constants.AdminOperationName, user_ops.group, CurrentUserId); if (!IsUserGroupAdmin) { return(RedirectToPageMessage(msgCODE.GROUP_OPERATION_CREATE_ADMINREQ)); } user_ops.groupId = user_ops.group.Id; setViewData(); return(Page()); } if (projectId != null) { return(RedirectToPageMessage(msgCODE.USER_OPS_CREATE_AMBIGUOUS)); } } if (projectId != null) { user_ops.project = _context.ge_project .Where(p => p.Id == projectId).FirstOrDefault(); if (user_ops.project != null) { bool IsUserProjectAdmin = _context.DoesUserHaveOperation(Constants.AdminOperationName, user_ops.project, CurrentUserId); if (!IsUserProjectAdmin) { return(RedirectToPageMessage(msgCODE.PROJECT_OPERATION_CREATE_ADMINREQ)); } user_ops.projectId = user_ops.project.Id; setViewData(); return(Page()); } } return(NotFound()); }
public async Task <Boolean> IsUserProjectAdmin(string userId, ge_project project) { ge_user_ops group_user = await _unitOfWork.UserOps.GetByUserIdGroupId(userId, project.groupId); if (group_user.user_operations.Contains("Admin")) { return(true); } ; ge_user_ops project_user = await _unitOfWork.UserOps.GetByUserIdProjectId(userId, project.Id); return(project_user.user_operations.Contains("Admin")); }
public static int IsOperationAllowed(this ge_DbContext context, string operation, ge_user_ops user_op) { if (context == null || user_op == null || operation == String.Empty) { return(geOPSResp.InvalidInput); } if (user_op.operations == null) { return(geOPSResp.UserOperation); } if (!user_op.operations.Contains(operation)) { return(geOPSResp.UserOperation); } return(geOPSResp.Allowed); }
public async Task UpdateUserOps(ge_user_ops dest, ge_user_ops src) { dest.projectId = src.projectId; await _unitOfWork.CommitAsync(); }
public async Task DeleteUserOps(ge_user_ops user_ops) { _unitOfWork.UserOps.Remove(user_ops); await _unitOfWork.CommitAsync(); }
public async Task <Boolean> IsUserGroupAdmin(string userId, ge_group group) { ge_user_ops group_user = await _unitOfWork.UserOps.GetByUserIdGroupId(userId, group.Id); return(group_user.user_operations.Contains("Admin")); }