diff --git a/.version b/.version
index 78a37ec..951b434 100644
--- a/.version
+++ b/.version
@@ -1 +1 @@
-0.2.4.2
\ No newline at end of file
+0.2.5.1
\ No newline at end of file
diff --git a/Brizco.Api/Brizco.Api.csproj b/Brizco.Api/Brizco.Api.csproj
index 7158b34..6ab550f 100644
--- a/Brizco.Api/Brizco.Api.csproj
+++ b/Brizco.Api/Brizco.Api.csproj
@@ -6,8 +6,8 @@
enable
Linux
..\docker-compose.dcproj
- 0.2.3.2
- 0.2.3.2
+ 0.2.5.1
+ 0.2.5.1
diff --git a/Brizco.Core/EntityServices/ActivityService.cs b/Brizco.Core/EntityServices/ActivityService.cs
index ed92687..3055a7e 100644
--- a/Brizco.Core/EntityServices/ActivityService.cs
+++ b/Brizco.Core/EntityServices/ActivityService.cs
@@ -140,8 +140,7 @@ public class ActivityService : IActivityService
return true;
}
- public async Task CreateActivitiesByShiftPlan(Guid shiftPlanId, CancellationToken cancellationToken)
- {
+ public async Task CreateActivitiesByShiftPlan(Guid shiftPlanId, CancellationToken cancellationToken) {
var shiftPlan = await _mediator.Send(new GetShiftPlanQuery(shiftPlanId), cancellationToken);
if (shiftPlan.Id == Guid.Empty)
return false;
diff --git a/Brizco.Core/EntityServices/UserService.cs b/Brizco.Core/EntityServices/UserService.cs
index b0091c3..1c46ac6 100644
--- a/Brizco.Core/EntityServices/UserService.cs
+++ b/Brizco.Core/EntityServices/UserService.cs
@@ -1,6 +1,5 @@
using System.Security.Claims;
using Brizco.Domain.CommandQueries.Queries;
-using Brizco.Domain.Entities.Complex;
using Brizco.Domain.Mappers;
using Mapster;
@@ -52,7 +51,7 @@ public class UserService : IUserService
userSDto.SelectedComplexName = complexUserRole!.ComplexName;
userSDto.SelectedRoleName = complexUserRole!.RoleName;
response.User.SelectedRoleId = complexUserRole!.Id;
- var role = await _roleManager.FindByIdAsync(complexUserRole.RoleId.ToString());
+ var role = await _roleManager.FindByIdAsync(complexUserRole.RoleId.ToString());
if (role != null)
{
var roleClaims = await _roleManager.GetClaimsAsync(role);
@@ -153,7 +152,7 @@ public class UserService : IUserService
return response;
}
- public async Task> GetUserRolesAsync(Guid userId,CancellationToken cancellationToken)
+ public async Task> GetUserRolesAsync(Guid userId, CancellationToken cancellationToken)
{
var user = await _userManager.FindByIdAsync(userId.ToString());
if (user == null)
@@ -201,12 +200,32 @@ public class UserService : IUserService
if (user == null)
throw new AppException("User not found", ApiResultStatusCode.NotFound);
var dto = user.AdaptToSDto();
- var roles = await _userManager.GetRolesAsync(user);
- foreach (var roleName in roles)
+ if (_currentUserService.ComplexId == null || !Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
{
- var role = await _roleManager.FindByNameAsync(roleName);
- if (role != null)
- dto.RoleIds.Add(role.Id);
+ var roles = await _userManager.GetRolesAsync(user);
+ foreach (var roleName in roles)
+ {
+ var role = await _roleManager.FindByNameAsync(roleName);
+ if (role != null)
+ dto.RoleIds.Add(role.Id);
+ }
+ }
+ else
+ {
+ var complexUser = await _repositoryWrapper.SetRepository().TableNoTracking
+ .FirstOrDefaultAsync(c => c.UserId == userId && c.ComplexId == complexId);
+
+ if (complexUser == null)
+ throw new AppException("ComplexUser not found", ApiResultStatusCode.NotFound);
+
+ var complexUserRoles = await _repositoryWrapper.SetRepository()
+ .TableNoTracking
+ .Where(cur => cur.ComplexUserId == complexUser.Id)
+ .ToListAsync();
+ foreach (var userRole in complexUserRoles)
+ {
+ dto.RoleIds.Add(userRole.RoleId);
+ }
}
return dto;
}
@@ -300,7 +319,7 @@ public class UserService : IUserService
if (!addPassResult.Succeeded)
throw new AppException(string.Join('|', addPassResult.Errors.Select(e => e.Description)));
}
-
+
await _sender.Send(new UpdateComplexUserCommand(user.Id, complexId, request.RoleIds), cancellationToken);
return true;
}
diff --git a/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs b/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs
index a7837a6..0207d9a 100644
--- a/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs
+++ b/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs
@@ -23,7 +23,8 @@ public class GetActivitiesQueryHandler : IRequestHandler activities = _repositoryWrapper.SetRepository().TableNoTracking.Where(a=>a.IsActivity);
+ IQueryable activities = _repositoryWrapper.SetRepository().TableNoTracking
+ .Where(a=>a.IsActivity);
if (request.SelectedDate > 0)
@@ -40,7 +41,7 @@ public class GetActivitiesQueryHandler : IRequestHandler s.CreatedAt)
+ return await activities.OrderBy(s => s.ScheduleType)
.Skip(request.Page * 15).Take(15)
.Select(ActivityMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
diff --git a/Brizco.Repository/Handlers/Complex/UpdateComplexUserCommandHandler.cs b/Brizco.Repository/Handlers/Complex/UpdateComplexUserCommandHandler.cs
index 0795b44..c1f433f 100644
--- a/Brizco.Repository/Handlers/Complex/UpdateComplexUserCommandHandler.cs
+++ b/Brizco.Repository/Handlers/Complex/UpdateComplexUserCommandHandler.cs
@@ -25,7 +25,7 @@ public class UpdateComplexUserCommandHandler : IRequestHandler().TableNoTracking
- .FirstOrDefaultAsync(c => c.UserId == request.UserId && c.ComplexId==request.ComplexId , cancellationToken);
+ .FirstOrDefaultAsync(c => c.UserId == request.UserId && c.ComplexId == request.ComplexId , cancellationToken);
if (complexUser == null)
throw new AppException("ComplexUser not found", ApiResultStatusCode.NotFound);