feat : add version 0.5.8.9 , edit roles and permissions , fix issues

master
Amir Hossein Khademi 2024-04-25 02:33:17 +03:30
parent 34e9e73d3c
commit 5b67533eee
22 changed files with 355 additions and 275 deletions

View File

@ -1 +1 @@
0.4.8.8 0.5.8.9

View File

@ -1,6 +1,6 @@
{ {
"ConnectionStrings": { "ConnectionStrings": {
"PostgresServer": "Host=185.220.227.160;port=5432;Username=postgres;Password=ub0J7sFFThkSBmkc0TzSKsCfheRnQpyu;Database=BrizcoDB", "PostgresServer": "Host=185.220.227.123;port=5432;Username=postgres;Password=ub0J7sFFThkSBmkc0TzSKsCfheRnQpyu;Database=BrizcoDB",
"Postgres": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=BrizcoDB;Load Balance Hosts=true;Target Session Attributes=primary;Application Name=iGLS" "Postgres": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=BrizcoDB;Load Balance Hosts=true;Target Session Attributes=primary;Application Name=iGLS"
}, },
"Logging": { "Logging": {

View File

@ -6,42 +6,42 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath> <DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
<AssemblyVersion>0.4.8.8</AssemblyVersion> <AssemblyVersion>0.5.8.9</AssemblyVersion>
<FileVersion>0.4.8.8</FileVersion> <FileVersion>0.5.8.9</FileVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Asp.Versioning.Http" Version="8.0.0" /> <PackageReference Include="Asp.Versioning.Http" Version="8.1.0" />
<PackageReference Include="Ben.BlockingDetector" Version="0.0.4" /> <PackageReference Include="Ben.BlockingDetector" Version="0.0.4" />
<PackageReference Include="Carter" Version="8.0.0" /> <PackageReference Include="Carter" Version="8.0.0" />
<PackageReference Include="FluentValidation" Version="11.9.0" /> <PackageReference Include="FluentValidation" Version="11.9.1" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.0" /> <PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.1" />
<PackageReference Include="MediatR.Extensions.Autofac.DependencyInjection" Version="12.0.0" /> <PackageReference Include="MediatR.Extensions.Autofac.DependencyInjection" Version="12.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.2" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.2" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.2"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.4">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Autofac" Version="8.0.0" /> <PackageReference Include="Autofac" Version="8.0.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" /> <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Elmah.Io.AspNetCore.Serilog" Version="5.0.17" /> <PackageReference Include="Elmah.Io.AspNetCore.Serilog" Version="5.0.17" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.2" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.4" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" /> <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" /> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.1" /> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.2" />
<PackageReference Include="Sentry.Serilog" Version="4.1.1" /> <PackageReference Include="Sentry.Serilog" Version="4.4.0" />
<PackageReference Include="Serilog" Version="3.1.1" /> <PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" /> <PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" /> <PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.PostgreSQL" Version="2.3.0" /> <PackageReference Include="Serilog.Sinks.PostgreSQL" Version="2.3.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="6.0.0" /> <PackageReference Include="Serilog.Sinks.Seq" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.ElmahIo" Version="5.0.38" /> <PackageReference Include="Serilog.Sinks.ElmahIo" Version="5.0.38" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" /> <PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="StackExchange.Redis.Extensions.AspNetCore" Version="10.2.0" /> <PackageReference Include="StackExchange.Redis.Extensions.AspNetCore" Version="10.2.0" />
@ -51,7 +51,7 @@
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" /> <PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="8.0.1" /> <PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="8.0.1" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" /> <PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
<PackageReference Include="System.Drawing.Common" Version="8.0.2" /> <PackageReference Include="System.Drawing.Common" Version="8.0.4" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Using Include="Autofac" /> <Using Include="Autofac" />

View File

@ -26,7 +26,7 @@
"ASPNETCORE_URLS": "http://+:80" "ASPNETCORE_URLS": "http://+:80"
}, },
"publishAllPorts": true, "publishAllPorts": true,
"DockerfileRunArguments": " --network=mother -p 32769:80" "DockerfileRunArguments": " --network=mother -p 32767:80"
} }
}, },
"$schema": "https://json.schemastore.org/launchsettings.json", "$schema": "https://json.schemastore.org/launchsettings.json",

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<!--<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<LangVersion>10</LangVersion> <LangVersion>10</LangVersion>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
@ -11,10 +11,10 @@
<PackageReference Include="MD.PersianDateTime.Standard" Version="2.5.0" /> <PackageReference Include="MD.PersianDateTime.Standard" Version="2.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" /> <PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.3.1" /> <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.5.1" />
</ItemGroup>--> </ItemGroup>
<PropertyGroup> <!--<PropertyGroup>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
<LangVersion>10</LangVersion> <LangVersion>10</LangVersion>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
@ -25,7 +25,7 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" /> <PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.0.3" /> <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.0.3" />
</ItemGroup> </ItemGroup>-->
<ItemGroup> <ItemGroup>
<Using Include="MD.PersianDateTime.Standard" /> <Using Include="MD.PersianDateTime.Standard" />

View File

@ -97,6 +97,13 @@ public static class ApplicationClaims
Title = "مشاهده فعالیت ها", Title = "مشاهده فعالیت ها",
Detail = "دسترسی به مشاهده فعالیت ها فروشگاه شما" Detail = "دسترسی به مشاهده فعالیت ها فروشگاه شما"
}; };
public static ClaimDto ViewMineActivities { get; } = new ClaimDto
{
Type = CustomClaimType.Permission,
Value = ApplicationPermission.ViewMineActivities,
Title = "مشاهده فعالیت ها من",
Detail = "دسترسی به مشاهده فعالیت ها فروشگاه شما"
};
public static ClaimDto ManageRoutines { get; } = new ClaimDto public static ClaimDto ManageRoutines { get; } = new ClaimDto
@ -217,6 +224,7 @@ public static class ApplicationClaims
ManageComplexes, ManageComplexes,
ViewActivities, ViewActivities,
ViewMineActivities,
ManageRoutines, ManageRoutines,
ViewRoutines, ViewRoutines,
@ -257,6 +265,7 @@ public static class ApplicationClaims
ManageActivities.GetClaim, ManageActivities.GetClaim,
ViewActivities.GetClaim, ViewActivities.GetClaim,
ChangeActivityStatus.GetClaim, ChangeActivityStatus.GetClaim,
ViewMineActivities.GetClaim,
ManageRoutines.GetClaim, ManageRoutines.GetClaim,
ViewRoutines.GetClaim, ViewRoutines.GetClaim,
@ -339,7 +348,7 @@ public static class ApplicationClaims
{ {
ManageActivities.GetClaim, ManageActivities.GetClaim,
ChangeActivityStatus.GetClaim, ChangeActivityStatus.GetClaim,
ViewActivities.GetClaim, ViewMineActivities.GetClaim,
ManageReports.GetClaim, ManageReports.GetClaim,
ViewTasks.GetClaim, ViewTasks.GetClaim,
@ -351,13 +360,17 @@ public static class ApplicationClaims
ViewShifts.GetClaim, ViewShifts.GetClaim,
ManageShifts.GetClaim, ManageShifts.GetClaim,
ViewDashboard.GetClaim ViewDashboard.GetClaim,
ViewRoutines.GetClaim,
ViewPositions.GetClaim,
ViewUsers.GetClaim,
}; };
public static List<Claim> StaffClaims = new List<Claim> public static List<Claim> StaffClaims = new List<Claim>
{ {
ChangeActivityStatus.GetClaim, ChangeActivityStatus.GetClaim,
ViewActivities.GetClaim, ViewMineActivities.GetClaim,
ViewTasks.GetClaim, ViewTasks.GetClaim,

View File

@ -27,6 +27,7 @@ public static class ApplicationPermission
public const string ManageActivities = nameof(ManageActivities); public const string ManageActivities = nameof(ManageActivities);
public const string ChangeActivityStatus = nameof(ChangeActivityStatus); public const string ChangeActivityStatus = nameof(ChangeActivityStatus);
public const string ViewActivities = nameof(ViewActivities); public const string ViewActivities = nameof(ViewActivities);
public const string ViewMineActivities = nameof(ViewActivities);
public const string ManageRoutines = nameof(ManageRoutines); public const string ManageRoutines = nameof(ManageRoutines);
public const string ViewRoutines = nameof(ViewRoutines); public const string ViewRoutines = nameof(ViewRoutines);

View File

@ -0,0 +1,9 @@
namespace Brizco.Common.Models.Claims;
public static class ApplicationRoles
{
public const string Manager = nameof(Manager);
public const string ViewerOwner = nameof(ViewerOwner);
public const string SuperVisor = nameof(SuperVisor);
public const string Staff = nameof(Staff);
}

View File

@ -10,9 +10,9 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" /> <PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
<PackageReference Include="AspNetCoreRateLimit.Redis" Version="2.0.0" /> <PackageReference Include="AspNetCoreRateLimit.Redis" Version="2.0.0" />
<PackageReference Include="Autofac.Extras.Quartz" Version="9.0.0" /> <PackageReference Include="Autofac.Extras.Quartz" Version="10.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="NPOI" Version="2.6.2" /> <PackageReference Include="NPOI" Version="2.7.0" />
<PackageReference Include="Quartz" Version="3.8.1" /> <PackageReference Include="Quartz" Version="3.8.1" />
</ItemGroup> </ItemGroup>

View File

@ -25,22 +25,32 @@ public class PageService : IPageService
{ {
if (_currentUserService.UserId == null) if (_currentUserService.UserId == null)
throw new AppException("User id is null "); throw new AppException("User id is null ");
if (Guid.TryParse(_currentUserService.UserId, out Guid userId)!) if (!Guid.TryParse(_currentUserService.UserId, out Guid userId))
throw new AppException("User id is wrong"); throw new AppException("User id is wrong");
if (Guid.TryParse(_currentUserService.ComplexId, out Guid complexId)!) if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
throw new AppException("Complex id is wrong"); throw new AppException("Complex id is wrong");
var todayTasks = await _repositoryWrapper.SetRepository<Activity>() var todayTasks = await _repositoryWrapper.SetRepository<Activity>()
.TableNoTracking .TableNoTracking
.Where(a => a.UserId == userId) .Where(a => a.UserId == userId)
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);
var todayShiftPlans = await _repositoryWrapper.SetRepository<ShiftPlan>()
.TableNoTracking
.Where(a => a.PlanFor.Date == DateTime.Today.Date)
.Select(ShiftPlanMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
var names = new List<string>();
names.AddRange(todayShiftPlans.SelectMany(sp => sp.Users).Select(s => s.UserFullName).ToList());
var page = new AppDashboardPageDto var page = new AppDashboardPageDto
{ {
DoneActivitiesToday = todayTasks.Count(t => t.IsDone), DoneActivitiesToday = todayTasks.Count(t => t.IsDone),
TotalActivitiesToday = todayTasks.Count, TotalActivitiesToday = todayTasks.Count,
UnDoneActivitiesToday = todayTasks.Count(t => t.IsDone!) UnDoneActivitiesToday = todayTasks.Count(t => t.IsDone!),
TotalShiftToday = todayShiftPlans.Count,
TodayStaffNames = names,
TotalStaffToday = todayShiftPlans.SelectMany(sp => sp.Users).Count()
}; };
if (_currentUserService.Permissions != null) if (_currentUserService.Permissions != null)
{ {
int totalStepCount = 0; int totalStepCount = 0;

View File

@ -24,10 +24,10 @@ public class ComplexService : IComplexService
var managerRole = new ApplicationRole var managerRole = new ApplicationRole
{ {
ComplexId = complex.Id, ComplexId = complex.Id,
EnglishName = "Manager", EnglishName = ApplicationRoles.Manager,
PersianName = "مدیریت", PersianName = "مدیریت",
Description = "مدیریت مجموعه", Description = "مدیریت مجموعه",
Name = $"Manager_{complex.Id.ToString()}" Name = $"{ApplicationRoles.Manager}_{complex.Id.ToString()}"
}; };
var createRoleResult = await _roleManager.CreateAsync(managerRole); var createRoleResult = await _roleManager.CreateAsync(managerRole);
if (!createRoleResult.Succeeded) if (!createRoleResult.Succeeded)
@ -41,10 +41,10 @@ public class ComplexService : IComplexService
var viewOwnerRole = new ApplicationRole var viewOwnerRole = new ApplicationRole
{ {
ComplexId = complex.Id, ComplexId = complex.Id,
EnglishName = "ViewerOwner", EnglishName = ApplicationRoles.ViewerOwner,
PersianName = "ناظر", PersianName = "ناظر",
Description = "ناظر مجموعه", Description = "ناظر مجموعه",
Name = $"ViewerOwner_{complex.Id.ToString()}" Name = $"{ApplicationRoles.ViewerOwner}_{complex.Id.ToString()}"
}; };
var createViewerResult = await _roleManager.CreateAsync(viewOwnerRole); var createViewerResult = await _roleManager.CreateAsync(viewOwnerRole);
if (!createViewerResult.Succeeded) if (!createViewerResult.Succeeded)
@ -56,10 +56,10 @@ public class ComplexService : IComplexService
var superVisorRole = new ApplicationRole var superVisorRole = new ApplicationRole
{ {
ComplexId = complex.Id, ComplexId = complex.Id,
EnglishName = "SuperVisor", EnglishName = ApplicationRoles.SuperVisor,
PersianName = "سوپروایزر", PersianName = "سوپروایزر",
Description = "انجام فعالیت مدیریت کارکنان و وظیفه ها", Description = "انجام فعالیت مدیریت کارکنان و وظیفه ها",
Name = $"SuperVisor_{complex.Id.ToString()}" Name = $"{ApplicationRoles.SuperVisor}_{complex.Id.ToString()}"
}; };
var superVisorRoleResult = await _roleManager.CreateAsync(superVisorRole); var superVisorRoleResult = await _roleManager.CreateAsync(superVisorRole);
if (!superVisorRoleResult.Succeeded) if (!superVisorRoleResult.Succeeded)
@ -72,10 +72,10 @@ public class ComplexService : IComplexService
var staffRole = new ApplicationRole var staffRole = new ApplicationRole
{ {
ComplexId = complex.Id, ComplexId = complex.Id,
EnglishName = "Staff", EnglishName = ApplicationRoles.Staff,
PersianName = "کارمند", PersianName = "کارمند",
Description = "انجام فعالیت ها و وظیفه ها", Description = "انجام فعالیت ها و وظیفه ها",
Name = $"Staff_{complex.Id.ToString()}" Name = $"{ApplicationRoles.Staff}_{complex.Id.ToString()}"
}; };
var staffRoleResult = await _roleManager.CreateAsync(staffRole); var staffRoleResult = await _roleManager.CreateAsync(staffRole);
if (!staffRoleResult.Succeeded) if (!staffRoleResult.Succeeded)

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<!--<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
@ -11,12 +11,12 @@
<PackageReference Include="Mapster" Version="7.4.0" /> <PackageReference Include="Mapster" Version="7.4.0" />
<PackageReference Include="Mapster.Core" Version="1.2.1" /> <PackageReference Include="Mapster.Core" Version="1.2.1" />
<PackageReference Include="MediatR" Version="12.2.0" /> <PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.2" /> <PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.4" />
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" /> <PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
</ItemGroup>--> </ItemGroup>
<PropertyGroup> <!--<PropertyGroup>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
<LangVersion>10</LangVersion> <LangVersion>10</LangVersion>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
@ -32,7 +32,7 @@
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" /> <PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
</ItemGroup> </ItemGroup>-->
<Target Name="Mapster"> <Target Name="Mapster">

View File

@ -5,7 +5,9 @@ public class AppDashboardPageDto
public int UnDoneActivitiesToday { get; set; } public int UnDoneActivitiesToday { get; set; }
public int DoneActivitiesToday { get; set; } public int DoneActivitiesToday { get; set; }
public int TotalActivitiesToday { get; set; } public int TotalActivitiesToday { get; set; }
public int TotalShiftToday { get; set; }
public int TotalStaffToday { get; set; } public int TotalStaffToday { get; set; }
public List<string> TodayStaffNames { get; set; } = new();
public string CurrentSignUpStep { get; set; } = string.Empty; public string CurrentSignUpStep { get; set; } = string.Empty;
public int SignUpCompletePercent { get; set; } public int SignUpCompletePercent { get; set; }

View File

@ -1,19 +1,18 @@
using Brizco.Domain.Entities.Shift; namespace Brizco.Domain.Dtos.SmallDtos;
namespace Brizco.Domain.Dtos.SmallDtos;
public class ShiftPlanSDto : BaseDto<ShiftPlanSDto,ShiftPlan> public class ShiftPlanSDto : BaseDto<ShiftPlanSDto,ShiftPlan>
{ {
public DateTime PlanFor { get; internal set; } public DateTime PlanFor { get; set; }
public bool IsCompleted { get; internal set; } public bool IsCompleted { get; set; }
public int UndoneActivitiesCount { get; set; } public int UndoneActivitiesCount { get; set; }
public int DoneActivitiesCount { get; set; } public int DoneActivitiesCount { get; set; }
public int TotalActivitiesCount { get; set; } public int TotalActivitiesCount { get; set; }
public int StaffCount { get; set; } public int StaffCount { get; set; }
public int CompletePercent { get; internal set; } public int CompletePercent { get; set; }
public string CompleteDescription { get; internal set; } = string.Empty; public string SupervisorFullName { get; set; } = string.Empty;
public string CompleteDescription { get; set; } = string.Empty;
public Guid ShiftId { get; set; } public Guid ShiftId { get; set; }
public string ShiftTitle { get; internal set; } = string.Empty; public string ShiftTitle { get; set; } = string.Empty;
public List<ShiftPlanUserSDto> Users { get; set; } = new(); public List<ShiftPlanUserSDto> Users { get; set; } = new();
} }

View File

@ -23,6 +23,11 @@ namespace Brizco.Domain.Mappers
CompletePercent = p1.CompletePercent, CompletePercent = p1.CompletePercent,
CompleteDescription = p1.CompleteDescription, CompleteDescription = p1.CompleteDescription,
ShiftId = p1.ShiftId, ShiftId = p1.ShiftId,
Shift = new Shift()
{
Title = p1.ShiftTitle,
Id = p1.ShiftId
},
Users = funcMain1(p1.Users), Users = funcMain1(p1.Users),
Id = p1.Id Id = p1.Id
}; };
@ -40,184 +45,193 @@ namespace Brizco.Domain.Mappers
result.CompletePercent = p3.CompletePercent; result.CompletePercent = p3.CompletePercent;
result.CompleteDescription = p3.CompleteDescription; result.CompleteDescription = p3.CompleteDescription;
result.ShiftId = p3.ShiftId; result.ShiftId = p3.ShiftId;
result.Users = funcMain2(p3.Users, result.Users); result.Shift = funcMain2(new Never(), result.Shift, p3);
result.Users = funcMain3(p3.Users, result.Users);
result.Id = p3.Id; result.Id = p3.Id;
return result; return result;
} }
public static Expression<Func<ShiftPlanSDto, ShiftPlan>> ProjectToShiftPlan => p7 => new ShiftPlan() public static Expression<Func<ShiftPlanSDto, ShiftPlan>> ProjectToShiftPlan => p9 => new ShiftPlan()
{ {
PlanFor = p7.PlanFor, PlanFor = p9.PlanFor,
IsCompleted = p7.IsCompleted, IsCompleted = p9.IsCompleted,
CompletePercent = p7.CompletePercent, CompletePercent = p9.CompletePercent,
CompleteDescription = p7.CompleteDescription, CompleteDescription = p9.CompleteDescription,
ShiftId = p7.ShiftId, ShiftId = p9.ShiftId,
Users = p7.Users.Select<ShiftPlanUserSDto, ShiftPlanUser>(p8 => new ShiftPlanUser() Shift = new Shift()
{ {
ShiftPlanId = p8.ShiftPlanId, Title = p9.ShiftTitle,
ShiftPlan = new ShiftPlan() {Id = p8.ShiftPlanId}, Id = p9.ShiftId
PositionId = p8.PositionId, },
Users = p9.Users.Select<ShiftPlanUserSDto, ShiftPlanUser>(p10 => new ShiftPlanUser()
{
ShiftPlanId = p10.ShiftPlanId,
ShiftPlan = new ShiftPlan() {Id = p10.ShiftPlanId},
PositionId = p10.PositionId,
Position = new Position() Position = new Position()
{ {
Name = p8.PositionName, Name = p10.PositionName,
Id = p8.PositionId Id = p10.PositionId
}, },
UserId = p8.UserId, UserId = p10.UserId,
User = new ApplicationUser() {Id = p8.UserId}, User = new ApplicationUser() {Id = p10.UserId},
Id = p8.Id Id = p10.Id
}).ToList<ShiftPlanUser>(), }).ToList<ShiftPlanUser>(),
Id = p7.Id Id = p9.Id
}; };
public static ShiftPlanSDto AdaptToSDto(this ShiftPlan p9) public static ShiftPlanSDto AdaptToSDto(this ShiftPlan p11)
{ {
return p9 == null ? null : new ShiftPlanSDto() return p11 == null ? null : new ShiftPlanSDto()
{ {
PlanFor = p9.PlanFor, PlanFor = p11.PlanFor,
IsCompleted = p9.IsCompleted, IsCompleted = p11.IsCompleted,
CompletePercent = p9.CompletePercent, CompletePercent = p11.CompletePercent,
CompleteDescription = p9.CompleteDescription, SupervisorFullName = p11.Supervisor != null ? p11.Supervisor.FirstName + " " + p11.Supervisor.LastName : string.Empty,
ShiftId = p9.ShiftId, CompleteDescription = p11.CompleteDescription,
ShiftTitle = p9.Shift == null ? null : p9.Shift.Title, ShiftId = p11.ShiftId,
Users = funcMain3(p9.Users), ShiftTitle = p11.Shift == null ? null : p11.Shift.Title,
Id = p9.Id Users = funcMain4(p11.Users),
Id = p11.Id
}; };
} }
public static ShiftPlanSDto AdaptTo(this ShiftPlan p11, ShiftPlanSDto p12) public static ShiftPlanSDto AdaptTo(this ShiftPlan p13, ShiftPlanSDto p14)
{ {
if (p11 == null) if (p13 == null)
{ {
return null; return null;
} }
ShiftPlanSDto result = p12 ?? new ShiftPlanSDto(); ShiftPlanSDto result = p14 ?? new ShiftPlanSDto();
result.PlanFor = p11.PlanFor; result.PlanFor = p13.PlanFor;
result.IsCompleted = p11.IsCompleted; result.IsCompleted = p13.IsCompleted;
result.CompletePercent = p11.CompletePercent; result.CompletePercent = p13.CompletePercent;
result.CompleteDescription = p11.CompleteDescription; result.SupervisorFullName = p13.Supervisor != null ? p13.Supervisor.FirstName + " " + p13.Supervisor.LastName : string.Empty;
result.ShiftId = p11.ShiftId; result.CompleteDescription = p13.CompleteDescription;
result.ShiftTitle = p11.Shift == null ? null : p11.Shift.Title; result.ShiftId = p13.ShiftId;
result.Users = funcMain4(p11.Users, result.Users); result.ShiftTitle = p13.Shift == null ? null : p13.Shift.Title;
result.Id = p11.Id; result.Users = funcMain5(p13.Users, result.Users);
result.Id = p13.Id;
return result; return result;
} }
public static Expression<Func<ShiftPlan, ShiftPlanSDto>> ProjectToSDto => p15 => new ShiftPlanSDto() public static Expression<Func<ShiftPlan, ShiftPlanSDto>> ProjectToSDto => p17 => new ShiftPlanSDto()
{ {
PlanFor = p15.PlanFor, PlanFor = p17.PlanFor,
IsCompleted = p15.IsCompleted, IsCompleted = p17.IsCompleted,
CompletePercent = p15.CompletePercent, CompletePercent = p17.CompletePercent,
CompleteDescription = p15.CompleteDescription, SupervisorFullName = p17.Supervisor != null ? p17.Supervisor.FirstName + " " + p17.Supervisor.LastName : string.Empty,
ShiftId = p15.ShiftId, CompleteDescription = p17.CompleteDescription,
ShiftTitle = p15.Shift.Title, ShiftId = p17.ShiftId,
Users = p15.Users.Select<ShiftPlanUser, ShiftPlanUserSDto>(p16 => new ShiftPlanUserSDto() ShiftTitle = p17.Shift.Title,
Users = p17.Users.Select<ShiftPlanUser, ShiftPlanUserSDto>(p18 => new ShiftPlanUserSDto()
{ {
ShiftPlanId = p16.ShiftPlanId, ShiftPlanId = p18.ShiftPlanId,
UserId = p16.UserId, UserId = p18.UserId,
UserFullName = p16.User != null ? p16.User.FirstName + " " + p16.User.LastName : string.Empty, UserFullName = p18.User != null ? p18.User.FirstName + " " + p18.User.LastName : string.Empty,
PositionId = p16.PositionId, PositionId = p18.PositionId,
PositionName = p16.Position != null ? p16.Position.Name : string.Empty, PositionName = p18.Position != null ? p18.Position.Name : string.Empty,
Id = p16.Id Id = p18.Id
}).ToList<ShiftPlanUserSDto>(), }).ToList<ShiftPlanUserSDto>(),
Id = p15.Id Id = p17.Id
}; };
public static ShiftPlan AdaptToShiftPlan(this ShiftPlanLDto p17) public static ShiftPlan AdaptToShiftPlan(this ShiftPlanLDto p19)
{ {
return p17 == null ? null : new ShiftPlan() return p19 == null ? null : new ShiftPlan()
{ {
PlanFor = p17.PlanFor, PlanFor = p19.PlanFor,
IsCompleted = p17.IsCompleted, IsCompleted = p19.IsCompleted,
CompletePercent = p17.CompletePercent, CompletePercent = p19.CompletePercent,
CompleteDescription = p17.CompleteDescription, CompleteDescription = p19.CompleteDescription,
ShiftId = p17.ShiftId, ShiftId = p19.ShiftId,
Shift = new Shift() {Id = p17.ShiftId}, Shift = new Shift() {Id = p19.ShiftId},
RoutineId = p17.RoutineId, RoutineId = p19.RoutineId,
Routine = new Routine() {Id = p17.RoutineId}, Routine = new Routine() {Id = p19.RoutineId},
SupervisorId = p17.SupervisorId, SupervisorId = p19.SupervisorId,
Supervisor = new ApplicationUser() {Id = p17.SupervisorId}, Supervisor = new ApplicationUser() {Id = p19.SupervisorId},
Users = funcMain5(p17.Users), Users = funcMain6(p19.Users),
Id = p17.Id Id = p19.Id
}; };
} }
public static ShiftPlan AdaptTo(this ShiftPlanLDto p19, ShiftPlan p20) public static ShiftPlan AdaptTo(this ShiftPlanLDto p21, ShiftPlan p22)
{ {
if (p19 == null) if (p21 == null)
{ {
return null; return null;
} }
ShiftPlan result = p20 ?? new ShiftPlan(); ShiftPlan result = p22 ?? new ShiftPlan();
result.PlanFor = p19.PlanFor; result.PlanFor = p21.PlanFor;
result.IsCompleted = p19.IsCompleted; result.IsCompleted = p21.IsCompleted;
result.CompletePercent = p19.CompletePercent; result.CompletePercent = p21.CompletePercent;
result.CompleteDescription = p19.CompleteDescription; result.CompleteDescription = p21.CompleteDescription;
result.ShiftId = p19.ShiftId; result.ShiftId = p21.ShiftId;
result.Shift = funcMain6(new Never(), result.Shift, p19); result.Shift = funcMain7(new Never(), result.Shift, p21);
result.RoutineId = p19.RoutineId; result.RoutineId = p21.RoutineId;
result.Routine = funcMain7(new Never(), result.Routine, p19); result.Routine = funcMain8(new Never(), result.Routine, p21);
result.SupervisorId = p19.SupervisorId; result.SupervisorId = p21.SupervisorId;
result.Supervisor = funcMain8(new Never(), result.Supervisor, p19); result.Supervisor = funcMain9(new Never(), result.Supervisor, p21);
result.Users = funcMain9(p19.Users, result.Users); result.Users = funcMain10(p21.Users, result.Users);
result.Id = p19.Id; result.Id = p21.Id;
return result; return result;
} }
public static ShiftPlanLDto AdaptToLDto(this ShiftPlan p29) public static ShiftPlanLDto AdaptToLDto(this ShiftPlan p31)
{ {
return p29 == null ? null : new ShiftPlanLDto() return p31 == null ? null : new ShiftPlanLDto()
{ {
PlanFor = p29.PlanFor, PlanFor = p31.PlanFor,
RoutineId = p29.RoutineId, RoutineId = p31.RoutineId,
IsCompleted = p29.IsCompleted, IsCompleted = p31.IsCompleted,
CompletePercent = p29.CompletePercent, CompletePercent = p31.CompletePercent,
CompleteDescription = p29.CompleteDescription, CompleteDescription = p31.CompleteDescription,
ShiftId = p29.ShiftId, ShiftId = p31.ShiftId,
Users = funcMain10(p29.Users), Users = funcMain11(p31.Users),
SupervisorId = p29.SupervisorId, SupervisorId = p31.SupervisorId,
SupervisorFullName = p29.Supervisor != null ? p29.Supervisor.FirstName + " " + p29.Supervisor.LastName : string.Empty, SupervisorFullName = p31.Supervisor != null ? p31.Supervisor.FirstName + " " + p31.Supervisor.LastName : string.Empty,
Id = p29.Id Id = p31.Id
}; };
} }
public static ShiftPlanLDto AdaptTo(this ShiftPlan p31, ShiftPlanLDto p32) public static ShiftPlanLDto AdaptTo(this ShiftPlan p33, ShiftPlanLDto p34)
{ {
if (p31 == null) if (p33 == null)
{ {
return null; return null;
} }
ShiftPlanLDto result = p32 ?? new ShiftPlanLDto(); ShiftPlanLDto result = p34 ?? new ShiftPlanLDto();
result.PlanFor = p31.PlanFor; result.PlanFor = p33.PlanFor;
result.RoutineId = p31.RoutineId; result.RoutineId = p33.RoutineId;
result.IsCompleted = p31.IsCompleted; result.IsCompleted = p33.IsCompleted;
result.CompletePercent = p31.CompletePercent; result.CompletePercent = p33.CompletePercent;
result.CompleteDescription = p31.CompleteDescription; result.CompleteDescription = p33.CompleteDescription;
result.ShiftId = p31.ShiftId; result.ShiftId = p33.ShiftId;
result.Users = funcMain11(p31.Users, result.Users); result.Users = funcMain12(p33.Users, result.Users);
result.SupervisorId = p31.SupervisorId; result.SupervisorId = p33.SupervisorId;
result.SupervisorFullName = p31.Supervisor != null ? p31.Supervisor.FirstName + " " + p31.Supervisor.LastName : string.Empty; result.SupervisorFullName = p33.Supervisor != null ? p33.Supervisor.FirstName + " " + p33.Supervisor.LastName : string.Empty;
result.Id = p31.Id; result.Id = p33.Id;
return result; return result;
} }
public static Expression<Func<ShiftPlan, ShiftPlanLDto>> ProjectToLDto => p35 => new ShiftPlanLDto() public static Expression<Func<ShiftPlan, ShiftPlanLDto>> ProjectToLDto => p37 => new ShiftPlanLDto()
{ {
PlanFor = p35.PlanFor, PlanFor = p37.PlanFor,
RoutineId = p35.RoutineId, RoutineId = p37.RoutineId,
IsCompleted = p35.IsCompleted, IsCompleted = p37.IsCompleted,
CompletePercent = p35.CompletePercent, CompletePercent = p37.CompletePercent,
CompleteDescription = p35.CompleteDescription, CompleteDescription = p37.CompleteDescription,
ShiftId = p35.ShiftId, ShiftId = p37.ShiftId,
Users = p35.Users.Select<ShiftPlanUser, ShiftPlanUserSDto>(p36 => new ShiftPlanUserSDto() Users = p37.Users.Select<ShiftPlanUser, ShiftPlanUserSDto>(p38 => new ShiftPlanUserSDto()
{ {
ShiftPlanId = p36.ShiftPlanId, ShiftPlanId = p38.ShiftPlanId,
UserId = p36.UserId, UserId = p38.UserId,
UserFullName = p36.User != null ? p36.User.FirstName + " " + p36.User.LastName : string.Empty, UserFullName = p38.User != null ? p38.User.FirstName + " " + p38.User.LastName : string.Empty,
PositionId = p36.PositionId, PositionId = p38.PositionId,
PositionName = p36.Position != null ? p36.Position.Name : string.Empty, PositionName = p38.Position != null ? p38.Position.Name : string.Empty,
Id = p36.Id Id = p38.Id
}).ToList<ShiftPlanUserSDto>(), }).ToList<ShiftPlanUserSDto>(),
SupervisorId = p35.SupervisorId, SupervisorId = p37.SupervisorId,
SupervisorFullName = p35.Supervisor != null ? p35.Supervisor.FirstName + " " + p35.Supervisor.LastName : string.Empty, SupervisorFullName = p37.Supervisor != null ? p37.Supervisor.FirstName + " " + p37.Supervisor.LastName : string.Empty,
Id = p35.Id Id = p37.Id
}; };
private static List<ShiftPlanUser> funcMain1(List<ShiftPlanUserSDto> p2) private static List<ShiftPlanUser> funcMain1(List<ShiftPlanUserSDto> p2)
@ -254,20 +268,30 @@ namespace Brizco.Domain.Mappers
} }
private static List<ShiftPlanUser> funcMain2(List<ShiftPlanUserSDto> p5, List<ShiftPlanUser> p6) private static Shift funcMain2(Never p5, Shift p6, ShiftPlanSDto p3)
{ {
if (p5 == null) Shift result = p6 ?? new Shift();
result.Title = p3.ShiftTitle;
result.Id = p3.ShiftId;
return result;
}
private static List<ShiftPlanUser> funcMain3(List<ShiftPlanUserSDto> p7, List<ShiftPlanUser> p8)
{
if (p7 == null)
{ {
return null; return null;
} }
List<ShiftPlanUser> result = new List<ShiftPlanUser>(p5.Count); List<ShiftPlanUser> result = new List<ShiftPlanUser>(p7.Count);
int i = 0; int i = 0;
int len = p5.Count; int len = p7.Count;
while (i < len) while (i < len)
{ {
ShiftPlanUserSDto item = p5[i]; ShiftPlanUserSDto item = p7[i];
result.Add(item == null ? null : new ShiftPlanUser() result.Add(item == null ? null : new ShiftPlanUser()
{ {
ShiftPlanId = item.ShiftPlanId, ShiftPlanId = item.ShiftPlanId,
@ -288,20 +312,20 @@ namespace Brizco.Domain.Mappers
} }
private static List<ShiftPlanUserSDto> funcMain3(List<ShiftPlanUser> p10) private static List<ShiftPlanUserSDto> funcMain4(List<ShiftPlanUser> p12)
{ {
if (p10 == null) if (p12 == null)
{ {
return null; return null;
} }
List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p10.Count); List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p12.Count);
int i = 0; int i = 0;
int len = p10.Count; int len = p12.Count;
while (i < len) while (i < len)
{ {
ShiftPlanUser item = p10[i]; ShiftPlanUser item = p12[i];
result.Add(item == null ? null : new ShiftPlanUserSDto() result.Add(item == null ? null : new ShiftPlanUserSDto()
{ {
ShiftPlanId = item.ShiftPlanId, ShiftPlanId = item.ShiftPlanId,
@ -317,20 +341,20 @@ namespace Brizco.Domain.Mappers
} }
private static List<ShiftPlanUserSDto> funcMain4(List<ShiftPlanUser> p13, List<ShiftPlanUserSDto> p14) private static List<ShiftPlanUserSDto> funcMain5(List<ShiftPlanUser> p15, List<ShiftPlanUserSDto> p16)
{ {
if (p13 == null) if (p15 == null)
{ {
return null; return null;
} }
List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p13.Count); List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p15.Count);
int i = 0; int i = 0;
int len = p13.Count; int len = p15.Count;
while (i < len) while (i < len)
{ {
ShiftPlanUser item = p13[i]; ShiftPlanUser item = p15[i];
result.Add(item == null ? null : new ShiftPlanUserSDto() result.Add(item == null ? null : new ShiftPlanUserSDto()
{ {
ShiftPlanId = item.ShiftPlanId, ShiftPlanId = item.ShiftPlanId,
@ -346,20 +370,20 @@ namespace Brizco.Domain.Mappers
} }
private static List<ShiftPlanUser> funcMain5(List<ShiftPlanUserSDto> p18) private static List<ShiftPlanUser> funcMain6(List<ShiftPlanUserSDto> p20)
{ {
if (p18 == null) if (p20 == null)
{ {
return null; return null;
} }
List<ShiftPlanUser> result = new List<ShiftPlanUser>(p18.Count); List<ShiftPlanUser> result = new List<ShiftPlanUser>(p20.Count);
int i = 0; int i = 0;
int len = p18.Count; int len = p20.Count;
while (i < len) while (i < len)
{ {
ShiftPlanUserSDto item = p18[i]; ShiftPlanUserSDto item = p20[i];
result.Add(item == null ? null : new ShiftPlanUser() result.Add(item == null ? null : new ShiftPlanUser()
{ {
ShiftPlanId = item.ShiftPlanId, ShiftPlanId = item.ShiftPlanId,
@ -380,47 +404,47 @@ namespace Brizco.Domain.Mappers
} }
private static Shift funcMain6(Never p21, Shift p22, ShiftPlanLDto p19) private static Shift funcMain7(Never p23, Shift p24, ShiftPlanLDto p21)
{ {
Shift result = p22 ?? new Shift(); Shift result = p24 ?? new Shift();
result.Id = p19.ShiftId; result.Id = p21.ShiftId;
return result; return result;
} }
private static Routine funcMain7(Never p23, Routine p24, ShiftPlanLDto p19) private static Routine funcMain8(Never p25, Routine p26, ShiftPlanLDto p21)
{ {
Routine result = p24 ?? new Routine(); Routine result = p26 ?? new Routine();
result.Id = p19.RoutineId; result.Id = p21.RoutineId;
return result; return result;
} }
private static ApplicationUser funcMain8(Never p25, ApplicationUser p26, ShiftPlanLDto p19) private static ApplicationUser funcMain9(Never p27, ApplicationUser p28, ShiftPlanLDto p21)
{ {
ApplicationUser result = p26 ?? new ApplicationUser(); ApplicationUser result = p28 ?? new ApplicationUser();
result.Id = p19.SupervisorId; result.Id = p21.SupervisorId;
return result; return result;
} }
private static List<ShiftPlanUser> funcMain9(List<ShiftPlanUserSDto> p27, List<ShiftPlanUser> p28) private static List<ShiftPlanUser> funcMain10(List<ShiftPlanUserSDto> p29, List<ShiftPlanUser> p30)
{ {
if (p27 == null) if (p29 == null)
{ {
return null; return null;
} }
List<ShiftPlanUser> result = new List<ShiftPlanUser>(p27.Count); List<ShiftPlanUser> result = new List<ShiftPlanUser>(p29.Count);
int i = 0; int i = 0;
int len = p27.Count; int len = p29.Count;
while (i < len) while (i < len)
{ {
ShiftPlanUserSDto item = p27[i]; ShiftPlanUserSDto item = p29[i];
result.Add(item == null ? null : new ShiftPlanUser() result.Add(item == null ? null : new ShiftPlanUser()
{ {
ShiftPlanId = item.ShiftPlanId, ShiftPlanId = item.ShiftPlanId,
@ -441,20 +465,20 @@ namespace Brizco.Domain.Mappers
} }
private static List<ShiftPlanUserSDto> funcMain10(List<ShiftPlanUser> p30) private static List<ShiftPlanUserSDto> funcMain11(List<ShiftPlanUser> p32)
{ {
if (p30 == null) if (p32 == null)
{ {
return null; return null;
} }
List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p30.Count); List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p32.Count);
int i = 0; int i = 0;
int len = p30.Count; int len = p32.Count;
while (i < len) while (i < len)
{ {
ShiftPlanUser item = p30[i]; ShiftPlanUser item = p32[i];
result.Add(item == null ? null : new ShiftPlanUserSDto() result.Add(item == null ? null : new ShiftPlanUserSDto()
{ {
ShiftPlanId = item.ShiftPlanId, ShiftPlanId = item.ShiftPlanId,
@ -470,20 +494,20 @@ namespace Brizco.Domain.Mappers
} }
private static List<ShiftPlanUserSDto> funcMain11(List<ShiftPlanUser> p33, List<ShiftPlanUserSDto> p34) private static List<ShiftPlanUserSDto> funcMain12(List<ShiftPlanUser> p35, List<ShiftPlanUserSDto> p36)
{ {
if (p33 == null) if (p35 == null)
{ {
return null; return null;
} }
List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p33.Count); List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p35.Count);
int i = 0; int i = 0;
int len = p33.Count; int len = p35.Count;
while (i < len) while (i < len)
{ {
ShiftPlanUser item = p33[i]; ShiftPlanUser item = p35[i];
result.Add(item == null ? null : new ShiftPlanUserSDto() result.Add(item == null ? null : new ShiftPlanUserSDto()
{ {
ShiftPlanId = item.ShiftPlanId, ShiftPlanId = item.ShiftPlanId,

View File

@ -44,6 +44,10 @@ public class MapsterRegister : IRegister
.Map("SupervisorFullName", o => o.Supervisor != null ? o.Supervisor.FirstName + " " + o.Supervisor.LastName : string.Empty) .Map("SupervisorFullName", o => o.Supervisor != null ? o.Supervisor.FirstName + " " + o.Supervisor.LastName : string.Empty)
.TwoWays(); .TwoWays();
config.NewConfig<ShiftPlan, ShiftPlanSDto>()
.Map("SupervisorFullName", o => o.Supervisor != null ? o.Supervisor.FirstName + " " + o.Supervisor.LastName : string.Empty)
.TwoWays();
config.NewConfig<ShiftPlanUser, ShiftPlanUserSDto>() config.NewConfig<ShiftPlanUser, ShiftPlanUserSDto>()
.Map("UserFullName", o => o.User != null ? o.User.FirstName + " " + o.User.LastName : string.Empty) .Map("UserFullName", o => o.User != null ? o.User.FirstName + " " + o.User.LastName : string.Empty)
.Map("PositionName", o => o.Position != null ? o.Position.Name : string.Empty) .Map("PositionName", o => o.Position != null ? o.Position.Name : string.Empty)

View File

@ -8,21 +8,21 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="MediatR" Version="12.2.0" /> <PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="FluentValidation" Version="11.9.0" /> <PackageReference Include="FluentValidation" Version="11.9.1" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.2" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.2"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.4">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Pluralize.NET" Version="1.0.2" /> <PackageReference Include="Pluralize.NET" Version="1.0.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" /> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.2" /> <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.4" />
<PackageReference Include="StackExchange.Redis" Version="2.7.17" /> <PackageReference Include="StackExchange.Redis" Version="2.7.33" />
<PackageReference Include="StackExchange.Redis.Extensions.Core" Version="10.2.0" /> <PackageReference Include="StackExchange.Redis.Extensions.Core" Version="10.2.0" />
</ItemGroup> </ItemGroup>

View File

@ -25,6 +25,11 @@ public class GetActivitiesQueryHandler : IRequestHandler<GetActivitiesQuery, Lis
IQueryable<Domain.Entities.Task.Activity> activities = _repositoryWrapper.SetRepository<Domain.Entities.Task.Activity>().TableNoTracking IQueryable<Domain.Entities.Task.Activity> activities = _repositoryWrapper.SetRepository<Domain.Entities.Task.Activity>().TableNoTracking
.Where(a=>a.IsActivity); .Where(a=>a.IsActivity);
if (_currentUserService.Permissions != null)
{
if (_currentUserService.Permissions.Contains(ApplicationPermission.ViewMineActivities))
activities = activities.Where(a => a.UserId == userId);
}
if (request.DateQueryFilter != null) if (request.DateQueryFilter != null)
{ {
@ -53,9 +58,6 @@ public class GetActivitiesQueryHandler : IRequestHandler<GetActivitiesQuery, Lis
if (request.SelectedShift != default) if (request.SelectedShift != default)
activities = activities.Where(a => a.ComplexId == complexId && a.ShiftId == request.SelectedShift); activities = activities.Where(a => a.ComplexId == complexId && a.ShiftId == request.SelectedShift);
if (request.SelectedDate == 0 && request.SelectedShift == default)
activities = activities.Where(a => a.UserId == userId);
return await activities.OrderBy(s => s.ScheduleType) return await activities.OrderBy(s => s.ScheduleType)

View File

@ -1,4 +1,5 @@
using Brizco.Domain.Entities.Shift; using Brizco.Domain.Entities.Shift;
using Guid = System.Guid;
namespace Brizco.Repository.Handlers.Shift; namespace Brizco.Repository.Handlers.Shift;
@ -18,15 +19,15 @@ public class GetShiftPlansQueryHandler : IRequestHandler<GetShiftsQuery, List<Sh
throw new AppException("ComplexId is null", ApiResultStatusCode.NotFound); throw new AppException("ComplexId is null", ApiResultStatusCode.NotFound);
if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId)) if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound); throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound);
List<ShiftSDto> shifts = new List<ShiftSDto>(); List<ShiftSDto> shifts;
if (request.SelectedDate > 0) if (request.SelectedDate > 0)
{ {
var selectedDate = DateTimeExtensions.UnixTimeStampToDateTime(request.SelectedDate); var selectedDate = DateTimeExtensions.UnixTimeStampToDateTime(request.SelectedDate);
var originalShifts = from shiftDay in _repositoryWrapper.SetRepository<ShiftDay>().Entities var originalShifts = from shiftDay in _repositoryWrapper.SetRepository<ShiftDay>().Entities
join shift in _repositoryWrapper.SetRepository<Domain.Entities.Shift.Shift>().Entities on shiftDay .ShiftId equals shift.Id join shift in _repositoryWrapper.SetRepository<Domain.Entities.Shift.Shift>().Entities on shiftDay.ShiftId equals shift.Id
where shiftDay.DayOfWeek == selectedDate.DayOfWeek && shift.ComplexId == complexId where shiftDay.DayOfWeek == selectedDate.DayOfWeek && shift.ComplexId == complexId
select shift; select shift;
shifts = await originalShifts.AsNoTracking().Select(ShiftMapper.ProjectToSDto).ToListAsync(cancellationToken); shifts = await originalShifts.AsNoTracking().Select(ShiftMapper.ProjectToSDto).ToListAsync(cancellationToken);
foreach (var shift in shifts) foreach (var shift in shifts)
@ -44,12 +45,33 @@ public class GetShiftPlansQueryHandler : IRequestHandler<GetShiftsQuery, List<Sh
shift.DoneActivitiesCount = doneActivitiesCount; shift.DoneActivitiesCount = doneActivitiesCount;
shift.TotalActivitiesCount = activitiesCount; shift.TotalActivitiesCount = activitiesCount;
var existedShiftPlan = await _repositoryWrapper.SetRepository<Domain.Entities.Shift.ShiftPlan>() switch (_currentUserService.RoleName)
.TableNoTracking {
.FirstOrDefaultAsync(s => s.ShiftId == shift.Id && s.PlanFor.Date == selectedDate.Date, cancellationToken); case null:
shift.IsCompleted = existedShiftPlan?.IsCompleted ?? false; continue;
shift.CurrentShiftPlanId = existedShiftPlan?.Id ?? default; case ApplicationRoles.SuperVisor:
shift.HasCurrentShiftPlan = existedShiftPlan != null; {
if (!Guid.TryParse(_currentUserService.UserId, out Guid userId))
throw new AppException("User id is wrong");
var existedShiftPlan = await _repositoryWrapper.SetRepository<Domain.Entities.Shift.ShiftPlan>()
.TableNoTracking
.FirstOrDefaultAsync(s => s.ShiftId == shift.Id && s.PlanFor.Date == selectedDate.Date && s.SupervisorId == userId, cancellationToken);
shift.IsCompleted = existedShiftPlan?.IsCompleted ?? false;
shift.CurrentShiftPlanId = existedShiftPlan?.Id ?? default;
shift.HasCurrentShiftPlan = existedShiftPlan != null;
break;
}
case ApplicationRoles.Manager:
{
var existedShiftPlan = await _repositoryWrapper.SetRepository<Domain.Entities.Shift.ShiftPlan>()
.TableNoTracking
.FirstOrDefaultAsync(s => s.ShiftId == shift.Id && s.PlanFor.Date == selectedDate.Date, cancellationToken);
shift.IsCompleted = existedShiftPlan?.IsCompleted ?? false;
shift.CurrentShiftPlanId = existedShiftPlan?.Id ?? default;
shift.HasCurrentShiftPlan = existedShiftPlan != null;
break;
}
}
} }
} }
else else
@ -61,18 +83,20 @@ public class GetShiftPlansQueryHandler : IRequestHandler<GetShiftsQuery, List<Sh
.Skip(request.Page * 15).Take(15) .Skip(request.Page * 15).Take(15)
.Select(ShiftMapper.ProjectToSDto) .Select(ShiftMapper.ProjectToSDto)
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);
} }
foreach (var shift in shifts) foreach (var shift in shifts)
{ {
var shiftDays = new List<DayOfWeek>(); var shiftDays = new List<DayOfWeek>();
shift.Days.OrderBy(d=>d).ToList().ForEach(d => shift.Days.OrderBy(d => d).ToList().ForEach(d =>
{ {
if(d==DayOfWeek.Saturday) if (d == DayOfWeek.Saturday)
shiftDays.Insert(0,d); shiftDays.Insert(0, d);
else{ else
shiftDays.Add(d);} {
shiftDays.Add(d);
}
}); });
shift.Days = shiftDays; shift.Days = shiftDays;

View File

@ -14,6 +14,7 @@ public static class RepositoryConfig
{ {
identityDbInitialize.Initialize(); identityDbInitialize.Initialize();
await identityDbInitialize.SeedDate(); await identityDbInitialize.SeedDate();
await identityDbInitialize.Refactor();
} }
} }
} }

View File

@ -8,4 +8,5 @@ public interface IDbInitializerService : IScopedDependency
void Initialize(); void Initialize();
Task SeedDate(bool force = false); Task SeedDate(bool force = false);
Task SeedRoles(); Task SeedRoles();
Task Refactor();
} }

View File

@ -89,54 +89,44 @@ public class DbInitializerService : IDbInitializerService
foreach (var claim in ApplicationClaims.AllClaims) foreach (var claim in ApplicationClaims.AllClaims)
await _roleManager.AddClaimAsync(managerRole, claim); await _roleManager.AddClaimAsync(managerRole, claim);
} }
}
public async Task Refactor()
{
//var roles = await _roleManager.Roles.ToListAsync(); //var roles = await _roleManager.Roles.ToListAsync();
//foreach (var role in roles) //foreach (var role in roles)
//{ //{
// if (role.EnglishName == "Manager") // if (role.EnglishName == ApplicationRoles.Manager)
// { // {
// var claims = await _roleManager.GetClaimsAsync(role); // var claims = await _roleManager.GetClaimsAsync(role);
// foreach (var claim in claims)
// await _roleManager.RemoveClaimAsync(role,claim);
// foreach (var claim in ApplicationClaims.ManagerClaims) // foreach (var claim in ApplicationClaims.ManagerClaims)
// {
// if(!claims.Contains(claim))
// await _roleManager.AddClaimAsync(role, claim); // await _roleManager.AddClaimAsync(role, claim);
// }
// } // }
// else if (role.EnglishName == "ViewerOwner") // if (role.EnglishName == ApplicationRoles.ViewerOwner)
// { // {
// var claims = await _roleManager.GetClaimsAsync(role); // var claims = await _roleManager.GetClaimsAsync(role);
// foreach (var claim in claims)
// await _roleManager.RemoveClaimAsync(role, claim);
// foreach (var claim in ApplicationClaims.ViewerOwnerClaims) // foreach (var claim in ApplicationClaims.ViewerOwnerClaims)
// { // await _roleManager.AddClaimAsync(role, claim);
// if (!claims.Contains(claim))
// await _roleManager.AddClaimAsync(role, claim);
// }
// } // }
// else if (role.EnglishName == "SuperVisor") // if (role.EnglishName == ApplicationRoles.SuperVisor)
// { // {
// var claims = await _roleManager.GetClaimsAsync(role); // var claims = await _roleManager.GetClaimsAsync(role);
// foreach (var claim in claims)
// await _roleManager.RemoveClaimAsync(role, claim);
// foreach (var claim in ApplicationClaims.SuperVisorClaims) // foreach (var claim in ApplicationClaims.SuperVisorClaims)
// { // await _roleManager.AddClaimAsync(role, claim);
// if (!claims.Contains(claim))
// await _roleManager.AddClaimAsync(role, claim);
// }
// } // }
// else if (role.EnglishName == "Staff") // if (role.EnglishName == ApplicationRoles.Staff)
// { // {
// var claims = await _roleManager.GetClaimsAsync(role); // var claims = await _roleManager.GetClaimsAsync(role);
// foreach (var claim in claims)
// await _roleManager.RemoveClaimAsync(role, claim);
// foreach (var claim in ApplicationClaims.StaffClaims) // foreach (var claim in ApplicationClaims.StaffClaims)
// { // await _roleManager.AddClaimAsync(role, claim);
// if (!claims.Contains(claim))
// await _roleManager.AddClaimAsync(role, claim);
// }
// } // }
//} //}
} }