Base solution for your next web application

Activities of "sagreven"

Answer

This is a service function. So nothing special. The commentend function shows the workaround.

Edit: I think I have a general problem with the UOW because I also discovered in other functions that it's not possible to disable filter. How can I debug this? I tried to disable the IMustHaveTenant filter but than while debugging the table is even not resolveable in the debugger mode.

[UnitOfWork]
		public async Task AddToRole(long userId, string roleName, int? tenantId)
		{
			if (tenantId == null)
				CheckErrors(await _userManager.AddToRoleAsync(userId, roleName));
			else
			{
				using (_unitOfWorkManager.Current.SetFilterParameter(AbpDataFilters.MayHaveTenant, AbpDataFilters.Parameters.TenantId, tenantId))
				{
					// Todo: Temporary fix
					//var role = await _roleManager.GetRoleByNameAsync(roleName);
					//if (await _userRoleRepository.FirstOrDefaultAsync(x => x.RoleId == role.Id && x.TenantId == (int)tenantId) != null)
					//	throw new UserFriendlyException("Permission already assigned.");
					//await _userRoleRepository.InsertAsync(new UserRole(tenantId, userId, role.Id));
					await _sessionAppService.ResetAllCaches();
					CheckErrors(await _userManager.AddToRoleAsync(userId, roleName));
				}
			}
		}

Thanks.

For the first issue: I also replaced everything to the then semantics.

For the second issue: You also right. Changed all links to use !/

Thx for the tip.

Showing 1 to 2 of 2 entries