Compare commits

..

No commits in common. "5328e74f790c026ee6807157b875ddb1e06e5017" and "81762ecb645c100e7c7a02ec6c226bfccac372a2" have entirely different histories.

56 changed files with 659 additions and 2607 deletions

View File

@ -1 +1 @@
1.4.9.4 1.0.1.2

View File

@ -1,7 +1,6 @@
{ {
"ConnectionStrings": { "ConnectionStrings": {
"PostgresServer": "Host=185.220.227.126;port=5432;Username=postgres;Password=ub0J7sFFThkSBmkc0TzSKsCfheRnQpyu;Database=BrizcoDB", "PostgresServer": "Host=185.220.227.123;port=5432;Username=postgres;Password=ub0J7sFFThkSBmkc0TzSKsCfheRnQpyu;Database=BrizcoDB",
"MartenDBServer": "Host=185.228.236.40;port=5432;Username=postgres;Password=ub0J7sFFThkSBmkc0TzSKsCfheRnQpyu;Database=BrizcoMartenDB",
"Postgres": "Host=pg-0;Username=postgres;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=BrizcoDB;Application Name=BrizCo", "Postgres": "Host=pg-0;Username=postgres;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=BrizcoDB;Application Name=BrizCo",
"MartenDB": "Host=pg-0;Username=postgres;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=BrizcoMartenDB;" "MartenDB": "Host=pg-0;Username=postgres;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=BrizcoMartenDB;"
}, },

View File

@ -6,8 +6,8 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath> <DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
<AssemblyVersion>1.4.9.4</AssemblyVersion> <AssemblyVersion>1.0.1.2</AssemblyVersion>
<FileVersion>1.4.9.4</FileVersion> <FileVersion>1.0.1.2</FileVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,6 @@
namespace Brizco.Api.Controllers; using Brizco.Domain.Enums;
namespace Brizco.Api.Controllers;
public class ActivityController : ICarterModule public class ActivityController : ICarterModule
{ {
@ -10,7 +12,7 @@ public class ActivityController : ICarterModule
group.MapGet("", GetAllAsync) group.MapGet("", GetAllAsync)
.WithDisplayName("GetActivities") .WithDisplayName("GetActivities")
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewActivities, ApplicationPermission.ManageActivities)) .RequireAuthorization(builder=>builder.RequireClaim(CustomClaimType.Permission,ApplicationPermission.ViewActivities, ApplicationPermission.ManageActivities))
.HasApiVersion(1.0); .HasApiVersion(1.0);
group.MapGet("{id:guid}", GetAsync) group.MapGet("{id:guid}", GetAsync)
@ -24,7 +26,7 @@ public class ActivityController : ICarterModule
.HasApiVersion(1.0); .HasApiVersion(1.0);
group.MapPost("complete", CompleteActivityAsync) group.MapPost("complete", CompleteActivityAsync)
.WithDisplayName("CompleteActivity") .WithDisplayName("DoneActivity")
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ChangeActivityStatus)) .RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ChangeActivityStatus))
.HasApiVersion(1.0); .HasApiVersion(1.0);
@ -32,35 +34,36 @@ public class ActivityController : ICarterModule
.WithDisplayName("UnDoneActivity") .WithDisplayName("UnDoneActivity")
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ChangeActivityStatus)) .RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ChangeActivityStatus))
.HasApiVersion(1.0); .HasApiVersion(1.0);
//group.MapPost("", Post)
// .AllowAnonymous()
// .HasApiVersion(1.0);
//group.MapPut("", Put)
// .HasApiVersion(1.0);
//group.MapDelete("{id:guid}", Delete)
// .HasApiVersion(1.0);
} }
// GET:Get All Entity // GET:Get All Entity
public async Task<IResult> GetAllAsync([FromQuery] int page, public async Task<IResult> GetAllAsync([FromQuery] int page, [FromQuery] DateQueryFilter? dateQueryFilter, [FromQuery] long? selectedDate, [FromQuery] Guid? selectedShiftPlanId, ISender sender, CancellationToken cancellationToken)
[FromQuery] DateTimeQueryFilter? dateQueryFilter, => TypedResults.Ok(await sender.Send(new GetActivitiesQuery(Page: page, SelectedDate: selectedDate ?? 0 , SelectedShiftPlanId: selectedShiftPlanId ?? default , DateQueryFilter: dateQueryFilter ?? null), cancellationToken));
[FromQuery] long? selectedDate,
[FromQuery] Guid? selectedShiftPlanId,
[FromQuery] Guid? userId,
ISender sender,
CancellationToken cancellationToken)
=> TypedResults.Ok(await sender.Send(new GetActivitiesQuery(UserId: userId,
Page: page,
SelectedDate: selectedDate ?? 0,
SelectedShiftPlanId: selectedShiftPlanId,
DateQueryFilter: dateQueryFilter), cancellationToken));
// GET:Get An Entity By Id // GET:Get An Entity By Id
public async Task<IResult> GetAsync(Guid id, IActivityService activityService, CancellationToken cancellationToken) public async Task<IResult> GetAsync(Guid id, IActivityService activityService, CancellationToken cancellationToken)
=> TypedResults.Ok(await activityService.DoneActivityAsync(id, cancellationToken)); => TypedResults.Ok(await activityService.DoneActivityAsync(id,cancellationToken));
public async Task<IResult> CompleteActivityAsync([FromBody] List<CompleteActivityRequestDto> requestDtos, [FromServices] IActivityService activityService, CancellationToken cancellationToken) public async Task<IResult> CompleteActivityAsync([FromBody]List<CompleteActivityRequestDto> requestDtos, [FromServices] IActivityService activityService, CancellationToken cancellationToken)
=> TypedResults.Ok(await activityService.CompleteActivitiesAsync(requestDtos, cancellationToken)); => TypedResults.Ok(await activityService.CompleteActivitiesAsync(requestDtos, cancellationToken));
public async Task<IResult> DoneActivityAsync(Guid id, [FromServices] IActivityService activityService, CancellationToken cancellationToken) public async Task<IResult> DoneActivityAsync(Guid id, [FromServices] IActivityService activityService, CancellationToken cancellationToken)
=> TypedResults.Ok(await activityService.DoneActivityAsync(id, cancellationToken)); => TypedResults.Ok(await activityService.DoneActivityAsync(id, cancellationToken));
public async Task<IResult> UnDoneActivityAsync(Guid id, [FromQuery] string undoneReason, [FromServices] IActivityService activityService, CancellationToken cancellationToken) public async Task<IResult> UnDoneActivityAsync(Guid id,[FromQuery]string undoneReason, [FromServices]IActivityService activityService, CancellationToken cancellationToken)
=> TypedResults.Ok(await activityService.UnDoneActivityAsync(id, undoneReason, cancellationToken)); => TypedResults.Ok(await activityService.UnDoneActivityAsync(id,undoneReason, cancellationToken));
//// POST:Create Entity //// POST:Create Entity
//public async Task<IResult> Post([FromQuery]Guid shiftPlanId,IActivityService activityService, CancellationToken cancellationToken) //public async Task<IResult> Post([FromQuery]Guid shiftPlanId,IActivityService activityService, CancellationToken cancellationToken)

View File

@ -1,38 +0,0 @@
namespace Brizco.Api.Controllers;
public class NewsFeedController : ICarterModule
{
public void AddRoutes(IEndpointRouteBuilder app)
{
var group = app.NewVersionedApi("News")
.MapGroup("api/news");
group.MapGet("", GetEntitiesAsync)
.WithDisplayName("Get News Feed")
.HasApiVersion(1.0);
group.MapPost("", PostEntitiesAsync)
.WithDisplayName("Create News Feed")
.HasApiVersion(1.0);
group.MapPut("{id}/pin", ChangePinAsync)
.WithDisplayName("Change NewsFeed Pin")
.HasApiVersion(1.0);
group.MapDelete("{id}", DeleteEntitiesAsync)
.WithDisplayName("Delete News Feed")
.HasApiVersion(1.0);
}
private async Task GetEntitiesAsync([FromQuery] int page, [FromQuery] int? count, [FromServices] IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new GetNewsFeedsQuery(page, count), cancellationToken));
private async Task PostEntitiesAsync([FromBody]CreateNewsFeedCommand request, [FromServices] IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(request, cancellationToken));
private async Task ChangePinAsync([FromRoute] Guid id, [FromQuery]bool isPin, [FromServices] IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new ChangeNewsFeedPinCommand(id,isPin), cancellationToken));
private async Task DeleteEntitiesAsync([FromRoute] Guid id, [FromServices] IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new DeleteNewsFeedCommand(id), cancellationToken));
}

View File

@ -13,12 +13,6 @@ public class NotificationController : ICarterModule
.RequireAuthorization(builder=>builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) .RequireAuthorization(builder=>builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser())
.HasApiVersion(1.0); .HasApiVersion(1.0);
group.MapGet("/unread/count", GetUserNotificationsCountAsync)
.WithDisplayName("Get Unread Notifications Count")
.WithDescription("Get user notifications , by JWT user id")
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser())
.HasApiVersion(1.0);
group.MapPost("{id}/read",ReadNotificationAsync) group.MapPost("{id}/read",ReadNotificationAsync)
.WithDisplayName("Read Notification") .WithDisplayName("Read Notification")
.WithDescription("Read notification , by JWT user id") .WithDescription("Read notification , by JWT user id")
@ -30,10 +24,7 @@ public class NotificationController : ICarterModule
private async Task<IResult> ReadNotificationAsync([FromRoute] Guid id, [FromServices] IMediator mediator, CancellationToken cancellationToken) private async Task<IResult> ReadNotificationAsync([FromRoute] Guid id, [FromServices] IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new ReadNotificationCommand(id), cancellationToken)); => TypedResults.Ok(await mediator.Send(new ReadNotificationCommand(id), cancellationToken));
private async Task<IResult> GetUserNotificationsAsync([FromQuery] int page, [FromQuery] int? count, private async Task<IResult> GetUserNotificationsAsync([FromQuery] int page, [FromQuery] int count,
[FromServices] IMediator mediator, CancellationToken cancellationToken) [FromServices] IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new GetNotificationsQuery(page, count), cancellationToken)); => TypedResults.Ok(await mediator.Send(new GetNotificationsQuery(page, count), cancellationToken));
private async Task<IResult> GetUserNotificationsCountAsync([FromServices] IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new GetNotificationsCountQuery(), cancellationToken));
} }

View File

@ -1,4 +1,6 @@
namespace Brizco.Api.Controllers; using Brizco.Domain.Enums;
namespace Brizco.Api.Controllers;
public class ShiftPlanController : ICarterModule public class ShiftPlanController : ICarterModule
{ {
@ -30,7 +32,6 @@ public class ShiftPlanController : ICarterModule
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageShiftPlans)) .RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageShiftPlans))
.HasApiVersion(1.0); .HasApiVersion(1.0);
group.MapPost("", Post) group.MapPost("", Post)
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageShiftPlans)) .RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageShiftPlans))
.HasApiVersion(1.0); .HasApiVersion(1.0);
@ -53,10 +54,7 @@ public class ShiftPlanController : ICarterModule
// GET:Get All Entity // GET:Get All Entity
public async Task<IResult> GetAllAsync([FromQuery] int page, public async Task<IResult> GetAllAsync([FromQuery] int page, [FromQuery] long? selectedDate, [FromQuery] DateTimeQueryFilter? dateFilter , ISender sender, CancellationToken cancellationToken)
[FromQuery] long? selectedDate,
[FromQuery] DateTimeQueryFilter? dateFilter ,
[FromServices]ISender sender, CancellationToken cancellationToken)
=> TypedResults.Ok(await sender.Send(new GetShiftPlansQuery(page , selectedDate ?? 0 , DateTimeQueryFilter: dateFilter), cancellationToken)); => TypedResults.Ok(await sender.Send(new GetShiftPlansQuery(page , selectedDate ?? 0 , DateTimeQueryFilter: dateFilter), cancellationToken));
// GET:Get An Entity By Id // GET:Get An Entity By Id

View File

@ -2,6 +2,9 @@
public class TaskController : ICarterModule public class TaskController : ICarterModule
{ {
public TaskController()
{
}
public virtual void AddRoutes(IEndpointRouteBuilder app) public virtual void AddRoutes(IEndpointRouteBuilder app)
{ {
var group = app.NewVersionedApi("Task") var group = app.NewVersionedApi("Task")
@ -10,12 +13,12 @@ public class TaskController : ICarterModule
group.MapGet("", GetAllAsync) group.MapGet("", GetAllAsync)
.WithDisplayName("GetAllTask") .WithDisplayName("GetAllTask")
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageTasks, ApplicationPermission.ViewTasks)) .RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageTasks,ApplicationPermission.ViewTasks))
.HasApiVersion(1.0); .HasApiVersion(1.0);
group.MapGet("{id}", GetAsync) group.MapGet("{id}", GetAsync)
.WithDisplayName("GetOneTask") .WithDisplayName("GetOneTask")
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageTasks, ApplicationPermission.ViewTasks)) .RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageTasks,ApplicationPermission.ViewTasks))
.HasApiVersion(1.0); .HasApiVersion(1.0);
group.MapPost("", Post) group.MapPost("", Post)
@ -32,15 +35,12 @@ public class TaskController : ICarterModule
} }
// GET:Get All Entity // GET:Get All Entity
public async Task<IResult> GetAllAsync([FromQuery] int page, public async Task<IResult> GetAllAsync([FromQuery] int page,ISender sender, CancellationToken cancellationToken)
[FromQuery] int? count, => TypedResults.Ok(await sender.Send(new GetTasksQuery(page), cancellationToken));
[FromQuery] Guid? shiftId,
ISender sender, CancellationToken cancellationToken)
=> TypedResults.Ok(await sender.Send(new GetTasksQuery(page, ShiftId: shiftId, Count: count), cancellationToken));
// GET:Get An Entity By Id // GET:Get An Entity By Id
public async Task<IResult> GetAsync(Guid id, ISender sender, CancellationToken cancellationToken) public async Task<IResult> GetAsync(Guid id, ISender sender, CancellationToken cancellationToken)
=> TypedResults.Ok(await sender.Send(new GetTaskQuery(id), cancellationToken)); => TypedResults.Ok(await sender.Send(new GetTaskQuery(id),cancellationToken));
// POST:Create Entity // POST:Create Entity
public async Task<IResult> Post([FromBody] CreateTaskCommand ent, ISender mediator, CancellationToken cancellationToken) public async Task<IResult> Post([FromBody] CreateTaskCommand ent, ISender mediator, CancellationToken cancellationToken)

View File

@ -16,11 +16,6 @@ public class UserController : ICarterModule
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewUsers,ApplicationPermission.ManageUsers)) .RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewUsers,ApplicationPermission.ManageUsers))
.HasApiVersion(1.0); .HasApiVersion(1.0);
group.MapGet("/staff", GetAllStaffAsync)
.WithDisplayName("GetAllStaff")
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewUsers, ApplicationPermission.ManageUsers))
.HasApiVersion(1.0);
group.MapGet("{id}", GetAsync) group.MapGet("{id}", GetAsync)
.WithDisplayName("GetOneUser") .WithDisplayName("GetOneUser")
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewUsers, ApplicationPermission.ManageUsers)) .RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewUsers, ApplicationPermission.ManageUsers))
@ -47,12 +42,6 @@ public class UserController : ICarterModule
.HasApiVersion(1.0); .HasApiVersion(1.0);
} }
private async Task<IResult> GetAllStaffAsync([FromQuery] DateTimeQueryFilter filter,
[FromQuery] int page,
[FromQuery] int? count,
IMediator mediator,
CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new GetStaffQuery(page, filter, count), cancellationToken));
public async Task<IResult> ChangeUserRoleAsync(Guid roleId,IUserService userService, CancellationToken cancellationToken) public async Task<IResult> ChangeUserRoleAsync(Guid roleId,IUserService userService, CancellationToken cancellationToken)
=> TypedResults.Ok(await userService.ChangeUserRoleAsync(roleId,cancellationToken)); => TypedResults.Ok(await userService.ChangeUserRoleAsync(roleId,cancellationToken));

View File

@ -83,7 +83,6 @@ builder.Host.ConfigureContainer<ContainerBuilder>(builder =>
.Create(typeof(CoreConfig).Assembly) .Create(typeof(CoreConfig).Assembly)
.WithAllOpenGenericHandlerTypesRegistered() .WithAllOpenGenericHandlerTypesRegistered()
.Build()); .Build());
builder.AddSchedulerToAutoFac();
}); });
var app = builder.Build(); var app = builder.Build();

View File

@ -23,8 +23,7 @@
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/scalar/v1", "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/scalar/v1",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_URLS": "http://+:80", "ASPNETCORE_URLS": "http://+:80"
"TZ": "Asia/Tehran"
}, },
"publishAllPorts": true, "publishAllPorts": true,
"DockerfileRunArguments": " --network=mother -p 32767:80" "DockerfileRunArguments": " --network=mother -p 32767:80"

View File

@ -0,0 +1 @@
7bec0081-0f19-4cf7-84a9-7deed79e4f61

View File

@ -10,6 +10,11 @@ public static class LoggerConfig
Log.Logger = new LoggerConfiguration() Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext() .Enrich.FromLogContext()
.WriteTo.Console(theme: AnsiConsoleTheme.Literate) .WriteTo.Console(theme: AnsiConsoleTheme.Literate)
.WriteTo.Sentry(o =>
{
o.MinimumEventLevel = LogEventLevel.Error;
o.Dsn = "https://592b7fbb29464442a8e996247abe857f@watcher.igarson.app/7";
})
.MinimumLevel.Override("Microsoft.EntityFrameworkCore.Database.Command", LogEventLevel.Warning) .MinimumLevel.Override("Microsoft.EntityFrameworkCore.Database.Command", LogEventLevel.Warning)
.CreateLogger(); .CreateLogger();
} }

View File

@ -1,10 +1,8 @@
using System.Collections.Specialized; using System.IO.Compression;
using System.IO.Compression;
using Asp.Versioning; using Asp.Versioning;
using AspNetCoreRateLimit; using AspNetCoreRateLimit;
using AspNetCoreRateLimit.Redis; using AspNetCoreRateLimit.Redis;
using Autofac.Extras.Quartz; using Brizco.Domain.Entities.Users;
using Brizco.Core.QuartzServices;
using Marten; using Marten;
using Microsoft.AspNetCore.ResponseCompression; using Microsoft.AspNetCore.ResponseCompression;
using StackExchange.Redis.Extensions.Core.Configuration; using StackExchange.Redis.Extensions.Core.Configuration;
@ -16,22 +14,6 @@ namespace Brizco.Api.WebFramework.Configurations;
public static class ServiceExtensions public static class ServiceExtensions
{ {
public static void AddSchedulerToAutoFac(this ContainerBuilder builder)
{
// configure and register Quartz
var schedulerConfig = new NameValueCollection {
{"quartz.threadPool.threadCount", "3"},
{"quartz.scheduler.threadName", "MyScheduler"},
};
builder.RegisterModule(new QuartzAutofacFactoryModule
{
ConfigurationProvider = c => schedulerConfig
});
builder.RegisterModule(new QuartzAutofacJobsModule(typeof(JobScheduler).Assembly));
builder.RegisterType<JobScheduler>().AsSelf();
}
public static void AddIpRateLimit(this IServiceCollection services, IConfigurationRoot configuration) public static void AddIpRateLimit(this IServiceCollection services, IConfigurationRoot configuration)
{ {

View File

@ -37,8 +37,6 @@ namespace Brizco.Common.Extensions
public static long DateTimeToUnixTimeStamp(DateTime dateTime) public static long DateTimeToUnixTimeStamp(DateTime dateTime)
{ {
if (dateTime == DateTime.MinValue)
return 0;
return ((DateTimeOffset)dateTime).ToUnixTimeMilliseconds(); return ((DateTimeOffset)dateTime).ToUnixTimeMilliseconds();
} }

View File

@ -63,11 +63,9 @@
<Using Include="Microsoft.AspNetCore.Identity" /> <Using Include="Microsoft.AspNetCore.Identity" />
<Using Include="Microsoft.EntityFrameworkCore" /> <Using Include="Microsoft.EntityFrameworkCore" />
<Using Include="Microsoft.IdentityModel.Tokens" /> <Using Include="Microsoft.IdentityModel.Tokens" />
<Using Include="Newtonsoft.Json" />
<Using Include="NPOI.SS.UserModel" /> <Using Include="NPOI.SS.UserModel" />
<Using Include="NPOI.SS.Util" /> <Using Include="NPOI.SS.Util" />
<Using Include="NPOI.XSSF.UserModel" /> <Using Include="NPOI.XSSF.UserModel" />
<Using Include="System.Reflection" />
<Using Include="System.Security.Claims" /> <Using Include="System.Security.Claims" />
<Using Include="System.Text.Json" /> <Using Include="System.Text.Json" />
</ItemGroup> </ItemGroup>

View File

@ -3,21 +3,29 @@ using Task = Brizco.Domain.Entities.Tasks.Task;
namespace Brizco.Core.EntityServices; namespace Brizco.Core.EntityServices;
public class ActivityService(IMediator mediator, IRepositoryWrapper repositoryWrapper) : IActivityService public class ActivityService : IActivityService
{ {
private readonly IMediator _mediator;
private readonly IRepositoryWrapper _repositoryWrapper;
public ActivityService(IMediator mediator, IRepositoryWrapper repositoryWrapper)
{
_mediator = mediator;
_repositoryWrapper = repositoryWrapper;
}
public async Task<bool> DoneActivityAsync(Guid activityId, CancellationToken cancellationToken) public async Task<bool> DoneActivityAsync(Guid activityId, CancellationToken cancellationToken)
{ {
var activity = await repositoryWrapper.SetRepository<Activity>() var activity = await _repositoryWrapper.SetRepository<Activity>()
.TableNoTracking .TableNoTracking
.FirstOrDefaultAsync(a => a.Id == activityId, cancellationToken); .FirstOrDefaultAsync(a => a.Id == activityId, cancellationToken);
if (activity == null) if (activity == null)
throw new AppException("Activity not found", ApiResultStatusCode.NotFound); throw new AppException("Activity not found", ApiResultStatusCode.NotFound);
activity.DoneActivity(); activity.DoneActivity();
repositoryWrapper.SetRepository<Activity>() _repositoryWrapper.SetRepository<Activity>()
.Update(activity); .Update(activity);
await repositoryWrapper.SaveChangesAsync(cancellationToken); await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return true; return true;
} }
@ -25,14 +33,14 @@ public class ActivityService(IMediator mediator, IRepositoryWrapper repositoryWr
{ {
foreach (var activityRequestDto in requestDtos) foreach (var activityRequestDto in requestDtos)
{ {
var activity = await repositoryWrapper.SetRepository<Activity>().TableNoTracking var activity = await _repositoryWrapper.SetRepository<Activity>().TableNoTracking
.FirstOrDefaultAsync(a => a.Id == activityRequestDto.ActivityId, cancellationToken); .FirstOrDefaultAsync(a => a.Id == activityRequestDto.ActivityId, cancellationToken);
if (activity == null) if (activity == null)
continue; continue;
activity.CompleteActivity(activityRequestDto.IsCompleted, activityRequestDto.PerformanceDescription); activity.CompleteActivity(activityRequestDto.IsCompleted, activityRequestDto.PerformanceDescription);
repositoryWrapper.SetRepository<Activity>().Update(activity); _repositoryWrapper.SetRepository<Activity>().Update(activity);
await repositoryWrapper.SaveChangesAsync(cancellationToken); await _repositoryWrapper.SaveChangesAsync(cancellationToken);
} }
return true; return true;
@ -41,44 +49,44 @@ public class ActivityService(IMediator mediator, IRepositoryWrapper repositoryWr
public async Task<bool> UnDoneActivityAsync(Guid activityId, string undoneReason, CancellationToken cancellationToken) public async Task<bool> UnDoneActivityAsync(Guid activityId, string undoneReason, CancellationToken cancellationToken)
{ {
var activity = await repositoryWrapper.SetRepository<Activity>() var activity = await _repositoryWrapper.SetRepository<Activity>()
.TableNoTracking .TableNoTracking
.FirstOrDefaultAsync(a => a.Id == activityId, cancellationToken); .FirstOrDefaultAsync(a => a.Id == activityId, cancellationToken);
if (activity == null) if (activity == null)
throw new AppException("Activity not found ", ApiResultStatusCode.NotFound); throw new AppException("Activity not found ", ApiResultStatusCode.NotFound);
activity.UnDoneActivity(undoneReason); activity.UnDoneActivity(undoneReason);
repositoryWrapper.SetRepository<Activity>() _repositoryWrapper.SetRepository<Activity>()
.Update(activity); .Update(activity);
await repositoryWrapper.SaveChangesAsync(cancellationToken); await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return true; return true;
} }
public async Task<bool> UpdateActivitiesByShiftPlan(Guid shiftPlanId, CancellationToken cancellationToken) public async Task<bool> UpdateActivitiesByShiftPlan(Guid shiftPlanId, CancellationToken cancellationToken)
{ {
var shiftPlan = await mediator.Send(new GetShiftPlanQuery(shiftPlanId), cancellationToken); var shiftPlan = await _mediator.Send(new GetShiftPlanQuery(shiftPlanId), cancellationToken);
if (shiftPlan.Id == Guid.Empty) if (shiftPlan.Id == Guid.Empty)
return false; return false;
var dailyTasks = await (from task in repositoryWrapper.SetRepository<Task>().Entities var dailyTasks = await (from task in _repositoryWrapper.SetRepository<Task>().Entities
join taskShift in repositoryWrapper.SetRepository<TaskShift>().Entities on task.Id equals taskShift.TaskId join taskShift in _repositoryWrapper.SetRepository<TaskShift>().Entities on task.Id equals taskShift.TaskId
join taskRoutine in repositoryWrapper.SetRepository<TaskRoutine>().Entities on task.Id equals taskRoutine join taskRoutine in _repositoryWrapper.SetRepository<TaskRoutine>().Entities on task.Id equals taskRoutine
.TaskId .TaskId
where taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId && task.ScheduleType == TaskScheduleType.Daily where taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId && task.ScheduleType == TaskScheduleType.Daily
select task).AsNoTracking().ToListAsync(cancellationToken); select task).AsNoTracking().ToListAsync(cancellationToken);
var weeklyTasks = await (from task in repositoryWrapper.SetRepository<Task>().Entities var weeklyTasks = await (from task in _repositoryWrapper.SetRepository<Task>().Entities
join taskShift in repositoryWrapper.SetRepository<TaskShift>().Entities on task.Id equals taskShift.TaskId join taskShift in _repositoryWrapper.SetRepository<TaskShift>().Entities on task.Id equals taskShift.TaskId
join taskDay in repositoryWrapper.SetRepository<TaskDay>().Entities on task.Id equals taskDay.TaskId join taskDay in _repositoryWrapper.SetRepository<TaskDay>().Entities on task.Id equals taskDay.TaskId
join taskRoutine in repositoryWrapper.SetRepository<TaskRoutine>().Entities on task.Id equals taskRoutine join taskRoutine in _repositoryWrapper.SetRepository<TaskRoutine>().Entities on task.Id equals taskRoutine
.TaskId .TaskId
where taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId && where taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId &&
taskDay.DayOfWeek == shiftPlan.PlanFor.DayOfWeek && task.ScheduleType == TaskScheduleType.Weekly taskDay.DayOfWeek == shiftPlan.PlanFor.DayOfWeek && task.ScheduleType == TaskScheduleType.Weekly
group task by task.Id into groupedTask group task by task.Id into groupedTask
select groupedTask.FirstOrDefault()).AsNoTracking().ToListAsync(cancellationToken); select groupedTask.FirstOrDefault()).AsNoTracking().ToListAsync(cancellationToken);
var customTasks = await (from task in repositoryWrapper.SetRepository<Task>().Entities var customTasks = await (from task in _repositoryWrapper.SetRepository<Task>().Entities
join taskShift in repositoryWrapper.SetRepository<TaskShift>().Entities on task.Id equals taskShift.TaskId join taskShift in _repositoryWrapper.SetRepository<TaskShift>().Entities on task.Id equals taskShift.TaskId
join taskRoutine in repositoryWrapper.SetRepository<TaskRoutine>().Entities on task.Id equals taskRoutine join taskRoutine in _repositoryWrapper.SetRepository<TaskRoutine>().Entities on task.Id equals taskRoutine
.TaskId .TaskId
where taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId && where taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId &&
task.ScheduleType == TaskScheduleType.Custom && task.SetFor.Date == shiftPlan.PlanFor.Date task.ScheduleType == TaskScheduleType.Custom && task.SetFor.Date == shiftPlan.PlanFor.Date
@ -90,13 +98,13 @@ public class ActivityService(IMediator mediator, IRepositoryWrapper repositoryWr
tasks.AddRange(dailyTasks); tasks.AddRange(dailyTasks);
tasks.AddRange(customTasks); tasks.AddRange(customTasks);
var shiftPlanPositions = await repositoryWrapper.SetRepository<ShiftPlanUser>() var shiftPlanPositions = await _repositoryWrapper.SetRepository<ShiftPlanUser>()
.TableNoTracking .TableNoTracking
.Where(spu => spu.ShiftPlanId == shiftPlan.Id) .Where(spu => spu.ShiftPlanId == shiftPlan.Id)
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);
var activities = await repositoryWrapper.SetRepository<Activity>() var activities = await _repositoryWrapper.SetRepository<Activity>()
.TableNoTracking .TableNoTracking
.Where(a => a.ShiftPlanId == shiftPlan.ShiftId && a.SetFor.Date == shiftPlan.PlanFor.Date) .Where(a => a.ShiftPlanId == shiftPlan.ShiftId && a.SetFor.Date == shiftPlan.PlanFor.Date)
.Select(ActivityMapper.ProjectToLDto) .Select(ActivityMapper.ProjectToLDto)
@ -107,7 +115,7 @@ public class ActivityService(IMediator mediator, IRepositoryWrapper repositoryWr
if (foundedTask == null) if (foundedTask == null)
continue; continue;
var taskPositions = await repositoryWrapper.SetRepository<TaskPosition>() var taskPositions = await _repositoryWrapper.SetRepository<TaskPosition>()
.TableNoTracking .TableNoTracking
.Where(tp => tp.TaskId == foundedTask.Id) .Where(tp => tp.TaskId == foundedTask.Id)
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);
@ -120,7 +128,7 @@ public class ActivityService(IMediator mediator, IRepositoryWrapper repositoryWr
if (activity.UserId != foundedUser.UserId) if (activity.UserId != foundedUser.UserId)
{ {
await mediator.Send(new UpdateActivityCommand(activity.Id, activity.Status, activity.DoneAt, activity.PerformanceDescription, await _mediator.Send(new UpdateActivityCommand(activity.Id, activity.Status, activity.DoneAt, activity.PerformanceDescription,
activity.Type, activity.Title, activity.Description, activity.IsDisposable, activity.SetFor, activity.HasDisposed, activity.Amount activity.Type, activity.Title, activity.Description, activity.IsDisposable, activity.SetFor, activity.HasDisposed, activity.Amount
, activity.AmountType, activity.ScheduleType, shiftPlan.Id, foundedUser.UserId), cancellationToken); , activity.AmountType, activity.ScheduleType, shiftPlan.Id, foundedUser.UserId), cancellationToken);
} }
@ -130,30 +138,30 @@ public class ActivityService(IMediator mediator, IRepositoryWrapper repositoryWr
} }
public async Task<bool> CreateActivitiesByShiftPlan(Guid shiftPlanId, CancellationToken cancellationToken) { public async Task<bool> CreateActivitiesByShiftPlan(Guid shiftPlanId, CancellationToken cancellationToken) {
var shiftPlan = await mediator.Send(new GetShiftPlanQuery(shiftPlanId), cancellationToken); var shiftPlan = await _mediator.Send(new GetShiftPlanQuery(shiftPlanId), cancellationToken);
if (shiftPlan.Id == Guid.Empty) if (shiftPlan.Id == Guid.Empty)
return false; return false;
var dailyTasks = await (from task in repositoryWrapper.SetRepository<Task>().Entities var dailyTasks = await (from task in _repositoryWrapper.SetRepository<Task>().Entities
join taskShift in repositoryWrapper.SetRepository<TaskShift>().Entities on task.Id equals taskShift.TaskId join taskShift in _repositoryWrapper.SetRepository<TaskShift>().Entities on task.Id equals taskShift.TaskId
join taskRoutine in repositoryWrapper.SetRepository<TaskRoutine>().Entities on task.Id equals taskRoutine join taskRoutine in _repositoryWrapper.SetRepository<TaskRoutine>().Entities on task.Id equals taskRoutine
.TaskId .TaskId
where task.IsActivity == false && taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId && task.ScheduleType == TaskScheduleType.Daily where task.IsActivity == false && taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId && task.ScheduleType == TaskScheduleType.Daily
select task).AsNoTracking().ToListAsync(cancellationToken); select task).AsNoTracking().ToListAsync(cancellationToken);
var weeklyTasks = await (from task in repositoryWrapper.SetRepository<Task>().Entities var weeklyTasks = await (from task in _repositoryWrapper.SetRepository<Task>().Entities
join taskShift in repositoryWrapper.SetRepository<TaskShift>().Entities on task.Id equals taskShift.TaskId join taskShift in _repositoryWrapper.SetRepository<TaskShift>().Entities on task.Id equals taskShift.TaskId
join taskDay in repositoryWrapper.SetRepository<TaskDay>().Entities on task.Id equals taskDay.TaskId join taskDay in _repositoryWrapper.SetRepository<TaskDay>().Entities on task.Id equals taskDay.TaskId
join taskRoutine in repositoryWrapper.SetRepository<TaskRoutine>().Entities on task.Id equals taskRoutine join taskRoutine in _repositoryWrapper.SetRepository<TaskRoutine>().Entities on task.Id equals taskRoutine
.TaskId .TaskId
where task.IsActivity == false && taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId && where task.IsActivity == false && taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId &&
taskDay.DayOfWeek == shiftPlan.PlanFor.DayOfWeek && task.ScheduleType == TaskScheduleType.Weekly taskDay.DayOfWeek == shiftPlan.PlanFor.DayOfWeek && task.ScheduleType == TaskScheduleType.Weekly
group task by task.Id into groupedTask group task by task.Id into groupedTask
select groupedTask.FirstOrDefault()).AsNoTracking().ToListAsync(cancellationToken); select groupedTask.FirstOrDefault()).AsNoTracking().ToListAsync(cancellationToken);
var customTasks = await (from task in repositoryWrapper.SetRepository<Task>().Entities var customTasks = await (from task in _repositoryWrapper.SetRepository<Task>().Entities
join taskShift in repositoryWrapper.SetRepository<TaskShift>().Entities on task.Id equals taskShift.TaskId join taskShift in _repositoryWrapper.SetRepository<TaskShift>().Entities on task.Id equals taskShift.TaskId
join taskRoutine in repositoryWrapper.SetRepository<TaskRoutine>().Entities on task.Id equals taskRoutine join taskRoutine in _repositoryWrapper.SetRepository<TaskRoutine>().Entities on task.Id equals taskRoutine
.TaskId .TaskId
where task.IsActivity == false && taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId && where task.IsActivity == false && taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId &&
task.ScheduleType == TaskScheduleType.Custom && task.SetFor.Date == shiftPlan.PlanFor.Date task.ScheduleType == TaskScheduleType.Custom && task.SetFor.Date == shiftPlan.PlanFor.Date
@ -165,14 +173,14 @@ public class ActivityService(IMediator mediator, IRepositoryWrapper repositoryWr
tasks.AddRange(customTasks); tasks.AddRange(customTasks);
var shiftPlanPositions = await repositoryWrapper.SetRepository<ShiftPlanUser>() var shiftPlanPositions = await _repositoryWrapper.SetRepository<ShiftPlanUser>()
.TableNoTracking .TableNoTracking
.Where(spu => spu.ShiftPlanId == shiftPlan.Id) .Where(spu => spu.ShiftPlanId == shiftPlan.Id)
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);
foreach (var task in tasks) foreach (var task in tasks)
{ {
var taskPositions = await repositoryWrapper.SetRepository<TaskPosition>() var taskPositions = await _repositoryWrapper.SetRepository<TaskPosition>()
.TableNoTracking .TableNoTracking
.Where(tp => tp.TaskId == task.Id) .Where(tp => tp.TaskId == task.Id)
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);
@ -182,7 +190,7 @@ public class ActivityService(IMediator mediator, IRepositoryWrapper repositoryWr
var fundedUser = shiftPlanPositions.FirstOrDefault(spu => spu.PositionId == taskPosition.PositionId); var fundedUser = shiftPlanPositions.FirstOrDefault(spu => spu.PositionId == taskPosition.PositionId);
if (fundedUser != null) if (fundedUser != null)
{ {
await mediator.Send(new CreateActivityCommand(task.Type, task.Title, task.Description, task.IsDisposable, await _mediator.Send(new CreateActivityCommand(task.Type, task.Title, task.Description, task.IsDisposable,
shiftPlan.PlanFor, task.HasDisposed, task.Amount, task.AmountType, shiftPlan.PlanFor, task.HasDisposed, task.Amount, task.AmountType,
task.ScheduleType, shiftPlan.Id, fundedUser.UserId), cancellationToken); task.ScheduleType, shiftPlan.Id, fundedUser.UserId), cancellationToken);
} }

View File

@ -34,17 +34,6 @@ public class ShiftPlanService(IMediator mediator, IActivityService activityServi
repositoryWrapper.SetRepository<ShiftPlan>().Update(shiftPlan); repositoryWrapper.SetRepository<ShiftPlan>().Update(shiftPlan);
await repositoryWrapper.SaveChangesAsync(cancellationToken); await repositoryWrapper.SaveChangesAsync(cancellationToken);
await activityService.CompleteActivitiesAsync(requestDtos.CompleteActivities, cancellationToken); await activityService.CompleteActivitiesAsync(requestDtos.CompleteActivities, cancellationToken);
var shiftPlanUsers = await repositoryWrapper.SetRepository<ShiftPlanUser>()
.TableNoTracking.Where(s => s.ShiftPlanId == id)
.Select(ShiftPlanUserMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
foreach (var shiftPlanUser in shiftPlanUsers)
{
var message = $"{shiftPlanUser.UserFullName}";
}
return true; return true;
} }
} }

View File

@ -1,4 +1,7 @@
namespace Brizco.Core.MartenServices; using Newtonsoft.Json;
using System.Reflection;
namespace Brizco.Core.MartenServices;
public class BrewService : IBrewService public class BrewService : IBrewService
{ {

View File

@ -1,7 +1,9 @@
namespace Brizco.Core.QuartzServices.Handlers; using Brizco.Domain.Entities.ShiftPlans;
public class CreateShiftPlanNotificationsCommandHandler(IMediator mediator, IRepositoryWrapper repositoryWrapper) namespace Brizco.Core.QuartzServices.Handlers;
: IRequestHandler<CreateShiftPlanNotificationsCommand, bool>
public class CreateShiftPlanNotificationsCommandHandler(IMediator mediator,IRepositoryWrapper repositoryWrapper)
: IRequestHandler<CreateShiftPlanNotificationsCommand,bool>
{ {
public async Task<bool> Handle(CreateShiftPlanNotificationsCommand request, CancellationToken cancellationToken) public async Task<bool> Handle(CreateShiftPlanNotificationsCommand request, CancellationToken cancellationToken)
{ {
@ -26,8 +28,8 @@ public class CreateShiftPlanNotificationsCommandHandler(IMediator mediator, IRep
foreach (var shiftPlanUser in shiftPlanUsers) foreach (var shiftPlanUser in shiftPlanUsers)
{ {
var completeShiftMessageForUser = $"شیفت‌های هفته بعد بسته شد، دیگه کار، کار، کار."; var completeShiftMessageForUser = $"";
await mediator.Send(new CreateNotificationCommand(completeShiftMessageForUser, shiftPlanUser.UserId, shiftPlan.ComplexId), cancellationToken); await mediator.Send( new CreateNotificationCommand(completeShiftMessageForUser, shiftPlanUser.UserId, shiftPlan.ComplexId), cancellationToken);
} }
} }

View File

@ -1,11 +1,9 @@
using Brizco.Core.QuartzServices.Commands; using Brizco.Core.QuartzServices.Commands;
using Microsoft.Extensions.Logging;
using Quartz; using Quartz;
namespace Brizco.Core.QuartzServices.Handlers; namespace Brizco.Core.QuartzServices.Handlers;
public class SetShiftPlanNotificationScheduleCommandHandler(IRepositoryWrapper repositoryWrapper,IScheduler scheduler,IMediator mediator,ILogger<SetShiftPlanNotificationScheduleCommand> logger) public class SetShiftPlanNotificationScheduleCommandHandler(IRepositoryWrapper repositoryWrapper,IScheduler scheduler) : IRequestHandler<SetShiftPlanNotificationScheduleCommand,bool>
: IRequestHandler<SetShiftPlanNotificationScheduleCommand,bool>
{ {
public async Task<bool> Handle(SetShiftPlanNotificationScheduleCommand request, CancellationToken cancellationToken) public async Task<bool> Handle(SetShiftPlanNotificationScheduleCommand request, CancellationToken cancellationToken)
{ {
@ -22,22 +20,9 @@ public class SetShiftPlanNotificationScheduleCommandHandler(IRepositoryWrapper r
if(shift == null) if(shift == null)
throw new BaseApiException(ApiResultStatusCode.NotFound, "Shift not found in set schedule"); throw new BaseApiException(ApiResultStatusCode.NotFound, "Shift not found in set schedule");
var shiftPlanUsers = await repositoryWrapper.SetRepository<ShiftPlanUser>() var shiftPlanStartAt = (new DateTime(shiftPlan.PlanFor.Year, shiftPlan.PlanFor.Month, shiftPlan.PlanFor.Day, shift.StartAt.Hours,shift.StartAt.Minutes,shift.StartAt.Seconds)).ToUniversalTime();
.TableNoTracking
.Where(f => f.ShiftPlanId == request.ShiftPlanId)
.ToListAsync(cancellationToken);
foreach (var shiftPlanUser in shiftPlanUsers)
{
var completeShiftMessageForUser = $"شیفت‌های هفته بعد بسته شد، دیگه کار، کار، کار.";
await mediator.Send(new CreateNotificationCommand(completeShiftMessageForUser, shiftPlanUser.UserId, shiftPlan.ComplexId), cancellationToken);
}
var shiftPlanStartAt = (new DateTime(shiftPlan.PlanFor.Year, shiftPlan.PlanFor.Month, shiftPlan.PlanFor.Day, shift.StartAt.Hours, shift.StartAt.Minutes, shift.StartAt.Seconds)).ToUniversalTime();
var shiftPlanEndAt = (new DateTime(shiftPlan.PlanFor.Year, shiftPlan.PlanFor.Month, shiftPlan.PlanFor.Day, shift.EndAt.Hours, shift.EndAt.Minutes, shift.EndAt.Seconds)).ToUniversalTime(); var shiftPlanEndAt = (new DateTime(shiftPlan.PlanFor.Year, shiftPlan.PlanFor.Month, shiftPlan.PlanFor.Day, shift.EndAt.Hours, shift.EndAt.Minutes, shift.EndAt.Seconds)).ToUniversalTime();
var currentDate = DateTime.UtcNow;
var startTimeOffset = new DateTimeOffset(shiftPlanStartAt.Year, shiftPlanStartAt.Month, shiftPlanStartAt.Day, shiftPlanStartAt.Hour, var startTimeOffset = new DateTimeOffset(shiftPlanStartAt.Year, shiftPlanStartAt.Month, shiftPlanStartAt.Day, shiftPlanStartAt.Hour,
shiftPlanStartAt.Minute, shiftPlanStartAt.Second, TimeSpan.Zero); shiftPlanStartAt.Minute, shiftPlanStartAt.Second, TimeSpan.Zero);
var endTimeOffset = new DateTimeOffset(shiftPlanEndAt.Year, shiftPlanEndAt.Month, shiftPlanEndAt.Day, shiftPlanEndAt.Hour, var endTimeOffset = new DateTimeOffset(shiftPlanEndAt.Year, shiftPlanEndAt.Month, shiftPlanEndAt.Day, shiftPlanEndAt.Hour,
@ -51,9 +36,10 @@ public class SetShiftPlanNotificationScheduleCommandHandler(IRepositoryWrapper r
ITrigger beforeEndShift30MinTrigger = TriggerBuilder.Create() ITrigger beforeEndShift30MinTrigger = TriggerBuilder.Create()
.WithIdentity(StringExtensions.GetId(9), shift.ComplexId.ToString()) .WithIdentity(StringExtensions.GetId(9), shift.ComplexId.ToString())
.WithSimpleSchedule(x => x.WithRepeatCount(0)) .WithSimpleSchedule(x => x.WithRepeatCount(0))
.StartAt(endTimeOffset.AddMinutes(-35)) .StartAt(endTimeOffset.AddMinutes(-40))
.Build(); .Build();
IJobDetail endOfShift = JobBuilder.Create<ShiftPlanNotificationScheduledJob>() IJobDetail endOfShift = JobBuilder.Create<ShiftPlanNotificationScheduledJob>()
.WithIdentity(ShiftPlanNotifyType.EndOfShift.ToString(), shiftPlan.Id.ToString()) .WithIdentity(ShiftPlanNotifyType.EndOfShift.ToString(), shiftPlan.Id.ToString())
.Build(); .Build();
@ -74,10 +60,9 @@ public class SetShiftPlanNotificationScheduleCommandHandler(IRepositoryWrapper r
.Build(); .Build();
var seTimeOffsetA = await scheduler.ScheduleJob(beforeEndShift30Min, beforeEndShift30MinTrigger, cancellationToken); await scheduler.ScheduleJob(beforeEndShift30Min, beforeEndShift30MinTrigger, cancellationToken);
var seTimeOffsetB = await scheduler.ScheduleJob(endOfShift, endOfShiftTrigger, cancellationToken); await scheduler.ScheduleJob(endOfShift, endOfShiftTrigger, cancellationToken);
var seTimeOffsetC = await scheduler.ScheduleJob(afterStartShift2Hour, afterStartShift2HourTrigger, cancellationToken); await scheduler.ScheduleJob(afterStartShift2Hour, afterStartShift2HourTrigger, cancellationToken);
await scheduler.Start(cancellationToken);
return true; return true;

View File

@ -1,4 +1,5 @@
using Brizco.Domain.Entities.Tasks; using Brizco.Domain.Entities.ShiftPlans;
using Brizco.Domain.Entities.Tasks;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Quartz; using Quartz;
using Task = System.Threading.Tasks.Task; using Task = System.Threading.Tasks.Task;
@ -25,15 +26,12 @@ public class ShiftPlanNotificationScheduledJob : IJob
var notifyType = (ShiftPlanNotifyType)int.Parse(context.JobDetail.Key.Name); var notifyType = (ShiftPlanNotifyType)int.Parse(context.JobDetail.Key.Name);
var shiftPlanId = Guid.Parse(context.JobDetail.Key.Group); var shiftPlanId = Guid.Parse(context.JobDetail.Key.Group);
var shiftPlan = await _repositoryWrapper.SetRepository<ShiftPlan>().TableNoTracking var shiftPlan = await _repositoryWrapper.SetRepository<ShiftPlan>().TableNoTracking
.Where(f => f.Id == shiftPlanId) .FirstOrDefaultAsync(f => f.Id == shiftPlanId);
.Select(ShiftPlanMapper.ProjectToSDto)
.FirstOrDefaultAsync();
if (shiftPlan == null) if (shiftPlan == null)
throw new Exception("Shift plan not found"); throw new Exception("Shift plan not found");
var shiftPlanUsers = await _repositoryWrapper.SetRepository<ShiftPlanUser>() var shiftPlanUsers = await _repositoryWrapper.SetRepository<ShiftPlanUser>()
.TableNoTracking .TableNoTracking
.Where(f => f.ShiftPlanId == shiftPlanId) .Where(f => f.ShiftPlanId == shiftPlanId)
.Select(ShiftPlanUserMapper.ProjectToSDto)
.ToListAsync(); .ToListAsync();
var superVisorId = shiftPlan.SupervisorId; var superVisorId = shiftPlan.SupervisorId;
switch (notifyType) switch (notifyType)
@ -49,7 +47,7 @@ public class ShiftPlanNotificationScheduledJob : IJob
var unDoneCount = activities.Count(a => a.UserId == shiftPlanUser.UserId && a.IsDone == false); var unDoneCount = activities.Count(a => a.UserId == shiftPlanUser.UserId && a.IsDone == false);
if(unDoneCount == 0) if(unDoneCount == 0)
continue; continue;
string message = $"نیم ساعت مونده تا شیفت تموم شه و {unDoneCount} عدد از تست هات مونده، حالا چه خاکی به سر کنیم!😱"; string message = $"شما تعداد {unDoneCount} وظیفه انجام نشده در شیفت مورد نظر دارید ، نیم ساعت به پایان شیفت مانده است";
await _mediator.Send(new CreateNotificationCommand(message, shiftPlanUser.UserId, shiftPlan.ComplexId)); await _mediator.Send(new CreateNotificationCommand(message, shiftPlanUser.UserId, shiftPlan.ComplexId));
} }
break; break;
@ -61,23 +59,14 @@ public class ShiftPlanNotificationScheduledJob : IJob
var unDoneCount = activitiesEndShift.Count(a => a.UserId == shiftPlanUser.UserId && a.IsDone == false); var unDoneCount = activitiesEndShift.Count(a => a.UserId == shiftPlanUser.UserId && a.IsDone == false);
if (unDoneCount == 0) if (unDoneCount == 0)
continue; continue;
string message = $"{shiftPlanUser.UserFullName} {shiftPlan.ShiftTitle} {shiftPlan.PlanFor.ToPersianDateTime().ToLongDateTimeString()} تموم شده است و {unDoneCount} - عدد از تسک های شما کاری روشون انجام نشده ، خطر سوپروایزر در کمین است"; string message = $"شما تعداد {unDoneCount} وظیفه انجام نشده در شیفت مورد نظر دارید";
await _mediator.Send(new CreateNotificationCommand(message, shiftPlanUser.UserId, shiftPlan.ComplexId)); await _mediator.Send(new CreateNotificationCommand(message, shiftPlanUser.UserId, shiftPlan.ComplexId));
} }
string superVisorAfterShiftMessage = $"{shiftPlan.SupervisorFullName} محترم {shiftPlan.ShiftTitle} تموم شد. برو به کار بچه ها نمره بده و مو رو از ماست بکش و کامنت یادت نره"; string superVisorAfterShiftMessage = $"سوپر وایزر محترم ، شیفت مورد نظر به پایان رسیده است ، لطفا فعالیت ها را رسیدگی کنید";
await _mediator.Send(new CreateNotificationCommand(superVisorAfterShiftMessage, shiftPlan.SupervisorId, shiftPlan.ComplexId)); await _mediator.Send(new CreateNotificationCommand(superVisorAfterShiftMessage, shiftPlan.SupervisorId, shiftPlan.ComplexId));
break; break;
case ShiftPlanNotifyType.AfterStartShift2Hour: case ShiftPlanNotifyType.AfterStartShift2Hour:
var activities2AfterStartShift = await _repositoryWrapper.SetRepository<Activity>().TableNoTracking
.Where(a => a.ShiftPlanId == shiftPlanId).ToListAsync();
foreach (var shiftPlanUser in shiftPlanUsers)
{
var unDoneCount = activities2AfterStartShift.Count(a => a.UserId == shiftPlanUser.UserId && a.IsDone == false);
if (unDoneCount == 0)
continue;
string message = $"{shiftPlanUser.UserFullName} دوساعت از {shiftPlan.ShiftTitle} گذشته ، اون انگشت و بزن روی تیک تسک ها که وقت طلاس مشتیییییی ";
await _mediator.Send(new CreateNotificationCommand(message, shiftPlanUser.UserId, shiftPlan.ComplexId));
}
break; break;
default: default:
return; return;

View File

@ -61,7 +61,6 @@
<Using Include="Brizco.Domain.Entities.Shifts" /> <Using Include="Brizco.Domain.Entities.Shifts" />
<Using Include="Brizco.Domain.Entities.Users" /> <Using Include="Brizco.Domain.Entities.Users" />
<Using Include="Brizco.Domain.Enums" /> <Using Include="Brizco.Domain.Enums" />
<Using Include="Brizco.Domain.MartenEntities.NewFeeds" />
<Using Include="Mapster" /> <Using Include="Mapster" />
<Using Include="Microsoft.AspNetCore.Identity" /> <Using Include="Microsoft.AspNetCore.Identity" />
<Using Include="System.ComponentModel" /> <Using Include="System.ComponentModel" />
@ -71,10 +70,4 @@
<Using Include="MediatR" /> <Using Include="MediatR" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="MartenEntities\NewFeeds\" />
</ItemGroup>
</Project> </Project>

View File

@ -1,5 +0,0 @@
namespace Brizco.Domain.CommandQueries.Commands;
public record CreateNewsFeedCommand(string Title,string Content,bool IsPin) : IRequest<Guid>;
public record DeleteNewsFeedCommand(Guid Id) : IRequest<bool>;
public record ChangeNewsFeedPinCommand(Guid Id , bool IsPin) : IRequest<bool>;

View File

@ -2,11 +2,7 @@
namespace Brizco.Domain.CommandQueries.Queries; namespace Brizco.Domain.CommandQueries.Queries;
public sealed record GetActivitiesQuery(int Page = 0 , public sealed record GetActivitiesQuery(int Page = 0 , long SelectedDate = 0 , Guid SelectedShiftPlanId = default , DateQueryFilter? DateQueryFilter = null) : IRequest<List<ActivitySDto>>;
long SelectedDate = 0 ,
Guid? SelectedShiftPlanId = null ,
DateTimeQueryFilter? DateQueryFilter = null,
Guid? UserId = null) : IRequest<List<ActivitySDto>>;
public sealed record GetActivityQuery(Guid Id) : IRequest<ActivityLDto>; public sealed record GetActivityQuery(Guid Id) : IRequest<ActivityLDto>;

View File

@ -1,3 +0,0 @@
namespace Brizco.Domain.CommandQueries.Queries;
public record GetNewsFeedsQuery(int Page , int? Count = 0) : IRequest<List<NewsFeed>>;

View File

@ -2,5 +2,4 @@
namespace Brizco.Domain.CommandQueries.Queries; namespace Brizco.Domain.CommandQueries.Queries;
public record GetNotificationsQuery(int Page,int? Count=null, Guid? UserId=null) : IRequest<List<Notification>>; public record GetNotificationsQuery(int Page,int Count, Guid? UserId=null) : IRequest<List<Notification>>;
public record GetNotificationsCountQuery() : IRequest<int>;

View File

@ -2,7 +2,7 @@
namespace Brizco.Domain.CommandQueries.Queries; namespace Brizco.Domain.CommandQueries.Queries;
public sealed record GetTasksQuery(int Page = 0 , int? Count = null,Guid? ShiftId = null) : public sealed record GetTasksQuery(int Page = 0) :
IRequest<List<TaskSDto>>; IRequest<List<TaskSDto>>;
public sealed record GetTaskQuery(Guid Id) : public sealed record GetTaskQuery(Guid Id) :

View File

@ -1,3 +0,0 @@
namespace Brizco.Domain.CommandQueries.Queries;
public record GetStaffQuery(int Page , DateTimeQueryFilter DateTimeQuery , int? Count = null) : IRequest<List<StaffResponseSDto>>;

View File

@ -1,8 +0,0 @@
namespace Brizco.Domain.Dtos.ResponseDto;
public class StaffResponseSDto
{
public Guid Id { get; set; }
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
}

View File

@ -20,7 +20,6 @@ public class ActivitySDto : BaseDto<ActivitySDto , Activity>
public string UserFirstName { get; set; } = string.Empty; public string UserFirstName { get; set; } = string.Empty;
public string UserLastName { get; set; } = string.Empty; public string UserLastName { get; set; } = string.Empty;
public string UserFullName => UserFirstName + " " + UserLastName; public string UserFullName => UserFirstName + " " + UserLastName;
public Guid UserId { get; set; }
public int Amount { get; set; } public int Amount { get; set; }

View File

@ -18,7 +18,6 @@ public class ShiftPlanSDto : BaseDto<ShiftPlanSDto,ShiftPlan>
public string ShiftTitle { get; set; } = string.Empty; public string ShiftTitle { get; set; } = string.Empty;
public TimeSpan StartAt { get; set; } public TimeSpan StartAt { get; set; }
public TimeSpan EndAt { get; set; } public TimeSpan EndAt { get; set; }
public Guid SupervisorId { get; set; }
public List<ShiftPlanUserSDto> Users { get; set; } = new(); public List<ShiftPlanUserSDto> Users { get; set; } = new();
} }

View File

@ -0,0 +1,9 @@
namespace Brizco.Domain.Enums;
public enum DateQueryFilter
{
Today = 0,
Tomorrow = 1,
ThisWeek = 2,
Yesterday = 3,
}

View File

@ -5,7 +5,6 @@ public enum DateTimeQueryFilter
CustomDate = 0, CustomDate = 0,
Today = 1, Today = 1,
Yesterday = 2, Yesterday = 2,
Tomorrow = 3,
PastWeek = 10, PastWeek = 10,
NextWeek = 11, NextWeek = 11,
ThisWeek = 12, ThisWeek = 12,

View File

@ -20,12 +20,10 @@ namespace Brizco.Domain.Mappers
IsDone = p1.IsDone, IsDone = p1.IsDone,
UnDoneReason = p1.UnDoneReason, UnDoneReason = p1.UnDoneReason,
PerformanceDescription = p1.PerformanceDescription, PerformanceDescription = p1.PerformanceDescription,
UserId = p1.UserId,
User = new ApplicationUser() User = new ApplicationUser()
{ {
FirstName = p1.UserFirstName, FirstName = p1.UserFirstName,
LastName = p1.UserLastName, LastName = p1.UserLastName
Id = p1.UserId
}, },
ShiftPlanId = p1.ShiftPlanId, ShiftPlanId = p1.ShiftPlanId,
ShiftPlan = new ShiftPlan() {Id = p1.ShiftPlanId}, ShiftPlan = new ShiftPlan() {Id = p1.ShiftPlanId},
@ -54,7 +52,6 @@ namespace Brizco.Domain.Mappers
result.IsDone = p2.IsDone; result.IsDone = p2.IsDone;
result.UnDoneReason = p2.UnDoneReason; result.UnDoneReason = p2.UnDoneReason;
result.PerformanceDescription = p2.PerformanceDescription; result.PerformanceDescription = p2.PerformanceDescription;
result.UserId = p2.UserId;
result.User = funcMain1(new Never(), result.User, p2); result.User = funcMain1(new Never(), result.User, p2);
result.ShiftPlanId = p2.ShiftPlanId; result.ShiftPlanId = p2.ShiftPlanId;
result.ShiftPlan = funcMain2(new Never(), result.ShiftPlan, p2); result.ShiftPlan = funcMain2(new Never(), result.ShiftPlan, p2);
@ -78,12 +75,10 @@ namespace Brizco.Domain.Mappers
IsDone = p8.IsDone, IsDone = p8.IsDone,
UnDoneReason = p8.UnDoneReason, UnDoneReason = p8.UnDoneReason,
PerformanceDescription = p8.PerformanceDescription, PerformanceDescription = p8.PerformanceDescription,
UserId = p8.UserId,
User = new ApplicationUser() User = new ApplicationUser()
{ {
FirstName = p8.UserFirstName, FirstName = p8.UserFirstName,
LastName = p8.UserLastName, LastName = p8.UserLastName
Id = p8.UserId
}, },
ShiftPlanId = p8.ShiftPlanId, ShiftPlanId = p8.ShiftPlanId,
ShiftPlan = new ShiftPlan() {Id = p8.ShiftPlanId}, ShiftPlan = new ShiftPlan() {Id = p8.ShiftPlanId},
@ -117,7 +112,6 @@ namespace Brizco.Domain.Mappers
PerformanceDescription = p9.PerformanceDescription, PerformanceDescription = p9.PerformanceDescription,
UserFirstName = p9.User != null ? p9.User.FirstName : string.Empty, UserFirstName = p9.User != null ? p9.User.FirstName : string.Empty,
UserLastName = p9.User != null ? p9.User.LastName : string.Empty, UserLastName = p9.User != null ? p9.User.LastName : string.Empty,
UserId = p9.UserId,
Amount = p9.Amount, Amount = p9.Amount,
ShiftPlanId = p9.ShiftPlanId, ShiftPlanId = p9.ShiftPlanId,
AmountType = p9.AmountType, AmountType = p9.AmountType,
@ -147,7 +141,6 @@ namespace Brizco.Domain.Mappers
result.PerformanceDescription = p10.PerformanceDescription; result.PerformanceDescription = p10.PerformanceDescription;
result.UserFirstName = p10.User != null ? p10.User.FirstName : string.Empty; result.UserFirstName = p10.User != null ? p10.User.FirstName : string.Empty;
result.UserLastName = p10.User != null ? p10.User.LastName : string.Empty; result.UserLastName = p10.User != null ? p10.User.LastName : string.Empty;
result.UserId = p10.UserId;
result.Amount = p10.Amount; result.Amount = p10.Amount;
result.ShiftPlanId = p10.ShiftPlanId; result.ShiftPlanId = p10.ShiftPlanId;
result.AmountType = p10.AmountType; result.AmountType = p10.AmountType;
@ -172,7 +165,6 @@ namespace Brizco.Domain.Mappers
PerformanceDescription = p12.PerformanceDescription, PerformanceDescription = p12.PerformanceDescription,
UserFirstName = p12.User != null ? p12.User.FirstName : string.Empty, UserFirstName = p12.User != null ? p12.User.FirstName : string.Empty,
UserLastName = p12.User != null ? p12.User.LastName : string.Empty, UserLastName = p12.User != null ? p12.User.LastName : string.Empty,
UserId = p12.UserId,
Amount = p12.Amount, Amount = p12.Amount,
ShiftPlanId = p12.ShiftPlanId, ShiftPlanId = p12.ShiftPlanId,
AmountType = p12.AmountType, AmountType = p12.AmountType,
@ -297,7 +289,6 @@ namespace Brizco.Domain.Mappers
result.FirstName = p2.UserFirstName; result.FirstName = p2.UserFirstName;
result.LastName = p2.UserLastName; result.LastName = p2.UserLastName;
result.Id = p2.UserId;
return result; return result;
} }

View File

@ -29,10 +29,6 @@ namespace Brizco.Domain.Mappers
Title = p1.ShiftTitle, Title = p1.ShiftTitle,
Id = p1.ShiftId Id = p1.ShiftId
}, },
ComplexId = p1.ComplexId,
Complex = new Complex() {Id = p1.ComplexId},
SupervisorId = p1.SupervisorId,
Supervisor = new ApplicationUser() {Id = p1.SupervisorId},
Users = funcMain1(p1.Users), Users = funcMain1(p1.Users),
Id = p1.Id Id = p1.Id
}; };
@ -51,212 +47,198 @@ namespace Brizco.Domain.Mappers
result.CompleteDescription = p3.CompleteDescription; result.CompleteDescription = p3.CompleteDescription;
result.ShiftId = p3.ShiftId; result.ShiftId = p3.ShiftId;
result.Shift = funcMain2(new Never(), result.Shift, p3); result.Shift = funcMain2(new Never(), result.Shift, p3);
result.ComplexId = p3.ComplexId; result.Users = funcMain3(p3.Users, result.Users);
result.Complex = funcMain3(new Never(), result.Complex, p3);
result.SupervisorId = p3.SupervisorId;
result.Supervisor = funcMain4(new Never(), result.Supervisor, p3);
result.Users = funcMain5(p3.Users, result.Users);
result.Id = p3.Id; result.Id = p3.Id;
return result; return result;
} }
public static Expression<Func<ShiftPlanSDto, ShiftPlan>> ProjectToShiftPlan => p13 => new ShiftPlan() public static Expression<Func<ShiftPlanSDto, ShiftPlan>> ProjectToShiftPlan => p9 => new ShiftPlan()
{ {
PlanFor = p13.PlanFor, PlanFor = p9.PlanFor,
IsCompleted = p13.IsCompleted, IsCompleted = p9.IsCompleted,
CompletePercent = p13.CompletePercent, CompletePercent = p9.CompletePercent,
CompleteDescription = p13.CompleteDescription, CompleteDescription = p9.CompleteDescription,
ShiftId = p13.ShiftId, ShiftId = p9.ShiftId,
Shift = new Shift() Shift = new Shift()
{ {
Title = p13.ShiftTitle, Title = p9.ShiftTitle,
Id = p13.ShiftId Id = p9.ShiftId
}, },
ComplexId = p13.ComplexId, Users = p9.Users.Select<ShiftPlanUserSDto, ShiftPlanUser>(p10 => new ShiftPlanUser()
Complex = new Complex() {Id = p13.ComplexId},
SupervisorId = p13.SupervisorId,
Supervisor = new ApplicationUser() {Id = p13.SupervisorId},
Users = p13.Users.Select<ShiftPlanUserSDto, ShiftPlanUser>(p14 => new ShiftPlanUser()
{ {
ShiftPlanId = p14.ShiftPlanId, ShiftPlanId = p10.ShiftPlanId,
ShiftPlan = new ShiftPlan() {Id = p14.ShiftPlanId}, ShiftPlan = new ShiftPlan() {Id = p10.ShiftPlanId},
PositionId = p14.PositionId, PositionId = p10.PositionId,
Position = new Position() Position = new Position()
{ {
Name = p14.PositionName, Name = p10.PositionName,
Id = p14.PositionId Id = p10.PositionId
}, },
UserId = p14.UserId, UserId = p10.UserId,
User = new ApplicationUser() {Id = p14.UserId}, User = new ApplicationUser() {Id = p10.UserId},
Id = p14.Id Id = p10.Id
}).ToList<ShiftPlanUser>(), }).ToList<ShiftPlanUser>(),
Id = p13.Id Id = p9.Id
}; };
public static ShiftPlanSDto AdaptToSDto(this ShiftPlan p15) public static ShiftPlanSDto AdaptToSDto(this ShiftPlan p11)
{ {
return p15 == null ? null : new ShiftPlanSDto() return p11 == null ? null : new ShiftPlanSDto()
{ {
PlanFor = p15.PlanFor, PlanFor = p11.PlanFor,
IsCompleted = p15.IsCompleted, IsCompleted = p11.IsCompleted,
CompletePercent = p15.CompletePercent, CompletePercent = p11.CompletePercent,
SupervisorFullName = p15.Supervisor != null ? p15.Supervisor.FirstName + " " + p15.Supervisor.LastName : string.Empty, SupervisorFullName = p11.Supervisor != null ? p11.Supervisor.FirstName + " " + p11.Supervisor.LastName : string.Empty,
CompleteDescription = p15.CompleteDescription, CompleteDescription = p11.CompleteDescription,
ComplexId = p15.ComplexId, ShiftId = p11.ShiftId,
ShiftId = p15.ShiftId, ShiftTitle = p11.Shift == null ? null : p11.Shift.Title,
ShiftTitle = p15.Shift == null ? null : p15.Shift.Title, StartAt = p11.Shift != null ? p11.Shift.StartAt : TimeSpan.MinValue,
StartAt = p15.Shift != null ? p15.Shift.StartAt : TimeSpan.MinValue, EndAt = p11.Shift != null ? p11.Shift.EndAt : TimeSpan.MinValue,
EndAt = p15.Shift != null ? p15.Shift.EndAt : TimeSpan.MinValue, Users = funcMain4(p11.Users),
SupervisorId = p15.SupervisorId, Id = p11.Id
Users = funcMain6(p15.Users),
Id = p15.Id
}; };
} }
public static ShiftPlanSDto AdaptTo(this ShiftPlan p17, ShiftPlanSDto p18) public static ShiftPlanSDto AdaptTo(this ShiftPlan p13, ShiftPlanSDto p14)
{ {
if (p17 == null) if (p13 == null)
{ {
return null; return null;
} }
ShiftPlanSDto result = p18 ?? new ShiftPlanSDto(); ShiftPlanSDto result = p14 ?? new ShiftPlanSDto();
result.PlanFor = p17.PlanFor; result.PlanFor = p13.PlanFor;
result.IsCompleted = p17.IsCompleted; result.IsCompleted = p13.IsCompleted;
result.CompletePercent = p17.CompletePercent; result.CompletePercent = p13.CompletePercent;
result.SupervisorFullName = p17.Supervisor != null ? p17.Supervisor.FirstName + " " + p17.Supervisor.LastName : string.Empty; result.SupervisorFullName = p13.Supervisor != null ? p13.Supervisor.FirstName + " " + p13.Supervisor.LastName : string.Empty;
result.CompleteDescription = p17.CompleteDescription; result.CompleteDescription = p13.CompleteDescription;
result.ComplexId = p17.ComplexId; result.ShiftId = p13.ShiftId;
result.ShiftId = p17.ShiftId; result.ShiftTitle = p13.Shift == null ? null : p13.Shift.Title;
result.ShiftTitle = p17.Shift == null ? null : p17.Shift.Title; result.StartAt = p13.Shift != null ? p13.Shift.StartAt : TimeSpan.MinValue;
result.StartAt = p17.Shift != null ? p17.Shift.StartAt : TimeSpan.MinValue; result.EndAt = p13.Shift != null ? p13.Shift.EndAt : TimeSpan.MinValue;
result.EndAt = p17.Shift != null ? p17.Shift.EndAt : TimeSpan.MinValue; result.Users = funcMain5(p13.Users, result.Users);
result.SupervisorId = p17.SupervisorId; result.Id = p13.Id;
result.Users = funcMain7(p17.Users, result.Users);
result.Id = p17.Id;
return result; return result;
} }
public static Expression<Func<ShiftPlan, ShiftPlanSDto>> ProjectToSDto => p21 => new ShiftPlanSDto() public static Expression<Func<ShiftPlan, ShiftPlanSDto>> ProjectToSDto => p17 => new ShiftPlanSDto()
{ {
PlanFor = p21.PlanFor, PlanFor = p17.PlanFor,
IsCompleted = p21.IsCompleted, IsCompleted = p17.IsCompleted,
CompletePercent = p21.CompletePercent, CompletePercent = p17.CompletePercent,
SupervisorFullName = p21.Supervisor != null ? p21.Supervisor.FirstName + " " + p21.Supervisor.LastName : string.Empty, SupervisorFullName = p17.Supervisor != null ? p17.Supervisor.FirstName + " " + p17.Supervisor.LastName : string.Empty,
CompleteDescription = p21.CompleteDescription, CompleteDescription = p17.CompleteDescription,
ComplexId = p21.ComplexId, ShiftId = p17.ShiftId,
ShiftId = p21.ShiftId, ShiftTitle = p17.Shift.Title,
ShiftTitle = p21.Shift.Title, StartAt = p17.Shift != null ? p17.Shift.StartAt : TimeSpan.MinValue,
StartAt = p21.Shift != null ? p21.Shift.StartAt : TimeSpan.MinValue, EndAt = p17.Shift != null ? p17.Shift.EndAt : TimeSpan.MinValue,
EndAt = p21.Shift != null ? p21.Shift.EndAt : TimeSpan.MinValue, Users = p17.Users.Select<ShiftPlanUser, ShiftPlanUserSDto>(p18 => new ShiftPlanUserSDto()
SupervisorId = p21.SupervisorId,
Users = p21.Users.Select<ShiftPlanUser, ShiftPlanUserSDto>(p22 => new ShiftPlanUserSDto()
{ {
ShiftPlanId = p22.ShiftPlanId, ShiftPlanId = p18.ShiftPlanId,
UserId = p22.UserId, UserId = p18.UserId,
UserFullName = p22.User != null ? p22.User.FirstName + " " + p22.User.LastName : string.Empty, UserFullName = p18.User != null ? p18.User.FirstName + " " + p18.User.LastName : string.Empty,
PositionId = p22.PositionId, PositionId = p18.PositionId,
PositionName = p22.Position != null ? p22.Position.Name : string.Empty, PositionName = p18.Position != null ? p18.Position.Name : string.Empty,
Id = p22.Id Id = p18.Id
}).ToList<ShiftPlanUserSDto>(), }).ToList<ShiftPlanUserSDto>(),
Id = p21.Id Id = p17.Id
}; };
public static ShiftPlan AdaptToShiftPlan(this ShiftPlanLDto p23) public static ShiftPlan AdaptToShiftPlan(this ShiftPlanLDto p19)
{ {
return p23 == null ? null : new ShiftPlan() return p19 == null ? null : new ShiftPlan()
{ {
PlanFor = p23.PlanFor, PlanFor = p19.PlanFor,
IsCompleted = p23.IsCompleted, IsCompleted = p19.IsCompleted,
CompletePercent = p23.CompletePercent, CompletePercent = p19.CompletePercent,
CompleteDescription = p23.CompleteDescription, CompleteDescription = p19.CompleteDescription,
ShiftId = p23.ShiftId, ShiftId = p19.ShiftId,
Shift = new Shift() {Id = p23.ShiftId}, Shift = new Shift() {Id = p19.ShiftId},
RoutineId = p23.RoutineId, RoutineId = p19.RoutineId,
Routine = new Routine() {Id = p23.RoutineId}, Routine = new Routine() {Id = p19.RoutineId},
SupervisorId = p23.SupervisorId, SupervisorId = p19.SupervisorId,
Supervisor = new ApplicationUser() {Id = p23.SupervisorId}, Supervisor = new ApplicationUser() {Id = p19.SupervisorId},
Users = funcMain8(p23.Users), Users = funcMain6(p19.Users),
Id = p23.Id Id = p19.Id
}; };
} }
public static ShiftPlan AdaptTo(this ShiftPlanLDto p25, ShiftPlan p26) public static ShiftPlan AdaptTo(this ShiftPlanLDto p21, ShiftPlan p22)
{ {
if (p25 == null) if (p21 == null)
{ {
return null; return null;
} }
ShiftPlan result = p26 ?? new ShiftPlan(); ShiftPlan result = p22 ?? new ShiftPlan();
result.PlanFor = p25.PlanFor; result.PlanFor = p21.PlanFor;
result.IsCompleted = p25.IsCompleted; result.IsCompleted = p21.IsCompleted;
result.CompletePercent = p25.CompletePercent; result.CompletePercent = p21.CompletePercent;
result.CompleteDescription = p25.CompleteDescription; result.CompleteDescription = p21.CompleteDescription;
result.ShiftId = p25.ShiftId; result.ShiftId = p21.ShiftId;
result.Shift = funcMain9(new Never(), result.Shift, p25); result.Shift = funcMain7(new Never(), result.Shift, p21);
result.RoutineId = p25.RoutineId; result.RoutineId = p21.RoutineId;
result.Routine = funcMain10(new Never(), result.Routine, p25); result.Routine = funcMain8(new Never(), result.Routine, p21);
result.SupervisorId = p25.SupervisorId; result.SupervisorId = p21.SupervisorId;
result.Supervisor = funcMain11(new Never(), result.Supervisor, p25); result.Supervisor = funcMain9(new Never(), result.Supervisor, p21);
result.Users = funcMain12(p25.Users, result.Users); result.Users = funcMain10(p21.Users, result.Users);
result.Id = p25.Id; result.Id = p21.Id;
return result; return result;
} }
public static ShiftPlanLDto AdaptToLDto(this ShiftPlan p35) public static ShiftPlanLDto AdaptToLDto(this ShiftPlan p31)
{ {
return p35 == null ? null : new ShiftPlanLDto() return p31 == null ? null : new ShiftPlanLDto()
{ {
PlanFor = p35.PlanFor, PlanFor = p31.PlanFor,
RoutineId = p35.RoutineId, RoutineId = p31.RoutineId,
IsCompleted = p35.IsCompleted, IsCompleted = p31.IsCompleted,
CompletePercent = p35.CompletePercent, CompletePercent = p31.CompletePercent,
CompleteDescription = p35.CompleteDescription, CompleteDescription = p31.CompleteDescription,
ShiftId = p35.ShiftId, ShiftId = p31.ShiftId,
Users = funcMain13(p35.Users), Users = funcMain11(p31.Users),
SupervisorId = p35.SupervisorId, SupervisorId = p31.SupervisorId,
SupervisorFullName = p35.Supervisor != null ? p35.Supervisor.FirstName + " " + p35.Supervisor.LastName : string.Empty, SupervisorFullName = p31.Supervisor != null ? p31.Supervisor.FirstName + " " + p31.Supervisor.LastName : string.Empty,
Id = p35.Id Id = p31.Id
}; };
} }
public static ShiftPlanLDto AdaptTo(this ShiftPlan p37, ShiftPlanLDto p38) public static ShiftPlanLDto AdaptTo(this ShiftPlan p33, ShiftPlanLDto p34)
{ {
if (p37 == null) if (p33 == null)
{ {
return null; return null;
} }
ShiftPlanLDto result = p38 ?? new ShiftPlanLDto(); ShiftPlanLDto result = p34 ?? new ShiftPlanLDto();
result.PlanFor = p37.PlanFor; result.PlanFor = p33.PlanFor;
result.RoutineId = p37.RoutineId; result.RoutineId = p33.RoutineId;
result.IsCompleted = p37.IsCompleted; result.IsCompleted = p33.IsCompleted;
result.CompletePercent = p37.CompletePercent; result.CompletePercent = p33.CompletePercent;
result.CompleteDescription = p37.CompleteDescription; result.CompleteDescription = p33.CompleteDescription;
result.ShiftId = p37.ShiftId; result.ShiftId = p33.ShiftId;
result.Users = funcMain14(p37.Users, result.Users); result.Users = funcMain12(p33.Users, result.Users);
result.SupervisorId = p37.SupervisorId; result.SupervisorId = p33.SupervisorId;
result.SupervisorFullName = p37.Supervisor != null ? p37.Supervisor.FirstName + " " + p37.Supervisor.LastName : string.Empty; result.SupervisorFullName = p33.Supervisor != null ? p33.Supervisor.FirstName + " " + p33.Supervisor.LastName : string.Empty;
result.Id = p37.Id; result.Id = p33.Id;
return result; return result;
} }
public static Expression<Func<ShiftPlan, ShiftPlanLDto>> ProjectToLDto => p41 => new ShiftPlanLDto() public static Expression<Func<ShiftPlan, ShiftPlanLDto>> ProjectToLDto => p37 => new ShiftPlanLDto()
{ {
PlanFor = p41.PlanFor, PlanFor = p37.PlanFor,
RoutineId = p41.RoutineId, RoutineId = p37.RoutineId,
IsCompleted = p41.IsCompleted, IsCompleted = p37.IsCompleted,
CompletePercent = p41.CompletePercent, CompletePercent = p37.CompletePercent,
CompleteDescription = p41.CompleteDescription, CompleteDescription = p37.CompleteDescription,
ShiftId = p41.ShiftId, ShiftId = p37.ShiftId,
Users = p41.Users.Select<ShiftPlanUser, ShiftPlanUserSDto>(p42 => new ShiftPlanUserSDto() Users = p37.Users.Select<ShiftPlanUser, ShiftPlanUserSDto>(p38 => new ShiftPlanUserSDto()
{ {
ShiftPlanId = p42.ShiftPlanId, ShiftPlanId = p38.ShiftPlanId,
UserId = p42.UserId, UserId = p38.UserId,
UserFullName = p42.User != null ? p42.User.FirstName + " " + p42.User.LastName : string.Empty, UserFullName = p38.User != null ? p38.User.FirstName + " " + p38.User.LastName : string.Empty,
PositionId = p42.PositionId, PositionId = p38.PositionId,
PositionName = p42.Position != null ? p42.Position.Name : string.Empty, PositionName = p38.Position != null ? p38.Position.Name : string.Empty,
Id = p42.Id Id = p38.Id
}).ToList<ShiftPlanUserSDto>(), }).ToList<ShiftPlanUserSDto>(),
SupervisorId = p41.SupervisorId, SupervisorId = p37.SupervisorId,
SupervisorFullName = p41.Supervisor != null ? p41.Supervisor.FirstName + " " + p41.Supervisor.LastName : string.Empty, SupervisorFullName = p37.Supervisor != null ? p37.Supervisor.FirstName + " " + p37.Supervisor.LastName : string.Empty,
Id = p41.Id Id = p37.Id
}; };
private static List<ShiftPlanUser> funcMain1(List<ShiftPlanUserSDto> p2) private static List<ShiftPlanUser> funcMain1(List<ShiftPlanUserSDto> p2)
@ -303,38 +285,20 @@ namespace Brizco.Domain.Mappers
} }
private static Complex funcMain3(Never p7, Complex p8, ShiftPlanSDto p3) private static List<ShiftPlanUser> funcMain3(List<ShiftPlanUserSDto> p7, List<ShiftPlanUser> p8)
{ {
Complex result = p8 ?? new Complex(); if (p7 == null)
result.Id = p3.ComplexId;
return result;
}
private static ApplicationUser funcMain4(Never p9, ApplicationUser p10, ShiftPlanSDto p3)
{
ApplicationUser result = p10 ?? new ApplicationUser();
result.Id = p3.SupervisorId;
return result;
}
private static List<ShiftPlanUser> funcMain5(List<ShiftPlanUserSDto> p11, List<ShiftPlanUser> p12)
{
if (p11 == null)
{ {
return null; return null;
} }
List<ShiftPlanUser> result = new List<ShiftPlanUser>(p11.Count); List<ShiftPlanUser> result = new List<ShiftPlanUser>(p7.Count);
int i = 0; int i = 0;
int len = p11.Count; int len = p7.Count;
while (i < len) while (i < len)
{ {
ShiftPlanUserSDto item = p11[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,
@ -355,20 +319,20 @@ namespace Brizco.Domain.Mappers
} }
private static List<ShiftPlanUserSDto> funcMain6(List<ShiftPlanUser> p16) private static List<ShiftPlanUserSDto> funcMain4(List<ShiftPlanUser> p12)
{ {
if (p16 == null) if (p12 == null)
{ {
return null; return null;
} }
List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p16.Count); List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p12.Count);
int i = 0; int i = 0;
int len = p16.Count; int len = p12.Count;
while (i < len) while (i < len)
{ {
ShiftPlanUser item = p16[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,
@ -384,20 +348,20 @@ namespace Brizco.Domain.Mappers
} }
private static List<ShiftPlanUserSDto> funcMain7(List<ShiftPlanUser> p19, List<ShiftPlanUserSDto> p20) private static List<ShiftPlanUserSDto> funcMain5(List<ShiftPlanUser> p15, List<ShiftPlanUserSDto> p16)
{ {
if (p19 == null) if (p15 == null)
{ {
return null; return null;
} }
List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p19.Count); List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p15.Count);
int i = 0; int i = 0;
int len = p19.Count; int len = p15.Count;
while (i < len) while (i < len)
{ {
ShiftPlanUser item = p19[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,
@ -413,20 +377,20 @@ namespace Brizco.Domain.Mappers
} }
private static List<ShiftPlanUser> funcMain8(List<ShiftPlanUserSDto> p24) private static List<ShiftPlanUser> funcMain6(List<ShiftPlanUserSDto> p20)
{ {
if (p24 == null) if (p20 == null)
{ {
return null; return null;
} }
List<ShiftPlanUser> result = new List<ShiftPlanUser>(p24.Count); List<ShiftPlanUser> result = new List<ShiftPlanUser>(p20.Count);
int i = 0; int i = 0;
int len = p24.Count; int len = p20.Count;
while (i < len) while (i < len)
{ {
ShiftPlanUserSDto item = p24[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,
@ -447,47 +411,47 @@ namespace Brizco.Domain.Mappers
} }
private static Shift funcMain9(Never p27, Shift p28, ShiftPlanLDto p25) private static Shift funcMain7(Never p23, Shift p24, ShiftPlanLDto p21)
{ {
Shift result = p28 ?? new Shift(); Shift result = p24 ?? new Shift();
result.Id = p25.ShiftId; result.Id = p21.ShiftId;
return result; return result;
} }
private static Routine funcMain10(Never p29, Routine p30, ShiftPlanLDto p25) private static Routine funcMain8(Never p25, Routine p26, ShiftPlanLDto p21)
{ {
Routine result = p30 ?? new Routine(); Routine result = p26 ?? new Routine();
result.Id = p25.RoutineId; result.Id = p21.RoutineId;
return result; return result;
} }
private static ApplicationUser funcMain11(Never p31, ApplicationUser p32, ShiftPlanLDto p25) private static ApplicationUser funcMain9(Never p27, ApplicationUser p28, ShiftPlanLDto p21)
{ {
ApplicationUser result = p32 ?? new ApplicationUser(); ApplicationUser result = p28 ?? new ApplicationUser();
result.Id = p25.SupervisorId; result.Id = p21.SupervisorId;
return result; return result;
} }
private static List<ShiftPlanUser> funcMain12(List<ShiftPlanUserSDto> p33, List<ShiftPlanUser> p34) private static List<ShiftPlanUser> funcMain10(List<ShiftPlanUserSDto> p29, List<ShiftPlanUser> p30)
{ {
if (p33 == null) if (p29 == null)
{ {
return null; return null;
} }
List<ShiftPlanUser> result = new List<ShiftPlanUser>(p33.Count); List<ShiftPlanUser> result = new List<ShiftPlanUser>(p29.Count);
int i = 0; int i = 0;
int len = p33.Count; int len = p29.Count;
while (i < len) while (i < len)
{ {
ShiftPlanUserSDto item = p33[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,
@ -508,20 +472,20 @@ namespace Brizco.Domain.Mappers
} }
private static List<ShiftPlanUserSDto> funcMain13(List<ShiftPlanUser> p36) private static List<ShiftPlanUserSDto> funcMain11(List<ShiftPlanUser> p32)
{ {
if (p36 == null) if (p32 == null)
{ {
return null; return null;
} }
List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p36.Count); List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p32.Count);
int i = 0; int i = 0;
int len = p36.Count; int len = p32.Count;
while (i < len) while (i < len)
{ {
ShiftPlanUser item = p36[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,
@ -537,20 +501,20 @@ namespace Brizco.Domain.Mappers
} }
private static List<ShiftPlanUserSDto> funcMain14(List<ShiftPlanUser> p39, List<ShiftPlanUserSDto> p40) private static List<ShiftPlanUserSDto> funcMain12(List<ShiftPlanUser> p35, List<ShiftPlanUserSDto> p36)
{ {
if (p39 == null) if (p35 == null)
{ {
return null; return null;
} }
List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p39.Count); List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p35.Count);
int i = 0; int i = 0;
int len = p39.Count; int len = p35.Count;
while (i < len) while (i < len)
{ {
ShiftPlanUser item = p39[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

@ -1,9 +0,0 @@
namespace Brizco.Domain.MartenEntities.NewFeeds;
public class NewsFeed : MartenEntity
{
public string Content { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public bool IsPin { get; set; }
public DateTime CreatedAt { get; set; }
}

View File

@ -36,7 +36,7 @@ public class MartenRepository<TMartenEntity> : IMartenRepository<TMartenEntity>
await using var session = _documentStore.QuerySession(); await using var session = _documentStore.QuerySession();
var setting = await session.LoadAsync<TMartenEntity>(id, cancellation); var setting = await session.LoadAsync<TMartenEntity>(id, cancellation);
if (setting == null) if (setting == null)
throw new AppException($"{nameof(TMartenEntity)} not found", ApiResultStatusCode.NotFound); throw new AppException($"{nameof(setting)} not found", ApiResultStatusCode.NotFound);
return setting; return setting;
} }

View File

@ -27,7 +27,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Handlers\Users\" /> <Folder Include="MartenHandlers\Notifications\" />
<Folder Include="Models\" /> <Folder Include="Models\" />
<Folder Include="Extensions\" /> <Folder Include="Extensions\" />
<Folder Include="Services\Contracts\" /> <Folder Include="Services\Contracts\" />
@ -50,7 +50,6 @@
<Using Include="Brizco.Domain.Entities.ShiftPlans" /> <Using Include="Brizco.Domain.Entities.ShiftPlans" />
<Using Include="Brizco.Domain.Entities.Shifts" /> <Using Include="Brizco.Domain.Entities.Shifts" />
<Using Include="Brizco.Domain.Entities.Users" /> <Using Include="Brizco.Domain.Entities.Users" />
<Using Include="Brizco.Domain.MartenEntities.NewFeeds" />
<Using Include="Brizco.Domain.MartenEntities.Notifications" /> <Using Include="Brizco.Domain.MartenEntities.Notifications" />
<Using Include="Brizco.Repository.Abstracts" /> <Using Include="Brizco.Repository.Abstracts" />
<Using Include="Brizco.Repository.Extensions" /> <Using Include="Brizco.Repository.Extensions" />

View File

@ -1,52 +1,51 @@
namespace Brizco.Repository.Handlers.Activities; namespace Brizco.Repository.Handlers.Activities;
public class GetActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService) public class GetActivitiesQueryHandler : IRequestHandler<GetActivitiesQuery, List<ActivitySDto>>
: IRequestHandler<GetActivitiesQuery, List<ActivitySDto>>
{ {
private readonly IRepositoryWrapper _repositoryWrapper;
private readonly ICurrentUserService _currentUserService;
public GetActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
{
_repositoryWrapper = repositoryWrapper;
_currentUserService = currentUserService;
}
public async Task<List<ActivitySDto>> Handle(GetActivitiesQuery request, CancellationToken cancellationToken) public async Task<List<ActivitySDto>> Handle(GetActivitiesQuery request, CancellationToken cancellationToken)
{ {
if (currentUserService.ComplexId == null) if (_currentUserService.ComplexId == null)
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);
if (currentUserService.UserId == null) if (_currentUserService.UserId == null)
throw new AppException("UserId is null", ApiResultStatusCode.NotFound); throw new AppException("UserId is null", ApiResultStatusCode.NotFound);
if (!Guid.TryParse(currentUserService.UserId, out Guid userId)) if (!Guid.TryParse(_currentUserService.UserId, out Guid userId))
throw new AppException("UserId is wrong", ApiResultStatusCode.NotFound); throw new AppException("UserId is wrong", ApiResultStatusCode.NotFound);
IQueryable<Domain.Entities.Tasks.Activity> activities = repositoryWrapper.SetRepository<Domain.Entities.Tasks.Activity>().TableNoTracking IQueryable<Domain.Entities.Tasks.Activity> activities = _repositoryWrapper.SetRepository<Domain.Entities.Tasks.Activity>().TableNoTracking
.Where(a=>a.IsActivity && a.ComplexId == complexId); .Where(a=>a.IsActivity && a.ComplexId == complexId);
if (currentUserService is { Permissions: not null, RoleName: not null }) if (_currentUserService is { Permissions: not null, RoleName: not null })
{ {
if (currentUserService.Permissions.Contains(ApplicationPermission.ViewMineActivities) && currentUserService.RoleName == ApplicationRoles.Staff) if (_currentUserService.Permissions.Contains(ApplicationPermission.ViewMineActivities) && _currentUserService.RoleName == ApplicationRoles.Staff)
activities = activities.Where(a => a.UserId == userId); activities = activities.Where(a => a.UserId == userId);
else
activities = activities.Where(c => c.UserId == request.UserId);
} }
if (request.DateQueryFilter != null) if (request.DateQueryFilter != null)
{ {
var date = DateTime.Now;
switch (request.DateQueryFilter) switch (request.DateQueryFilter)
{ {
case DateTimeQueryFilter.Yesterday: case DateQueryFilter.Yesterday:
activities = activities.Where(a => a.SetFor.Date == DateTime.Today.Date.AddDays(-1).Date); activities = activities.Where(a => a.SetFor.Date == DateTime.Today.Date.AddDays(-1).Date);
break; break;
case DateTimeQueryFilter.Today: case DateQueryFilter.Today:
activities = activities.Where(a => a.SetFor.Date == DateTime.Today.Date); activities = activities.Where(a => a.SetFor.Date == DateTime.Today.Date);
break; break;
case DateTimeQueryFilter.Tomorrow: case DateQueryFilter.Tomorrow:
activities = activities.Where(a => a.SetFor.Date == DateTime.Today.AddDays(1).Date); activities = activities.Where(a => a.SetFor.Date == DateTime.Today.AddDays(1).Date);
break; break;
case DateTimeQueryFilter.ThisWeek: case DateQueryFilter.ThisWeek:
DateTime today = DateTime.Today; activities = activities.Where(a => a.SetFor.Date >= DateTime.Today.AddDays(-1).Date && a.SetFor.Date <= DateTime.Today.AddDays(+6).Date);
int delta = DayOfWeek.Saturday - today.DayOfWeek;
if (delta > 0) delta -= 7;
DateTime startOfWeek = today.AddDays(delta);
DateTime endOfWeek = startOfWeek.AddDays(6);
activities = activities.Where(a => a.SetFor.Date >= startOfWeek.Date && a.SetFor.Date <= endOfWeek.Date);
break; break;
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();

View File

@ -1,10 +1,16 @@
namespace Brizco.Repository.Handlers.Activities; namespace Brizco.Repository.Handlers.Activities;
public class GetShiftPlanActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler<GetShiftPlanActivitiesQuery, List<ActivitySDto>> public class GetShiftPlanActivitiesQueryHandler : IRequestHandler<GetShiftPlanActivitiesQuery, List<ActivitySDto>>
{ {
private IRepositoryWrapper _repositoryWrapper;
public GetShiftPlanActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<List<ActivitySDto>> Handle(GetShiftPlanActivitiesQuery request, CancellationToken cancellationToken) public async Task<List<ActivitySDto>> Handle(GetShiftPlanActivitiesQuery request, CancellationToken cancellationToken)
{ {
var activities = await repositoryWrapper.SetRepository<Domain.Entities.Tasks.Activity>() var activities = await _repositoryWrapper.SetRepository<Domain.Entities.Tasks.Activity>()
.TableNoTracking .TableNoTracking
.Where(a => a.ShiftPlanId == request.ShiftPlanId) .Where(a => a.ShiftPlanId == request.ShiftPlanId)
.Select(ActivityMapper.ProjectToSDto) .Select(ActivityMapper.ProjectToSDto)

View File

@ -2,16 +2,24 @@
namespace Brizco.Repository.Handlers.ShiftPlans; namespace Brizco.Repository.Handlers.ShiftPlans;
public class GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService) : IRequestHandler<GetShiftPlansQuery, List<ShiftPlanSDto>> public class GetShiftPlansQueryHandler : IRequestHandler<GetShiftPlansQuery, List<ShiftPlanSDto>>
{ {
private readonly IRepositoryWrapper _repositoryWrapper;
private readonly ICurrentUserService _currentUserService;
public GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
{
_repositoryWrapper = repositoryWrapper;
_currentUserService = currentUserService;
}
public async Task<List<ShiftPlanSDto>> Handle(GetShiftPlansQuery request, CancellationToken cancellationToken) public async Task<List<ShiftPlanSDto>> Handle(GetShiftPlansQuery request, CancellationToken cancellationToken)
{ {
if (currentUserService.ComplexId == null) if (_currentUserService.ComplexId == null)
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);
IQueryable<ShiftPlan> baseQuery = repositoryWrapper.SetRepository<ShiftPlan>() IQueryable<ShiftPlan> baseQuery = _repositoryWrapper.SetRepository<ShiftPlan>()
.TableNoTracking .TableNoTracking
.OrderByDescending(s => s.CreatedAt) .OrderByDescending(s => s.CreatedAt)
.Where(s => s.ComplexId == complexId); .Where(s => s.ComplexId == complexId);
@ -69,7 +77,7 @@ public class GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper, ICu
break; break;
case DateTimeQueryFilter.NextWeek: case DateTimeQueryFilter.NextWeek:
DateTime startOfNextWeek = DateTime.Today.AddDays(7 - (int)DateTime.Today.DayOfWeek + 1); DateTime startOfNextWeek = DateTime.Today.AddDays(7 - (int)DateTime.Today.DayOfWeek + 1);
DateTime endOfNextWeek = startOfNextWeek.AddDays(6); DateTime endOfNextWeek = startOfNextWeek.AddDays(5);
shiftPlans = await baseQuery.Where(s => s.PlanFor.Date >= startOfNextWeek.Date && s.PlanFor.Date <= endOfNextWeek.Date) shiftPlans = await baseQuery.Where(s => s.PlanFor.Date >= startOfNextWeek.Date && s.PlanFor.Date <= endOfNextWeek.Date)
.OrderByDescending(s => s.CreatedAt) .OrderByDescending(s => s.CreatedAt)
.Skip(request.Page * 15).Take(15) .Skip(request.Page * 15).Take(15)
@ -130,13 +138,13 @@ public class GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper, ICu
foreach (var shiftPlan in shiftPlans) foreach (var shiftPlan in shiftPlans)
{ {
var activitiesCount = await repositoryWrapper.SetRepository<Domain.Entities.Tasks.Activity>() var activitiesCount = await _repositoryWrapper.SetRepository<Domain.Entities.Tasks.Activity>()
.TableNoTracking .TableNoTracking
.CountAsync(a => a.SetFor.Date == shiftPlan.PlanFor.Date && a.ShiftPlanId == shiftPlan.Id, cancellationToken); .CountAsync(a => a.SetFor.Date == shiftPlan.PlanFor.Date && a.ShiftPlanId == shiftPlan.Id, cancellationToken);
var doneActivitiesCount = await repositoryWrapper.SetRepository<Domain.Entities.Tasks.Activity>() var doneActivitiesCount = await _repositoryWrapper.SetRepository<Domain.Entities.Tasks.Activity>()
.TableNoTracking .TableNoTracking
.CountAsync(a => a.Status == ActivityStatus.Done && a.SetFor.Date == shiftPlan.PlanFor.Date && a.ShiftPlanId == shiftPlan.Id, cancellationToken); .CountAsync(a => a.Status == ActivityStatus.Done && a.SetFor.Date == shiftPlan.PlanFor.Date && a.ShiftPlanId == shiftPlan.Id, cancellationToken);
var undoneActivitiesCount = await repositoryWrapper.SetRepository<Domain.Entities.Tasks.Activity>() var undoneActivitiesCount = await _repositoryWrapper.SetRepository<Domain.Entities.Tasks.Activity>()
.TableNoTracking .TableNoTracking
.CountAsync(a => a.Status == ActivityStatus.UnDone && a.SetFor.Date == shiftPlan.PlanFor.Date && a.ShiftPlanId == shiftPlan.Id, cancellationToken); .CountAsync(a => a.Status == ActivityStatus.UnDone && a.SetFor.Date == shiftPlan.PlanFor.Date && a.ShiftPlanId == shiftPlan.Id, cancellationToken);
shiftPlan.UndoneActivitiesCount = undoneActivitiesCount; shiftPlan.UndoneActivitiesCount = undoneActivitiesCount;
@ -147,7 +155,7 @@ public class GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper, ICu
foreach (var shiftPlan in shiftPlans) foreach (var shiftPlan in shiftPlans)
{ {
shiftPlan.StaffCount = await repositoryWrapper.SetRepository<ShiftPlanUser>() shiftPlan.StaffCount = await _repositoryWrapper.SetRepository<ShiftPlanUser>()
.TableNoTracking .TableNoTracking
.CountAsync(spu => spu.ShiftPlanId == shiftPlan.Id, cancellationToken); .CountAsync(spu => spu.ShiftPlanId == shiftPlan.Id, cancellationToken);

View File

@ -1,13 +1,22 @@
namespace Brizco.Repository.Handlers.Shifts; namespace Brizco.Repository.Handlers.Shifts;
public class GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper, UserManager<ApplicationUser> userManager, ICurrentUserService currentUserService) public class GetShiftPlansQueryHandler : IRequestHandler<GetShiftsQuery, List<ShiftSDto>>
: IRequestHandler<GetShiftsQuery, List<ShiftSDto>>
{ {
private readonly IRepositoryWrapper _repositoryWrapper;
private readonly UserManager<ApplicationUser> _userManager;
private readonly ICurrentUserService _currentUserService;
public GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper,UserManager<ApplicationUser> userManager, ICurrentUserService currentUserService)
{
_repositoryWrapper = repositoryWrapper;
_userManager = userManager;
_currentUserService = currentUserService;
}
public async Task<List<ShiftSDto>> Handle(GetShiftsQuery request, CancellationToken cancellationToken) public async Task<List<ShiftSDto>> Handle(GetShiftsQuery request, CancellationToken cancellationToken)
{ {
if (currentUserService.ComplexId == null) if (_currentUserService.ComplexId == null)
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; List<ShiftSDto> shifts;
@ -15,46 +24,46 @@ public class GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper, Use
{ {
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<Shift>().Entities on shiftDay.ShiftId equals shift.Id join shift in _repositoryWrapper.SetRepository<Shift>().Entities on shiftDay.ShiftId equals shift.Id
where shiftDay.DayOfWeek == selectedDate.DayOfWeek && shift.ComplexId == complexId where shiftDay.DayOfWeek == selectedDate.DayOfWeek && shift.ComplexId == complexId
orderby shift.StartAt orderby shift.StartAt descending
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)
{ {
var existedShiftPlan = await repositoryWrapper.SetRepository<ShiftPlan>() var existedShiftPlan = await _repositoryWrapper.SetRepository<ShiftPlan>()
.TableNoTracking .TableNoTracking
.FirstOrDefaultAsync(s => s.ShiftId == shift.Id && s.PlanFor.Date == selectedDate.Date, cancellationToken); .FirstOrDefaultAsync(s => s.ShiftId == shift.Id && s.PlanFor.Date == selectedDate.Date, cancellationToken);
if(existedShiftPlan == null) if(existedShiftPlan == null)
continue; continue;
var supervisor = await userManager.FindByIdAsync(existedShiftPlan.SupervisorId.ToString()); var supervisor = await _userManager.FindByIdAsync(existedShiftPlan.SupervisorId.ToString());
if (supervisor != null) if (supervisor != null)
shift.CurrentSupervisorFullName = supervisor.FirstName + " " + supervisor.LastName; shift.CurrentSupervisorFullName = supervisor.FirstName + " " + supervisor.LastName;
var activitiesCount = await repositoryWrapper.SetRepository<Domain.Entities.Tasks.Activity>() var activitiesCount = await _repositoryWrapper.SetRepository<Domain.Entities.Tasks.Activity>()
.TableNoTracking .TableNoTracking
.CountAsync(a => a.SetFor.Date == selectedDate.Date && a.ShiftPlanId == existedShiftPlan.Id, cancellationToken); .CountAsync(a => a.SetFor.Date == selectedDate.Date && a.ShiftPlanId == existedShiftPlan.Id, cancellationToken);
var doneActivitiesCount = await repositoryWrapper.SetRepository<Domain.Entities.Tasks.Activity>() var doneActivitiesCount = await _repositoryWrapper.SetRepository<Domain.Entities.Tasks.Activity>()
.TableNoTracking .TableNoTracking
.CountAsync(a => a.Status == ActivityStatus.Done && a.SetFor.Date == selectedDate.Date && a.ShiftPlanId == existedShiftPlan.Id, cancellationToken); .CountAsync(a => a.Status == ActivityStatus.Done && a.SetFor.Date == selectedDate.Date && a.ShiftPlanId == existedShiftPlan.Id, cancellationToken);
var undoneActivitiesCount = await repositoryWrapper.SetRepository<Domain.Entities.Tasks.Activity>() var undoneActivitiesCount = await _repositoryWrapper.SetRepository<Domain.Entities.Tasks.Activity>()
.TableNoTracking .TableNoTracking
.CountAsync(a => a.Status == ActivityStatus.UnDone && a.SetFor.Date == selectedDate.Date && a.ShiftPlanId == existedShiftPlan.Id, cancellationToken); .CountAsync(a => a.Status == ActivityStatus.UnDone && a.SetFor.Date == selectedDate.Date && a.ShiftPlanId == existedShiftPlan.Id, cancellationToken);
shift.UndoneActivitiesCount = undoneActivitiesCount; shift.UndoneActivitiesCount = undoneActivitiesCount;
shift.DoneActivitiesCount = doneActivitiesCount; shift.DoneActivitiesCount = doneActivitiesCount;
shift.TotalActivitiesCount = activitiesCount; shift.TotalActivitiesCount = activitiesCount;
switch (currentUserService.RoleName) switch (_currentUserService.RoleName)
{ {
case null: case null:
continue; continue;
case ApplicationRoles.SuperVisor: case ApplicationRoles.SuperVisor:
{ {
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");
var existedSupervisorShiftPlan = await repositoryWrapper.SetRepository<ShiftPlan>() var existedSupervisorShiftPlan = await _repositoryWrapper.SetRepository<ShiftPlan>()
.TableNoTracking .TableNoTracking
.FirstOrDefaultAsync(s => s.ShiftId == shift.Id && s.PlanFor.Date == selectedDate.Date && s.SupervisorId == userId, cancellationToken); .FirstOrDefaultAsync(s => s.ShiftId == shift.Id && s.PlanFor.Date == selectedDate.Date && s.SupervisorId == userId, cancellationToken);
shift.IsCompleted = existedSupervisorShiftPlan?.IsCompleted ?? false; shift.IsCompleted = existedSupervisorShiftPlan?.IsCompleted ?? false;
@ -75,9 +84,9 @@ public class GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper, Use
else else
{ {
shifts = await repositoryWrapper.SetRepository<Shift>().TableNoTracking shifts = await _repositoryWrapper.SetRepository<Shift>().TableNoTracking
.Where(s => s.ComplexId == complexId) .Where(s => s.ComplexId == complexId)
.OrderBy(s => s.StartAt) .OrderByDescending(s => s.StartAt)
.Skip(request.Page * 15).Take(15) .Skip(request.Page * 15).Take(15)
.Select(ShiftMapper.ProjectToSDto) .Select(ShiftMapper.ProjectToSDto)
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);

View File

@ -1,27 +1,24 @@
using Brizco.Domain.Entities.Tasks; namespace Brizco.Repository.Handlers.Tasks;
namespace Brizco.Repository.Handlers.Tasks; public class GetActivitiesQueryHandler : IRequestHandler<GetTasksQuery, List<TaskSDto>>
public class GetActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService) : IRequestHandler<GetTasksQuery, List<TaskSDto>>
{ {
private readonly IRepositoryWrapper _repositoryWrapper;
private readonly ICurrentUserService _currentUserService;
public GetActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
{
_repositoryWrapper = repositoryWrapper;
_currentUserService = currentUserService;
}
public async Task<List<TaskSDto>> Handle(GetTasksQuery request, CancellationToken cancellationToken) public async Task<List<TaskSDto>> Handle(GetTasksQuery request, CancellationToken cancellationToken)
{ {
if (currentUserService.ComplexId == null) if (_currentUserService.ComplexId == null)
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);
var query = repositoryWrapper.SetRepository<Domain.Entities.Tasks.Task>().TableNoTracking
.Where(t => t.ComplexId == complexId && t.IsActivity == false);
if (request.ShiftId != null) var tasks = await _repositoryWrapper.SetRepository<Domain.Entities.Tasks.Task>().TableNoTracking
query = from taskShift in repositoryWrapper.SetRepository<TaskShift>().TableNoTracking .Where(t=>t.ComplexId==complexId && t.IsActivity == false)
where taskShift.ShiftId == request.ShiftId
join task in query on taskShift.TaskId equals task.Id
select task;
query = query.Distinct();
var tasks = await query
.OrderByDescending(s => s.CreatedAt) .OrderByDescending(s => s.CreatedAt)
.Skip(request.Page * 15).Take(15) .Skip(request.Page * 15).Take(15)
.Select(TaskMapper.ProjectToSDto) .Select(TaskMapper.ProjectToSDto)

View File

@ -1,106 +0,0 @@
using MD.PersianDateTime.Standard;
using Activity = Brizco.Domain.Entities.Tasks.Activity;
namespace Brizco.Repository.Handlers.Users;
public class GetStaffQueryHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService) : IRequestHandler<GetStaffQuery,List<StaffResponseSDto>>
{
public async Task<List<StaffResponseSDto>> Handle(GetStaffQuery request, CancellationToken cancellationToken)
{
var count = request.Count ?? 10;
if (currentUserService.ComplexId == null)
throw new AppException("ComplexId is null", ApiResultStatusCode.NotFound);
if (!Guid.TryParse(currentUserService.ComplexId, out Guid complexId))
throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound);
var baseQuery = repositoryWrapper.SetRepository<Activity>()
.TableNoTracking
.OrderByDescending(s => s.CreatedAt)
.Where(s => s.ComplexId == complexId);
List<ActivitySDto> activities = new List<ActivitySDto>();
switch (request.DateTimeQuery)
{
case DateTimeQueryFilter.Today:
activities = await baseQuery.Where(s => s.SetFor.Date == DateTime.Now.Date)
.Skip(request.Page * count).Take(count)
.Select(ActivityMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
break;
case DateTimeQueryFilter.Yesterday:
activities = await baseQuery.Where(s => s.SetFor.Date == DateTime.Now.AddDays(-1).Date)
.Skip(request.Page * count).Take(count)
.Select(ActivityMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
break;
case DateTimeQueryFilter.PastWeek:
DateTime pastWeekToday = DateTime.Today;
int pastWeekDelta = DayOfWeek.Saturday - pastWeekToday.DayOfWeek;
if (pastWeekDelta > 0) pastWeekDelta -= 7;
DateTime startOfPastWeek = DateTime.Today.AddDays(pastWeekDelta).AddDays(-7);
DateTime endOfPastWeek = startOfPastWeek.AddDays(6);
activities = await baseQuery.Where(s => s.SetFor.Date >= startOfPastWeek.Date && s.SetFor.Date <= endOfPastWeek.Date)
.OrderByDescending(s => s.CreatedAt)
.Select(ActivityMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
break;
case DateTimeQueryFilter.NextWeek:
DateTime startOfNextWeek = DateTime.Today.AddDays(7 - (int)DateTime.Today.DayOfWeek + 1);
DateTime endOfNextWeek = startOfNextWeek.AddDays(6);
activities = await baseQuery.Where(s => s.SetFor.Date >= startOfNextWeek.Date && s.SetFor.Date <= endOfNextWeek.Date)
.OrderByDescending(s => s.CreatedAt)
.Select(ActivityMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
break;
case DateTimeQueryFilter.ThisWeek:
DateTime today = DateTime.Today;
int delta = DayOfWeek.Saturday - today.DayOfWeek;
if (delta > 0) delta -= 7;
DateTime startOfWeek = today.AddDays(delta);
DateTime endOfWeek = startOfWeek.AddDays(6);
activities = await baseQuery.Where(s => s.SetFor.Date >= startOfWeek.Date && s.SetFor.Date <= endOfWeek.Date)
.OrderByDescending(s => s.CreatedAt)
.Select(ActivityMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
break;
case DateTimeQueryFilter.PastMonth:
DateTime startOfPastMonth = new PersianDateTime(PersianDateTime.Today.AddMonths(-1).Year, PersianDateTime.Today.AddMonths(-1).Month, 1).ToDateTime();
DateTime endOfPastMonth = startOfPastMonth.AddMonths(1);
activities = await baseQuery.Where(s => s.SetFor.Date >= startOfPastMonth.Date && s.SetFor.Date < endOfPastMonth.Date)
.OrderByDescending(s => s.CreatedAt)
.Select(ActivityMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
break;
case DateTimeQueryFilter.NextMonth:
DateTime startOfNextMonth = new PersianDateTime(PersianDateTime.Today.AddMonths(1).Year, PersianDateTime.Today.AddMonths(1).Month, 1).ToDateTime();
DateTime endOfNextMonth = startOfNextMonth.AddMonths(1);
activities = await baseQuery.Where(s => s.SetFor.Date >= startOfNextMonth.Date && s.SetFor.Date < endOfNextMonth.Date)
.OrderByDescending(s => s.CreatedAt)
.Select(ActivityMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
break;
case DateTimeQueryFilter.ThisMonth:
DateTime startOfThisMonth = new PersianDateTime(PersianDateTime.Today.Year, PersianDateTime.Today.Month, 1).ToDateTime();
DateTime endOfThisMonth = startOfThisMonth.AddMonths(1);
activities = await baseQuery.Where(s => s.SetFor.Date >= startOfThisMonth.Date && s.SetFor.Date < endOfThisMonth.Date)
.OrderByDescending(s => s.CreatedAt)
.Select(ActivityMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
break;
default:
throw new ArgumentOutOfRangeException();
}
var staffs = activities.Select(a => new StaffResponseSDto
{
FirstName = a.UserFirstName,
LastName = a.UserLastName,
Id = a.UserId
}).ToList();
return staffs.DistinctBy(d => d.Id).ToList();
}
}

View File

@ -1,20 +0,0 @@
namespace Brizco.Repository.MartenHandlers.NewsFeeds;
public class ChangeNewsFeedPinCommandHandler(IMartenRepositoryWrapper martenRepositoryWrapper, ICurrentUserService currentUserService)
: IRequestHandler<ChangeNewsFeedPinCommand, bool>
{
public async Task<bool> Handle(ChangeNewsFeedPinCommand request, CancellationToken cancellationToken)
{
if (currentUserService.ComplexId == null)
throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is null");
if (!Guid.TryParse(currentUserService.ComplexId, out Guid complexId))
throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong");
var ent = await martenRepositoryWrapper.SetRepository<NewsFeed>().GetEntityAsync(request.Id, cancellationToken);
if (ent.ComplexId != complexId)
throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong");
ent.IsPin = request.IsPin;
await martenRepositoryWrapper.SetRepository<NewsFeed>().AddOrUpdateEntityAsync(ent, cancellationToken);
return true;
}
}

View File

@ -1,23 +0,0 @@
namespace Brizco.Repository.MartenHandlers.NewsFeeds;
public class CreateNewsFeedCommandHandler (IMartenRepositoryWrapper martenRepositoryWrapper , ICurrentUserService currentUserService)
: IRequestHandler<CreateNewsFeedCommand,Guid>
{
public async Task<Guid> Handle(CreateNewsFeedCommand request, CancellationToken cancellationToken)
{
if (currentUserService.ComplexId == null)
throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is null");
if (!Guid.TryParse(currentUserService.ComplexId, out Guid complexId))
throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong");
var newsFeed = new NewsFeed
{
ComplexId = complexId,
Content = request.Content,
Title = request.Title,
IsPin = request.IsPin
};
await martenRepositoryWrapper.SetRepository<NewsFeed>().AddOrUpdateEntityAsync(newsFeed, cancellationToken);
return newsFeed.Id;
}
}

View File

@ -1,19 +0,0 @@
namespace Brizco.Repository.MartenHandlers.NewsFeeds;
public class DeleteNewsFeedCommandHandler(IMartenRepositoryWrapper martenRepositoryWrapper, ICurrentUserService currentUserService)
: IRequestHandler<DeleteNewsFeedCommand, bool>
{
public async Task<bool> Handle(DeleteNewsFeedCommand request, CancellationToken cancellationToken)
{
if (currentUserService.ComplexId == null)
throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is null");
if (!Guid.TryParse(currentUserService.ComplexId, out Guid complexId))
throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong");
var ent = await martenRepositoryWrapper.SetRepository<NewsFeed>().GetEntityAsync(request.Id, cancellationToken);
if (ent.ComplexId != complexId)
throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong");
await martenRepositoryWrapper.SetRepository<NewsFeed>().RemoveEntityAsync(ent, cancellationToken);
return true;
}
}

View File

@ -1,22 +0,0 @@
namespace Brizco.Repository.MartenHandlers.NewsFeeds;
public class GetNewsFeedsQueryHandler (IMartenRepositoryWrapper martenRepositoryWrapper,ICurrentUserService currentUserService) : IRequestHandler<GetNewsFeedsQuery,List<NewsFeed>>
{
public async Task<List<NewsFeed>> Handle(GetNewsFeedsQuery request, CancellationToken cancellationToken)
{
if (currentUserService.ComplexId == null)
throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is null");
if (!Guid.TryParse(currentUserService.ComplexId, out Guid complexId))
throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong");
var count = request.Count ?? 5;
var query = await martenRepositoryWrapper.SetRepository<NewsFeed>()
.GetQueryAsync(q=>q.ComplexId == complexId);
query = query.Skip(request.Page * count)
.Take(count)
.OrderByDescending(c=>c.CreatedAt);
return await query.ToListAsync(cancellationToken);
}
}

View File

@ -1,13 +1,22 @@
namespace Brizco.Repository.MartenHandlers.Notifications; using Brizco.Domain.MartenEntities.Notifications;
public class CreateNotificationHandlerCommand(IMartenRepositoryWrapper martenRepositoryWrapper, ICurrentUserService currentUserService) namespace Brizco.Repository.MartenHandlers.Notifications;
: IRequestHandler<CreateNotificationCommand,Guid>
public class CreateNotificationHandlerCommand : IRequestHandler<CreateNotificationCommand,Guid>
{ {
private readonly IMartenRepositoryWrapper _martenRepositoryWrapper;
private readonly ICurrentUserService _currentUserService;
public CreateNotificationHandlerCommand(IMartenRepositoryWrapper martenRepositoryWrapper, ICurrentUserService currentUserService)
{
_martenRepositoryWrapper = martenRepositoryWrapper;
_currentUserService = currentUserService;
}
public async Task<Guid> Handle(CreateNotificationCommand request, CancellationToken cancellationToken) public async Task<Guid> Handle(CreateNotificationCommand request, CancellationToken cancellationToken)
{ {
if (currentUserService.ComplexId == null) if (_currentUserService.ComplexId == null)
throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is null"); throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is null");
if (!Guid.TryParse(currentUserService.ComplexId, out Guid complexId)) if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong"); throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong");
var notification = new Notification var notification = new Notification
{ {
@ -17,7 +26,7 @@ public class CreateNotificationHandlerCommand(IMartenRepositoryWrapper martenRep
CreatedAt = DateTime.Now CreatedAt = DateTime.Now
}; };
await martenRepositoryWrapper.SetRepository<Notification>() await _martenRepositoryWrapper.SetRepository<Notification>()
.AddOrUpdateEntityAsync(notification, cancellationToken); .AddOrUpdateEntityAsync(notification, cancellationToken);
return notification.Id; return notification.Id;
} }

View File

@ -1,25 +0,0 @@
namespace Brizco.Repository.MartenHandlers.Notifications;
public class GetNotificationsCountQueryHandler(IMartenRepositoryWrapper martenRepositoryWrapper,ICurrentUserService currentUserService) : IRequestHandler<GetNotificationsCountQuery,int>
{
public async Task<int> Handle(GetNotificationsCountQuery request, CancellationToken cancellationToken)
{
if (currentUserService.ComplexId == null)
throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is null");
if (!Guid.TryParse(currentUserService.ComplexId, out Guid complexId))
throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong");
Guid userId;
if (currentUserService.UserId == null)
throw new BaseApiException(ApiResultStatusCode.BadRequest, "User id is null");
if (!Guid.TryParse(currentUserService.UserId, out userId))
throw new BaseApiException(ApiResultStatusCode.BadRequest, "User id is wrong");
var notifications = await martenRepositoryWrapper.SetRepository<Notification>()
.GetEntitiesAsync(n => n.ComplexId == complexId && n.UserId == userId && !n.IsRead, cancellationToken);
return notifications.Count;
}
}

View File

@ -1,37 +1,44 @@
namespace Brizco.Repository.MartenHandlers.Notifications; using Brizco.Domain.MartenEntities.Notifications;
public class GetNotificationsQueryHandler(IMartenRepositoryWrapper martenRepositoryWrapper, ICurrentUserService currentUserService) : IRequestHandler<GetNotificationsQuery,List<Notification>> namespace Brizco.Repository.MartenHandlers.Notifications;
public class GetNotificationsQueryHandler : IRequestHandler<GetNotificationsQuery,List<Notification>>
{ {
private readonly IMartenRepositoryWrapper _martenRepositoryWrapper;
private readonly ICurrentUserService _currentUserService;
public GetNotificationsQueryHandler(IMartenRepositoryWrapper martenRepositoryWrapper,ICurrentUserService currentUserService)
{
_martenRepositoryWrapper = martenRepositoryWrapper;
_currentUserService = currentUserService;
}
public async Task<List<Notification>> Handle(GetNotificationsQuery request, CancellationToken cancellationToken) public async Task<List<Notification>> Handle(GetNotificationsQuery request, CancellationToken cancellationToken)
{ {
if (currentUserService.ComplexId == null) if (_currentUserService.ComplexId == null)
throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is null"); throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is null");
if (!Guid.TryParse(currentUserService.ComplexId, out Guid complexId)) if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong"); throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong");
if (request.UserId == default)
throw new BaseApiException(ApiResultStatusCode.BadRequest, "User id is null");
Guid userId; Guid userId;
if (request.UserId == null) if (request.UserId == null)
{ {
if (currentUserService.UserId == null) if (_currentUserService.UserId == null)
throw new BaseApiException(ApiResultStatusCode.BadRequest, "User id is null"); throw new BaseApiException(ApiResultStatusCode.BadRequest, "User id is null");
if (!Guid.TryParse(currentUserService.UserId, out userId)) if (!Guid.TryParse(_currentUserService.UserId, out userId))
throw new BaseApiException(ApiResultStatusCode.BadRequest, "User id is wrong"); throw new BaseApiException(ApiResultStatusCode.BadRequest, "User id is wrong");
} }
else else
userId = request.UserId.Value; userId = request.UserId.Value;
if (userId == default) var notifications = await _martenRepositoryWrapper.SetRepository<Notification>()
throw new BaseApiException(ApiResultStatusCode.BadRequest, "User id is null"); .GetQueryAsync(n => n.ComplexId == complexId && n.UserId == userId);
var response = await notifications.Take(new Range(request.Page * request.Count, (request.Page * request.Count) + request.Count))
.ToListAsync(cancellationToken);
var count = request.Count ?? 10;
var notifications = await martenRepositoryWrapper.SetRepository<Notification>()
.GetEntitiesAsync(n => n.ComplexId == complexId && n.UserId == userId,cancellationToken);
var response = notifications.OrderByDescending(n=>n.CreatedAt)
.Take(new Range(request.Page * count, (request.Page * count) + count))
.ToList();
return response; return response;
} }
} }

View File

@ -1,31 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Brizco.Repository.Migrations
{
/// <inheritdoc />
public partial class EditShiftPlanAddIsScheduled : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsScheduled",
schema: "public",
table: "ShiftPlans",
type: "boolean",
nullable: false,
defaultValue: false);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsScheduled",
schema: "public",
table: "ShiftPlans");
}
}
}

View File

@ -18,12 +18,12 @@ namespace Brizco.Repository.Migrations
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasDefaultSchema("public") .HasDefaultSchema("public")
.HasAnnotation("ProductVersion", "8.0.6") .HasAnnotation("ProductVersion", "8.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 63); .HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Complex", b => modelBuilder.Entity("Brizco.Domain.Entities.Complex.Complex", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -70,7 +70,7 @@ namespace Brizco.Repository.Migrations
b.ToTable("Complexes", "public"); b.ToTable("Complexes", "public");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Complexes.ComplexUser", b => modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -115,7 +115,7 @@ namespace Brizco.Repository.Migrations
b.ToTable("ComplexUsers", "public"); b.ToTable("ComplexUsers", "public");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Complexes.ComplexUserRole", b => modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUserRole", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -160,7 +160,7 @@ namespace Brizco.Repository.Migrations
b.ToTable("ComplexUserRoles", "public"); b.ToTable("ComplexUserRoles", "public");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Position", b => modelBuilder.Entity("Brizco.Domain.Entities.Complex.Position", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -213,7 +213,7 @@ namespace Brizco.Repository.Migrations
b.ToTable("Positions", "public"); b.ToTable("Positions", "public");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Complexes.PositionPermission", b => modelBuilder.Entity("Brizco.Domain.Entities.Complex.PositionPermission", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -257,7 +257,7 @@ namespace Brizco.Repository.Migrations
b.ToTable("PositionPermissions", "public"); b.ToTable("PositionPermissions", "public");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Section", b => modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -305,7 +305,7 @@ namespace Brizco.Repository.Migrations
b.ToTable("Sections", "public"); b.ToTable("Sections", "public");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Routines.Routine", b => modelBuilder.Entity("Brizco.Domain.Entities.Routine.Routine", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -353,128 +353,7 @@ namespace Brizco.Repository.Migrations
b.ToTable("Routines", "public"); b.ToTable("Routines", "public");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlans.ShiftPlan", b => modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CompleteDescription")
.IsRequired()
.HasColumnType("text");
b.Property<int>("CompletePercent")
.HasColumnType("integer");
b.Property<Guid>("ComplexId")
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsCompleted")
.HasColumnType("boolean");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<bool>("IsScheduled")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("PlanFor")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("RoutineId")
.HasColumnType("uuid");
b.Property<Guid>("ShiftId")
.HasColumnType("uuid");
b.Property<Guid>("SupervisorId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ComplexId");
b.HasIndex("RoutineId");
b.HasIndex("ShiftId");
b.HasIndex("SupervisorId");
b.ToTable("ShiftPlans", "public");
});
modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlans.ShiftPlanUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("PositionId")
.HasColumnType("uuid");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ShiftPlanId")
.HasColumnType("uuid");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("PositionId");
b.HasIndex("ShiftPlanId");
b.HasIndex("UserId");
b.ToTable("ShiftPlanUsers", "public");
});
modelBuilder.Entity("Brizco.Domain.Entities.Shifts.Shift", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -528,7 +407,7 @@ namespace Brizco.Repository.Migrations
b.ToTable("Shifts", "public"); b.ToTable("Shifts", "public");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Shifts.ShiftDay", b => modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftDay", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -571,7 +450,125 @@ namespace Brizco.Repository.Migrations
b.ToTable("ShiftDays", "public"); b.ToTable("ShiftDays", "public");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Shifts.ShiftRoutine", b => modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CompleteDescription")
.IsRequired()
.HasColumnType("text");
b.Property<int>("CompletePercent")
.HasColumnType("integer");
b.Property<Guid>("ComplexId")
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsCompleted")
.HasColumnType("boolean");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("PlanFor")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("RoutineId")
.HasColumnType("uuid");
b.Property<Guid>("ShiftId")
.HasColumnType("uuid");
b.Property<Guid>("SupervisorId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ComplexId");
b.HasIndex("RoutineId");
b.HasIndex("ShiftId");
b.HasIndex("SupervisorId");
b.ToTable("ShiftPlans", "public");
});
modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("PositionId")
.HasColumnType("uuid");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ShiftPlanId")
.HasColumnType("uuid");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("PositionId");
b.HasIndex("ShiftPlanId");
b.HasIndex("UserId");
b.ToTable("ShiftPlanUsers", "public");
});
modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftRoutine", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -616,7 +613,7 @@ namespace Brizco.Repository.Migrations
b.ToTable("ShiftRoutines", "public"); b.ToTable("ShiftRoutines", "public");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Tasks.Task", b => modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -697,7 +694,7 @@ namespace Brizco.Repository.Migrations
b.UseTphMappingStrategy(); b.UseTphMappingStrategy();
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskDay", b => modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskDay", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -740,7 +737,7 @@ namespace Brizco.Repository.Migrations
b.ToTable("TaskDays", "public"); b.ToTable("TaskDays", "public");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskPosition", b => modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskPosition", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -785,7 +782,7 @@ namespace Brizco.Repository.Migrations
b.ToTable("TaskPositions", "public"); b.ToTable("TaskPositions", "public");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskRoutine", b => modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskRoutine", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -830,7 +827,7 @@ namespace Brizco.Repository.Migrations
b.ToTable("TaskRoutines", "public"); b.ToTable("TaskRoutines", "public");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskShift", b => modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskShift", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -875,7 +872,7 @@ namespace Brizco.Repository.Migrations
b.ToTable("TaskShifts", "public"); b.ToTable("TaskShifts", "public");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Users.ApplicationRole", b => modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationRole", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -919,7 +916,7 @@ namespace Brizco.Repository.Migrations
b.ToTable("Roles", "public"); b.ToTable("Roles", "public");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Users.ApplicationUser", b => modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationUser", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -1111,9 +1108,9 @@ namespace Brizco.Repository.Migrations
b.ToTable("Tokens", "public"); b.ToTable("Tokens", "public");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Tasks.Activity", b => modelBuilder.Entity("Brizco.Domain.Entities.Task.Activity", b =>
{ {
b.HasBaseType("Brizco.Domain.Entities.Tasks.Task"); b.HasBaseType("Brizco.Domain.Entities.Task.Task");
b.Property<DateTime>("DoneAt") b.Property<DateTime>("DoneAt")
.HasColumnType("timestamp without time zone"); .HasColumnType("timestamp without time zone");
@ -1145,14 +1142,14 @@ namespace Brizco.Repository.Migrations
b.HasDiscriminator().HasValue("Activity"); b.HasDiscriminator().HasValue("Activity");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Complexes.ComplexUser", b => modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex")
.WithMany("Users") .WithMany("Users")
.HasForeignKey("ComplexId") .HasForeignKey("ComplexId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", "User") b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User")
.WithMany() .WithMany()
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
@ -1162,14 +1159,14 @@ namespace Brizco.Repository.Migrations
b.Navigation("User"); b.Navigation("User");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Complexes.ComplexUserRole", b => modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUserRole", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Complexes.ComplexUser", "ComplexUser") b.HasOne("Brizco.Domain.Entities.Complex.ComplexUser", "ComplexUser")
.WithMany("Roles") .WithMany("Roles")
.HasForeignKey("ComplexUserId") .HasForeignKey("ComplexUserId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Users.ApplicationRole", "Role") b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", "Role")
.WithMany() .WithMany()
.HasForeignKey("RoleId") .HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
@ -1179,14 +1176,14 @@ namespace Brizco.Repository.Migrations
b.Navigation("Role"); b.Navigation("Role");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Position", b => modelBuilder.Entity("Brizco.Domain.Entities.Complex.Position", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex")
.WithMany() .WithMany()
.HasForeignKey("ComplexId") .HasForeignKey("ComplexId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Complexes.Section", "Section") b.HasOne("Brizco.Domain.Entities.Complex.Section", "Section")
.WithMany("Positions") .WithMany("Positions")
.HasForeignKey("SectionId") .HasForeignKey("SectionId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
@ -1196,9 +1193,9 @@ namespace Brizco.Repository.Migrations
b.Navigation("Section"); b.Navigation("Section");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Complexes.PositionPermission", b => modelBuilder.Entity("Brizco.Domain.Entities.Complex.PositionPermission", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Complexes.Position", "Position") b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position")
.WithMany("Permissions") .WithMany("Permissions")
.HasForeignKey("PositionId") .HasForeignKey("PositionId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
@ -1206,9 +1203,9 @@ namespace Brizco.Repository.Migrations
b.Navigation("Position"); b.Navigation("Position");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Section", b => modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex")
.WithMany() .WithMany()
.HasForeignKey("ComplexId") .HasForeignKey("ComplexId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
@ -1216,9 +1213,9 @@ namespace Brizco.Repository.Migrations
b.Navigation("Complex"); b.Navigation("Complex");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Routines.Routine", b => modelBuilder.Entity("Brizco.Domain.Entities.Routine.Routine", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex")
.WithMany() .WithMany()
.HasForeignKey("ComplexId") .HasForeignKey("ComplexId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
@ -1226,24 +1223,44 @@ namespace Brizco.Repository.Migrations
b.Navigation("Complex"); b.Navigation("Complex");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlans.ShiftPlan", b => modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex")
.WithMany("Shifts")
.HasForeignKey("ComplexId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Complex");
});
modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftDay", b =>
{
b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift")
.WithMany("Days")
.HasForeignKey("ShiftId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Shift");
});
modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b =>
{
b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex")
.WithMany() .WithMany()
.HasForeignKey("ComplexId") .HasForeignKey("ComplexId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Routines.Routine", "Routine") b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine")
.WithMany() .WithMany()
.HasForeignKey("RoutineId") .HasForeignKey("RoutineId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Shifts.Shift", "Shift") b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift")
.WithMany("Plans") .WithMany("Plans")
.HasForeignKey("ShiftId") .HasForeignKey("ShiftId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", "Supervisor") b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "Supervisor")
.WithMany() .WithMany()
.HasForeignKey("SupervisorId") .HasForeignKey("SupervisorId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
@ -1257,19 +1274,19 @@ namespace Brizco.Repository.Migrations
b.Navigation("Supervisor"); b.Navigation("Supervisor");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlans.ShiftPlanUser", b => modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Complexes.Position", "Position") b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position")
.WithMany() .WithMany()
.HasForeignKey("PositionId") .HasForeignKey("PositionId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.ShiftPlans.ShiftPlan", "ShiftPlan") b.HasOne("Brizco.Domain.Entities.Shift.ShiftPlan", "ShiftPlan")
.WithMany("Users") .WithMany("Users")
.HasForeignKey("ShiftPlanId") .HasForeignKey("ShiftPlanId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", "User") b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User")
.WithMany() .WithMany()
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
@ -1281,34 +1298,14 @@ namespace Brizco.Repository.Migrations
b.Navigation("User"); b.Navigation("User");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Shifts.Shift", b => modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftRoutine", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine")
.WithMany("Shifts")
.HasForeignKey("ComplexId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Complex");
});
modelBuilder.Entity("Brizco.Domain.Entities.Shifts.ShiftDay", b =>
{
b.HasOne("Brizco.Domain.Entities.Shifts.Shift", "Shift")
.WithMany("Days")
.HasForeignKey("ShiftId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Shift");
});
modelBuilder.Entity("Brizco.Domain.Entities.Shifts.ShiftRoutine", b =>
{
b.HasOne("Brizco.Domain.Entities.Routines.Routine", "Routine")
.WithMany("Shifts") .WithMany("Shifts")
.HasForeignKey("RoutineId") .HasForeignKey("RoutineId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Shifts.Shift", "Shift") b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift")
.WithMany("Routines") .WithMany("Routines")
.HasForeignKey("ShiftId") .HasForeignKey("ShiftId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
@ -1318,9 +1315,9 @@ namespace Brizco.Repository.Migrations
b.Navigation("Shift"); b.Navigation("Shift");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Tasks.Task", b => modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex")
.WithMany("Tasks") .WithMany("Tasks")
.HasForeignKey("ComplexId") .HasForeignKey("ComplexId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
@ -1328,9 +1325,9 @@ namespace Brizco.Repository.Migrations
b.Navigation("Complex"); b.Navigation("Complex");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskDay", b => modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskDay", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Tasks.Task", "Task") b.HasOne("Brizco.Domain.Entities.Task.Task", "Task")
.WithMany("Days") .WithMany("Days")
.HasForeignKey("TaskId") .HasForeignKey("TaskId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
@ -1338,14 +1335,14 @@ namespace Brizco.Repository.Migrations
b.Navigation("Task"); b.Navigation("Task");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskPosition", b => modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskPosition", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Complexes.Position", "Position") b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position")
.WithMany() .WithMany()
.HasForeignKey("PositionId") .HasForeignKey("PositionId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Tasks.Task", "Task") b.HasOne("Brizco.Domain.Entities.Task.Task", "Task")
.WithMany("Positions") .WithMany("Positions")
.HasForeignKey("TaskId") .HasForeignKey("TaskId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
@ -1355,14 +1352,14 @@ namespace Brizco.Repository.Migrations
b.Navigation("Task"); b.Navigation("Task");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskRoutine", b => modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskRoutine", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Routines.Routine", "Routine") b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine")
.WithMany("Tasks") .WithMany("Tasks")
.HasForeignKey("RoutineId") .HasForeignKey("RoutineId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Tasks.Task", "Task") b.HasOne("Brizco.Domain.Entities.Task.Task", "Task")
.WithMany("Routines") .WithMany("Routines")
.HasForeignKey("TaskId") .HasForeignKey("TaskId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
@ -1372,14 +1369,14 @@ namespace Brizco.Repository.Migrations
b.Navigation("Task"); b.Navigation("Task");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskShift", b => modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskShift", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Shifts.Shift", "Shift") b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift")
.WithMany() .WithMany()
.HasForeignKey("ShiftId") .HasForeignKey("ShiftId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Tasks.Task", "Task") b.HasOne("Brizco.Domain.Entities.Task.Task", "Task")
.WithMany("Shifts") .WithMany("Shifts")
.HasForeignKey("TaskId") .HasForeignKey("TaskId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
@ -1389,9 +1386,9 @@ namespace Brizco.Repository.Migrations
b.Navigation("Task"); b.Navigation("Task");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Users.ApplicationRole", b => modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationRole", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex")
.WithMany("Roles") .WithMany("Roles")
.HasForeignKey("ComplexId"); .HasForeignKey("ComplexId");
@ -1400,7 +1397,7 @@ namespace Brizco.Repository.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b => modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Users.ApplicationRole", null) b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", null)
.WithMany() .WithMany()
.HasForeignKey("RoleId") .HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
@ -1408,7 +1405,7 @@ namespace Brizco.Repository.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b => modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", null) b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null)
.WithMany() .WithMany()
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
@ -1416,7 +1413,7 @@ namespace Brizco.Repository.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b => modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", null) b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null)
.WithMany() .WithMany()
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
@ -1424,12 +1421,12 @@ namespace Brizco.Repository.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b => modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Users.ApplicationRole", null) b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", null)
.WithMany() .WithMany()
.HasForeignKey("RoleId") .HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", null) b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null)
.WithMany() .WithMany()
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
@ -1437,20 +1434,20 @@ namespace Brizco.Repository.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b => modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", null) b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null)
.WithMany() .WithMany()
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Tasks.Activity", b => modelBuilder.Entity("Brizco.Domain.Entities.Task.Activity", b =>
{ {
b.HasOne("Brizco.Domain.Entities.ShiftPlans.ShiftPlan", "ShiftPlan") b.HasOne("Brizco.Domain.Entities.Shift.ShiftPlan", "ShiftPlan")
.WithMany() .WithMany()
.HasForeignKey("ShiftPlanId") .HasForeignKey("ShiftPlanId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", "User") b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User")
.WithMany() .WithMany()
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
@ -1460,7 +1457,7 @@ namespace Brizco.Repository.Migrations
b.Navigation("User"); b.Navigation("User");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Complex", b => modelBuilder.Entity("Brizco.Domain.Entities.Complex.Complex", b =>
{ {
b.Navigation("Roles"); b.Navigation("Roles");
@ -1471,34 +1468,29 @@ namespace Brizco.Repository.Migrations
b.Navigation("Users"); b.Navigation("Users");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Complexes.ComplexUser", b => modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b =>
{ {
b.Navigation("Roles"); b.Navigation("Roles");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Position", b => modelBuilder.Entity("Brizco.Domain.Entities.Complex.Position", b =>
{ {
b.Navigation("Permissions"); b.Navigation("Permissions");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Section", b => modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b =>
{ {
b.Navigation("Positions"); b.Navigation("Positions");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Routines.Routine", b => modelBuilder.Entity("Brizco.Domain.Entities.Routine.Routine", b =>
{ {
b.Navigation("Shifts"); b.Navigation("Shifts");
b.Navigation("Tasks"); b.Navigation("Tasks");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlans.ShiftPlan", b => modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b =>
{
b.Navigation("Users");
});
modelBuilder.Entity("Brizco.Domain.Entities.Shifts.Shift", b =>
{ {
b.Navigation("Days"); b.Navigation("Days");
@ -1507,7 +1499,12 @@ namespace Brizco.Repository.Migrations
b.Navigation("Routines"); b.Navigation("Routines");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Tasks.Task", b => modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b =>
{
b.Navigation("Users");
});
modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b =>
{ {
b.Navigation("Days"); b.Navigation("Days");

View File

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- <configuration>
<config>
<add key='maxHttpRequestsPerSource' value='10' />
</config>
<packageSources>
<clear />
<add key="VnfRepos" value="https://packages.vnfco.ir/repository/nuget-group/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<packageSourceCredentials>
<VnfRepos>
<add key="Username" value="runner" />
<add key="ClearTextPassword" value="22102210aA" />
</VnfRepos>
</packageSourceCredentials>
</configuration> -->
<configuration>
<config>
<add key='maxHttpRequestsPerSource' value='10' />
</config>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>