diff --git a/.version b/.version
index 636ed6a..baba1a6 100644
--- a/.version
+++ b/.version
@@ -1 +1 @@
-1.0.1.2
\ No newline at end of file
+1.4.9.4
\ No newline at end of file
diff --git a/Brizco.Api/AppSettings/appsettings.Development.json b/Brizco.Api/AppSettings/appsettings.Development.json
index 1b5d28b..6b8b9ac 100644
--- a/Brizco.Api/AppSettings/appsettings.Development.json
+++ b/Brizco.Api/AppSettings/appsettings.Development.json
@@ -1,6 +1,7 @@
{
"ConnectionStrings": {
- "PostgresServer": "Host=185.220.227.123;port=5432;Username=postgres;Password=ub0J7sFFThkSBmkc0TzSKsCfheRnQpyu;Database=BrizcoDB",
+ "PostgresServer": "Host=185.220.227.126;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",
"MartenDB": "Host=pg-0;Username=postgres;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=BrizcoMartenDB;"
},
diff --git a/Brizco.Api/Brizco.Api.csproj b/Brizco.Api/Brizco.Api.csproj
index ad8afbf..c72375e 100644
--- a/Brizco.Api/Brizco.Api.csproj
+++ b/Brizco.Api/Brizco.Api.csproj
@@ -6,8 +6,8 @@
enable
Linux
..\docker-compose.dcproj
- 1.0.1.2
- 1.0.1.2
+ 1.4.9.4
+ 1.4.9.4
diff --git a/Brizco.Api/Controllers/ActivityController.cs b/Brizco.Api/Controllers/ActivityController.cs
index fc5ef20..da10f20 100644
--- a/Brizco.Api/Controllers/ActivityController.cs
+++ b/Brizco.Api/Controllers/ActivityController.cs
@@ -1,6 +1,4 @@
-using Brizco.Domain.Enums;
-
-namespace Brizco.Api.Controllers;
+namespace Brizco.Api.Controllers;
public class ActivityController : ICarterModule
{
@@ -12,7 +10,7 @@ public class ActivityController : ICarterModule
group.MapGet("", GetAllAsync)
.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);
group.MapGet("{id:guid}", GetAsync)
@@ -26,7 +24,7 @@ public class ActivityController : ICarterModule
.HasApiVersion(1.0);
group.MapPost("complete", CompleteActivityAsync)
- .WithDisplayName("DoneActivity")
+ .WithDisplayName("CompleteActivity")
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ChangeActivityStatus))
.HasApiVersion(1.0);
@@ -34,36 +32,35 @@ public class ActivityController : ICarterModule
.WithDisplayName("UnDoneActivity")
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ChangeActivityStatus))
.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
- public async Task GetAllAsync([FromQuery] int page, [FromQuery] DateQueryFilter? dateQueryFilter, [FromQuery] long? selectedDate, [FromQuery] Guid? selectedShiftPlanId, ISender sender, CancellationToken cancellationToken)
- => TypedResults.Ok(await sender.Send(new GetActivitiesQuery(Page: page, SelectedDate: selectedDate ?? 0 , SelectedShiftPlanId: selectedShiftPlanId ?? default , DateQueryFilter: dateQueryFilter ?? null), cancellationToken));
+ public async Task GetAllAsync([FromQuery] int page,
+ [FromQuery] DateTimeQueryFilter? dateQueryFilter,
+ [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
public async Task GetAsync(Guid id, IActivityService activityService, CancellationToken cancellationToken)
- => TypedResults.Ok(await activityService.DoneActivityAsync(id,cancellationToken));
+ => TypedResults.Ok(await activityService.DoneActivityAsync(id, cancellationToken));
- public async Task CompleteActivityAsync([FromBody]List requestDtos, [FromServices] IActivityService activityService, CancellationToken cancellationToken)
+ public async Task CompleteActivityAsync([FromBody] List requestDtos, [FromServices] IActivityService activityService, CancellationToken cancellationToken)
=> TypedResults.Ok(await activityService.CompleteActivitiesAsync(requestDtos, cancellationToken));
public async Task DoneActivityAsync(Guid id, [FromServices] IActivityService activityService, CancellationToken cancellationToken)
=> TypedResults.Ok(await activityService.DoneActivityAsync(id, cancellationToken));
- public async Task UnDoneActivityAsync(Guid id,[FromQuery]string undoneReason, [FromServices]IActivityService activityService, CancellationToken cancellationToken)
- => TypedResults.Ok(await activityService.UnDoneActivityAsync(id,undoneReason, cancellationToken));
+ public async Task UnDoneActivityAsync(Guid id, [FromQuery] string undoneReason, [FromServices] IActivityService activityService, CancellationToken cancellationToken)
+ => TypedResults.Ok(await activityService.UnDoneActivityAsync(id, undoneReason, cancellationToken));
//// POST:Create Entity
//public async Task Post([FromQuery]Guid shiftPlanId,IActivityService activityService, CancellationToken cancellationToken)
diff --git a/Brizco.Api/Controllers/NewsFeedController.cs b/Brizco.Api/Controllers/NewsFeedController.cs
new file mode 100644
index 0000000..0c4da3d
--- /dev/null
+++ b/Brizco.Api/Controllers/NewsFeedController.cs
@@ -0,0 +1,38 @@
+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));
+}
\ No newline at end of file
diff --git a/Brizco.Api/Controllers/NotificationController.cs b/Brizco.Api/Controllers/NotificationController.cs
index 668b6b9..4234bca 100644
--- a/Brizco.Api/Controllers/NotificationController.cs
+++ b/Brizco.Api/Controllers/NotificationController.cs
@@ -13,6 +13,12 @@ public class NotificationController : ICarterModule
.RequireAuthorization(builder=>builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser())
.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)
.WithDisplayName("Read Notification")
.WithDescription("Read notification , by JWT user id")
@@ -24,7 +30,10 @@ public class NotificationController : ICarterModule
private async Task ReadNotificationAsync([FromRoute] Guid id, [FromServices] IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new ReadNotificationCommand(id), cancellationToken));
- private async Task GetUserNotificationsAsync([FromQuery] int page, [FromQuery] int count,
+ private async Task GetUserNotificationsAsync([FromQuery] int page, [FromQuery] int? count,
[FromServices] IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new GetNotificationsQuery(page, count), cancellationToken));
+
+ private async Task GetUserNotificationsCountAsync([FromServices] IMediator mediator, CancellationToken cancellationToken)
+ => TypedResults.Ok(await mediator.Send(new GetNotificationsCountQuery(), cancellationToken));
}
\ No newline at end of file
diff --git a/Brizco.Api/Controllers/ShiftPlanController.cs b/Brizco.Api/Controllers/ShiftPlanController.cs
index d203047..4a76816 100644
--- a/Brizco.Api/Controllers/ShiftPlanController.cs
+++ b/Brizco.Api/Controllers/ShiftPlanController.cs
@@ -1,6 +1,4 @@
-using Brizco.Domain.Enums;
-
-namespace Brizco.Api.Controllers;
+namespace Brizco.Api.Controllers;
public class ShiftPlanController : ICarterModule
{
@@ -32,6 +30,7 @@ public class ShiftPlanController : ICarterModule
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageShiftPlans))
.HasApiVersion(1.0);
+
group.MapPost("", Post)
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageShiftPlans))
.HasApiVersion(1.0);
@@ -54,7 +53,10 @@ public class ShiftPlanController : ICarterModule
// GET:Get All Entity
- public async Task GetAllAsync([FromQuery] int page, [FromQuery] long? selectedDate, [FromQuery] DateTimeQueryFilter? dateFilter , ISender sender, CancellationToken cancellationToken)
+ public async Task GetAllAsync([FromQuery] int page,
+ [FromQuery] long? selectedDate,
+ [FromQuery] DateTimeQueryFilter? dateFilter ,
+ [FromServices]ISender sender, CancellationToken cancellationToken)
=> TypedResults.Ok(await sender.Send(new GetShiftPlansQuery(page , selectedDate ?? 0 , DateTimeQueryFilter: dateFilter), cancellationToken));
// GET:Get An Entity By Id
diff --git a/Brizco.Api/Controllers/TaskController.cs b/Brizco.Api/Controllers/TaskController.cs
index 90c50e3..6327b5c 100644
--- a/Brizco.Api/Controllers/TaskController.cs
+++ b/Brizco.Api/Controllers/TaskController.cs
@@ -34,7 +34,7 @@ public class TaskController : ICarterModule
// GET:Get All Entity
public async Task GetAllAsync([FromQuery] int page,
[FromQuery] int? count,
- [FromQuery] Guid shiftId,
+ [FromQuery] Guid? shiftId,
ISender sender, CancellationToken cancellationToken)
=> TypedResults.Ok(await sender.Send(new GetTasksQuery(page, ShiftId: shiftId, Count: count), cancellationToken));
diff --git a/Brizco.Api/Controllers/UserController.cs b/Brizco.Api/Controllers/UserController.cs
index 788ca80..737299c 100644
--- a/Brizco.Api/Controllers/UserController.cs
+++ b/Brizco.Api/Controllers/UserController.cs
@@ -16,6 +16,11 @@ public class UserController : ICarterModule
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewUsers,ApplicationPermission.ManageUsers))
.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)
.WithDisplayName("GetOneUser")
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewUsers, ApplicationPermission.ManageUsers))
@@ -42,6 +47,12 @@ public class UserController : ICarterModule
.HasApiVersion(1.0);
}
+ private async Task 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 ChangeUserRoleAsync(Guid roleId,IUserService userService, CancellationToken cancellationToken)
=> TypedResults.Ok(await userService.ChangeUserRoleAsync(roleId,cancellationToken));
diff --git a/Brizco.Api/Program.cs b/Brizco.Api/Program.cs
index c84546c..a399cac 100644
--- a/Brizco.Api/Program.cs
+++ b/Brizco.Api/Program.cs
@@ -83,6 +83,7 @@ builder.Host.ConfigureContainer(builder =>
.Create(typeof(CoreConfig).Assembly)
.WithAllOpenGenericHandlerTypesRegistered()
.Build());
+ builder.AddSchedulerToAutoFac();
});
var app = builder.Build();
diff --git a/Brizco.Api/Properties/launchSettings.json b/Brizco.Api/Properties/launchSettings.json
index 4a0a476..78c6560 100644
--- a/Brizco.Api/Properties/launchSettings.json
+++ b/Brizco.Api/Properties/launchSettings.json
@@ -23,7 +23,8 @@
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/scalar/v1",
"environmentVariables": {
- "ASPNETCORE_URLS": "http://+:80"
+ "ASPNETCORE_URLS": "http://+:80",
+ "TZ": "Asia/Tehran"
},
"publishAllPorts": true,
"DockerfileRunArguments": " --network=mother -p 32767:80"
diff --git a/Brizco.Api/WebFramework/Configurations/ServiceExtensions.cs b/Brizco.Api/WebFramework/Configurations/ServiceExtensions.cs
index 379e751..399ad22 100644
--- a/Brizco.Api/WebFramework/Configurations/ServiceExtensions.cs
+++ b/Brizco.Api/WebFramework/Configurations/ServiceExtensions.cs
@@ -1,8 +1,10 @@
-using System.IO.Compression;
+using System.Collections.Specialized;
+using System.IO.Compression;
using Asp.Versioning;
using AspNetCoreRateLimit;
using AspNetCoreRateLimit.Redis;
-using Brizco.Domain.Entities.Users;
+using Autofac.Extras.Quartz;
+using Brizco.Core.QuartzServices;
using Marten;
using Microsoft.AspNetCore.ResponseCompression;
using StackExchange.Redis.Extensions.Core.Configuration;
@@ -14,6 +16,22 @@ namespace Brizco.Api.WebFramework.Configurations;
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().AsSelf();
+ }
public static void AddIpRateLimit(this IServiceCollection services, IConfigurationRoot configuration)
{
diff --git a/Brizco.Common/Extensions/DateTimeExtensions.cs b/Brizco.Common/Extensions/DateTimeExtensions.cs
index eb0ad4e..04d1c64 100644
--- a/Brizco.Common/Extensions/DateTimeExtensions.cs
+++ b/Brizco.Common/Extensions/DateTimeExtensions.cs
@@ -37,6 +37,8 @@ namespace Brizco.Common.Extensions
public static long DateTimeToUnixTimeStamp(DateTime dateTime)
{
+ if (dateTime == DateTime.MinValue)
+ return 0;
return ((DateTimeOffset)dateTime).ToUnixTimeMilliseconds();
}
diff --git a/Brizco.Core/Brizco.Core.csproj b/Brizco.Core/Brizco.Core.csproj
index 70523ac..8517ffd 100644
--- a/Brizco.Core/Brizco.Core.csproj
+++ b/Brizco.Core/Brizco.Core.csproj
@@ -63,9 +63,11 @@
+
+
diff --git a/Brizco.Core/EntityServices/ActivityService.cs b/Brizco.Core/EntityServices/ActivityService.cs
index d4604fa..393ce70 100644
--- a/Brizco.Core/EntityServices/ActivityService.cs
+++ b/Brizco.Core/EntityServices/ActivityService.cs
@@ -3,29 +3,21 @@ using Task = Brizco.Domain.Entities.Tasks.Task;
namespace Brizco.Core.EntityServices;
-public class ActivityService : IActivityService
+public class ActivityService(IMediator mediator, IRepositoryWrapper repositoryWrapper) : IActivityService
{
- private readonly IMediator _mediator;
- private readonly IRepositoryWrapper _repositoryWrapper;
-
- public ActivityService(IMediator mediator, IRepositoryWrapper repositoryWrapper)
- {
- _mediator = mediator;
- _repositoryWrapper = repositoryWrapper;
- }
public async Task DoneActivityAsync(Guid activityId, CancellationToken cancellationToken)
{
- var activity = await _repositoryWrapper.SetRepository()
+ var activity = await repositoryWrapper.SetRepository()
.TableNoTracking
.FirstOrDefaultAsync(a => a.Id == activityId, cancellationToken);
if (activity == null)
throw new AppException("Activity not found", ApiResultStatusCode.NotFound);
activity.DoneActivity();
- _repositoryWrapper.SetRepository()
+ repositoryWrapper.SetRepository()
.Update(activity);
- await _repositoryWrapper.SaveChangesAsync(cancellationToken);
+ await repositoryWrapper.SaveChangesAsync(cancellationToken);
return true;
}
@@ -33,14 +25,14 @@ public class ActivityService : IActivityService
{
foreach (var activityRequestDto in requestDtos)
{
- var activity = await _repositoryWrapper.SetRepository().TableNoTracking
+ var activity = await repositoryWrapper.SetRepository().TableNoTracking
.FirstOrDefaultAsync(a => a.Id == activityRequestDto.ActivityId, cancellationToken);
if (activity == null)
continue;
activity.CompleteActivity(activityRequestDto.IsCompleted, activityRequestDto.PerformanceDescription);
- _repositoryWrapper.SetRepository().Update(activity);
- await _repositoryWrapper.SaveChangesAsync(cancellationToken);
+ repositoryWrapper.SetRepository().Update(activity);
+ await repositoryWrapper.SaveChangesAsync(cancellationToken);
}
return true;
@@ -49,44 +41,44 @@ public class ActivityService : IActivityService
public async Task UnDoneActivityAsync(Guid activityId, string undoneReason, CancellationToken cancellationToken)
{
- var activity = await _repositoryWrapper.SetRepository()
+ var activity = await repositoryWrapper.SetRepository()
.TableNoTracking
.FirstOrDefaultAsync(a => a.Id == activityId, cancellationToken);
if (activity == null)
throw new AppException("Activity not found ", ApiResultStatusCode.NotFound);
activity.UnDoneActivity(undoneReason);
- _repositoryWrapper.SetRepository()
+ repositoryWrapper.SetRepository()
.Update(activity);
- await _repositoryWrapper.SaveChangesAsync(cancellationToken);
+ await repositoryWrapper.SaveChangesAsync(cancellationToken);
return true;
}
public async Task 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)
return false;
- var dailyTasks = await (from task in _repositoryWrapper.SetRepository().Entities
- join taskShift in _repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId
- join taskRoutine in _repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine
+ var dailyTasks = await (from task in repositoryWrapper.SetRepository().Entities
+ join taskShift in repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId
+ join taskRoutine in repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine
.TaskId
where taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId && task.ScheduleType == TaskScheduleType.Daily
select task).AsNoTracking().ToListAsync(cancellationToken);
- var weeklyTasks = await (from task in _repositoryWrapper.SetRepository().Entities
- join taskShift in _repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId
- join taskDay in _repositoryWrapper.SetRepository().Entities on task.Id equals taskDay.TaskId
- join taskRoutine in _repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine
+ var weeklyTasks = await (from task in repositoryWrapper.SetRepository().Entities
+ join taskShift in repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId
+ join taskDay in repositoryWrapper.SetRepository().Entities on task.Id equals taskDay.TaskId
+ join taskRoutine in repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine
.TaskId
where taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId &&
taskDay.DayOfWeek == shiftPlan.PlanFor.DayOfWeek && task.ScheduleType == TaskScheduleType.Weekly
group task by task.Id into groupedTask
select groupedTask.FirstOrDefault()).AsNoTracking().ToListAsync(cancellationToken);
- var customTasks = await (from task in _repositoryWrapper.SetRepository().Entities
- join taskShift in _repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId
- join taskRoutine in _repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine
+ var customTasks = await (from task in repositoryWrapper.SetRepository().Entities
+ join taskShift in repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId
+ join taskRoutine in repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine
.TaskId
where taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId &&
task.ScheduleType == TaskScheduleType.Custom && task.SetFor.Date == shiftPlan.PlanFor.Date
@@ -98,13 +90,13 @@ public class ActivityService : IActivityService
tasks.AddRange(dailyTasks);
tasks.AddRange(customTasks);
- var shiftPlanPositions = await _repositoryWrapper.SetRepository()
+ var shiftPlanPositions = await repositoryWrapper.SetRepository()
.TableNoTracking
.Where(spu => spu.ShiftPlanId == shiftPlan.Id)
.ToListAsync(cancellationToken);
- var activities = await _repositoryWrapper.SetRepository()
+ var activities = await repositoryWrapper.SetRepository()
.TableNoTracking
.Where(a => a.ShiftPlanId == shiftPlan.ShiftId && a.SetFor.Date == shiftPlan.PlanFor.Date)
.Select(ActivityMapper.ProjectToLDto)
@@ -115,7 +107,7 @@ public class ActivityService : IActivityService
if (foundedTask == null)
continue;
- var taskPositions = await _repositoryWrapper.SetRepository()
+ var taskPositions = await repositoryWrapper.SetRepository()
.TableNoTracking
.Where(tp => tp.TaskId == foundedTask.Id)
.ToListAsync(cancellationToken);
@@ -128,7 +120,7 @@ public class ActivityService : IActivityService
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.AmountType, activity.ScheduleType, shiftPlan.Id, foundedUser.UserId), cancellationToken);
}
@@ -138,30 +130,30 @@ public class ActivityService : IActivityService
}
public async Task 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)
return false;
- var dailyTasks = await (from task in _repositoryWrapper.SetRepository().Entities
- join taskShift in _repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId
- join taskRoutine in _repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine
+ var dailyTasks = await (from task in repositoryWrapper.SetRepository().Entities
+ join taskShift in repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId
+ join taskRoutine in repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine
.TaskId
where task.IsActivity == false && taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId && task.ScheduleType == TaskScheduleType.Daily
select task).AsNoTracking().ToListAsync(cancellationToken);
- var weeklyTasks = await (from task in _repositoryWrapper.SetRepository().Entities
- join taskShift in _repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId
- join taskDay in _repositoryWrapper.SetRepository().Entities on task.Id equals taskDay.TaskId
- join taskRoutine in _repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine
+ var weeklyTasks = await (from task in repositoryWrapper.SetRepository().Entities
+ join taskShift in repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId
+ join taskDay in repositoryWrapper.SetRepository().Entities on task.Id equals taskDay.TaskId
+ join taskRoutine in repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine
.TaskId
where task.IsActivity == false && taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId &&
taskDay.DayOfWeek == shiftPlan.PlanFor.DayOfWeek && task.ScheduleType == TaskScheduleType.Weekly
group task by task.Id into groupedTask
select groupedTask.FirstOrDefault()).AsNoTracking().ToListAsync(cancellationToken);
- var customTasks = await (from task in _repositoryWrapper.SetRepository().Entities
- join taskShift in _repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId
- join taskRoutine in _repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine
+ var customTasks = await (from task in repositoryWrapper.SetRepository().Entities
+ join taskShift in repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId
+ join taskRoutine in repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine
.TaskId
where task.IsActivity == false && taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId &&
task.ScheduleType == TaskScheduleType.Custom && task.SetFor.Date == shiftPlan.PlanFor.Date
@@ -173,14 +165,14 @@ public class ActivityService : IActivityService
tasks.AddRange(customTasks);
- var shiftPlanPositions = await _repositoryWrapper.SetRepository()
+ var shiftPlanPositions = await repositoryWrapper.SetRepository()
.TableNoTracking
.Where(spu => spu.ShiftPlanId == shiftPlan.Id)
.ToListAsync(cancellationToken);
foreach (var task in tasks)
{
- var taskPositions = await _repositoryWrapper.SetRepository()
+ var taskPositions = await repositoryWrapper.SetRepository()
.TableNoTracking
.Where(tp => tp.TaskId == task.Id)
.ToListAsync(cancellationToken);
@@ -190,7 +182,7 @@ public class ActivityService : IActivityService
var fundedUser = shiftPlanPositions.FirstOrDefault(spu => spu.PositionId == taskPosition.PositionId);
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,
task.ScheduleType, shiftPlan.Id, fundedUser.UserId), cancellationToken);
}
diff --git a/Brizco.Core/EntityServices/ShiftPlanService.cs b/Brizco.Core/EntityServices/ShiftPlanService.cs
index b76fa18..312ce64 100644
--- a/Brizco.Core/EntityServices/ShiftPlanService.cs
+++ b/Brizco.Core/EntityServices/ShiftPlanService.cs
@@ -34,6 +34,17 @@ public class ShiftPlanService(IMediator mediator, IActivityService activityServi
repositoryWrapper.SetRepository().Update(shiftPlan);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
await activityService.CompleteActivitiesAsync(requestDtos.CompleteActivities, cancellationToken);
+
+ var shiftPlanUsers = await repositoryWrapper.SetRepository()
+ .TableNoTracking.Where(s => s.ShiftPlanId == id)
+ .Select(ShiftPlanUserMapper.ProjectToSDto)
+ .ToListAsync(cancellationToken);
+
+ foreach (var shiftPlanUser in shiftPlanUsers)
+ {
+ var message = $"{shiftPlanUser.UserFullName}";
+ }
+
return true;
}
}
\ No newline at end of file
diff --git a/Brizco.Core/MartenServices/BrewService.cs b/Brizco.Core/MartenServices/BrewService.cs
index f2916b5..93d19fc 100644
--- a/Brizco.Core/MartenServices/BrewService.cs
+++ b/Brizco.Core/MartenServices/BrewService.cs
@@ -1,7 +1,4 @@
-using Newtonsoft.Json;
-using System.Reflection;
-
-namespace Brizco.Core.MartenServices;
+namespace Brizco.Core.MartenServices;
public class BrewService : IBrewService
{
diff --git a/Brizco.Core/QuartzServices/Handlers/CreateShiftPlanNotificationsCommandHandler.cs b/Brizco.Core/QuartzServices/Handlers/CreateShiftPlanNotificationsCommandHandler.cs
index 5e11562..ab20f43 100644
--- a/Brizco.Core/QuartzServices/Handlers/CreateShiftPlanNotificationsCommandHandler.cs
+++ b/Brizco.Core/QuartzServices/Handlers/CreateShiftPlanNotificationsCommandHandler.cs
@@ -1,9 +1,7 @@
-using Brizco.Domain.Entities.ShiftPlans;
+namespace Brizco.Core.QuartzServices.Handlers;
-namespace Brizco.Core.QuartzServices.Handlers;
-
-public class CreateShiftPlanNotificationsCommandHandler(IMediator mediator,IRepositoryWrapper repositoryWrapper)
- : IRequestHandler
+public class CreateShiftPlanNotificationsCommandHandler(IMediator mediator, IRepositoryWrapper repositoryWrapper)
+ : IRequestHandler
{
public async Task Handle(CreateShiftPlanNotificationsCommand request, CancellationToken cancellationToken)
{
@@ -28,8 +26,8 @@ public class CreateShiftPlanNotificationsCommandHandler(IMediator mediator,IRepo
foreach (var shiftPlanUser in shiftPlanUsers)
{
- var completeShiftMessageForUser = $"";
- await mediator.Send( new CreateNotificationCommand(completeShiftMessageForUser, shiftPlanUser.UserId, shiftPlan.ComplexId), cancellationToken);
+ var completeShiftMessageForUser = $"شیفتهای هفته بعد بسته شد، دیگه کار، کار، کار.";
+ await mediator.Send(new CreateNotificationCommand(completeShiftMessageForUser, shiftPlanUser.UserId, shiftPlan.ComplexId), cancellationToken);
}
}
diff --git a/Brizco.Core/QuartzServices/Handlers/SetShiftPlanNotificationScheduleCommandHandler.cs b/Brizco.Core/QuartzServices/Handlers/SetShiftPlanNotificationScheduleCommandHandler.cs
index ceb4416..c38bfee 100644
--- a/Brizco.Core/QuartzServices/Handlers/SetShiftPlanNotificationScheduleCommandHandler.cs
+++ b/Brizco.Core/QuartzServices/Handlers/SetShiftPlanNotificationScheduleCommandHandler.cs
@@ -1,9 +1,11 @@
using Brizco.Core.QuartzServices.Commands;
+using Microsoft.Extensions.Logging;
using Quartz;
namespace Brizco.Core.QuartzServices.Handlers;
-public class SetShiftPlanNotificationScheduleCommandHandler(IRepositoryWrapper repositoryWrapper,IScheduler scheduler) : IRequestHandler
+public class SetShiftPlanNotificationScheduleCommandHandler(IRepositoryWrapper repositoryWrapper,IScheduler scheduler,IMediator mediator,ILogger logger)
+ : IRequestHandler
{
public async Task Handle(SetShiftPlanNotificationScheduleCommand request, CancellationToken cancellationToken)
{
@@ -20,9 +22,22 @@ public class SetShiftPlanNotificationScheduleCommandHandler(IRepositoryWrapper r
if(shift == null)
throw new BaseApiException(ApiResultStatusCode.NotFound, "Shift not found in set schedule");
- var shiftPlanStartAt = (new DateTime(shiftPlan.PlanFor.Year, shiftPlan.PlanFor.Month, shiftPlan.PlanFor.Day, shift.StartAt.Hours,shift.StartAt.Minutes,shift.StartAt.Seconds)).ToUniversalTime();
+ var shiftPlanUsers = await repositoryWrapper.SetRepository()
+ .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 currentDate = DateTime.UtcNow;
+
var startTimeOffset = new DateTimeOffset(shiftPlanStartAt.Year, shiftPlanStartAt.Month, shiftPlanStartAt.Day, shiftPlanStartAt.Hour,
shiftPlanStartAt.Minute, shiftPlanStartAt.Second, TimeSpan.Zero);
var endTimeOffset = new DateTimeOffset(shiftPlanEndAt.Year, shiftPlanEndAt.Month, shiftPlanEndAt.Day, shiftPlanEndAt.Hour,
@@ -36,10 +51,9 @@ public class SetShiftPlanNotificationScheduleCommandHandler(IRepositoryWrapper r
ITrigger beforeEndShift30MinTrigger = TriggerBuilder.Create()
.WithIdentity(StringExtensions.GetId(9), shift.ComplexId.ToString())
.WithSimpleSchedule(x => x.WithRepeatCount(0))
- .StartAt(endTimeOffset.AddMinutes(-40))
+ .StartAt(endTimeOffset.AddMinutes(-35))
.Build();
-
IJobDetail endOfShift = JobBuilder.Create()
.WithIdentity(ShiftPlanNotifyType.EndOfShift.ToString(), shiftPlan.Id.ToString())
.Build();
@@ -60,9 +74,10 @@ public class SetShiftPlanNotificationScheduleCommandHandler(IRepositoryWrapper r
.Build();
- await scheduler.ScheduleJob(beforeEndShift30Min, beforeEndShift30MinTrigger, cancellationToken);
- await scheduler.ScheduleJob(endOfShift, endOfShiftTrigger, cancellationToken);
- await scheduler.ScheduleJob(afterStartShift2Hour, afterStartShift2HourTrigger, cancellationToken);
+ var seTimeOffsetA = await scheduler.ScheduleJob(beforeEndShift30Min, beforeEndShift30MinTrigger, cancellationToken);
+ var seTimeOffsetB = await scheduler.ScheduleJob(endOfShift, endOfShiftTrigger, cancellationToken);
+ var seTimeOffsetC = await scheduler.ScheduleJob(afterStartShift2Hour, afterStartShift2HourTrigger, cancellationToken);
+ await scheduler.Start(cancellationToken);
return true;
diff --git a/Brizco.Core/QuartzServices/ShiftPlanNotificationScheduledJob.cs b/Brizco.Core/QuartzServices/ShiftPlanNotificationScheduledJob.cs
index cdc4da6..1b7e8a9 100644
--- a/Brizco.Core/QuartzServices/ShiftPlanNotificationScheduledJob.cs
+++ b/Brizco.Core/QuartzServices/ShiftPlanNotificationScheduledJob.cs
@@ -1,5 +1,4 @@
-using Brizco.Domain.Entities.ShiftPlans;
-using Brizco.Domain.Entities.Tasks;
+using Brizco.Domain.Entities.Tasks;
using Microsoft.Extensions.Logging;
using Quartz;
using Task = System.Threading.Tasks.Task;
@@ -26,12 +25,15 @@ public class ShiftPlanNotificationScheduledJob : IJob
var notifyType = (ShiftPlanNotifyType)int.Parse(context.JobDetail.Key.Name);
var shiftPlanId = Guid.Parse(context.JobDetail.Key.Group);
var shiftPlan = await _repositoryWrapper.SetRepository().TableNoTracking
- .FirstOrDefaultAsync(f => f.Id == shiftPlanId);
+ .Where(f => f.Id == shiftPlanId)
+ .Select(ShiftPlanMapper.ProjectToSDto)
+ .FirstOrDefaultAsync();
if (shiftPlan == null)
throw new Exception("Shift plan not found");
var shiftPlanUsers = await _repositoryWrapper.SetRepository()
.TableNoTracking
.Where(f => f.ShiftPlanId == shiftPlanId)
+ .Select(ShiftPlanUserMapper.ProjectToSDto)
.ToListAsync();
var superVisorId = shiftPlan.SupervisorId;
switch (notifyType)
@@ -47,7 +49,7 @@ public class ShiftPlanNotificationScheduledJob : IJob
var unDoneCount = activities.Count(a => a.UserId == shiftPlanUser.UserId && a.IsDone == false);
if(unDoneCount == 0)
continue;
- string message = $"شما تعداد {unDoneCount} وظیفه انجام نشده در شیفت مورد نظر دارید ، نیم ساعت به پایان شیفت مانده است";
+ string message = $"نیم ساعت مونده تا شیفت تموم شه و {unDoneCount} عدد از تست هات مونده، حالا چه خاکی به سر کنیم!😱";
await _mediator.Send(new CreateNotificationCommand(message, shiftPlanUser.UserId, shiftPlan.ComplexId));
}
break;
@@ -59,14 +61,23 @@ public class ShiftPlanNotificationScheduledJob : IJob
var unDoneCount = activitiesEndShift.Count(a => a.UserId == shiftPlanUser.UserId && a.IsDone == false);
if (unDoneCount == 0)
continue;
- string message = $"شما تعداد {unDoneCount} وظیفه انجام نشده در شیفت مورد نظر دارید";
+ string message = $"{shiftPlanUser.UserFullName} {shiftPlan.ShiftTitle} {shiftPlan.PlanFor.ToPersianDateTime().ToLongDateTimeString()} تموم شده است و {unDoneCount} - عدد از تسک های شما کاری روشون انجام نشده ، خطر سوپروایزر در کمین است";
await _mediator.Send(new CreateNotificationCommand(message, shiftPlanUser.UserId, shiftPlan.ComplexId));
}
- string superVisorAfterShiftMessage = $"سوپر وایزر محترم ، شیفت مورد نظر به پایان رسیده است ، لطفا فعالیت ها را رسیدگی کنید";
+ string superVisorAfterShiftMessage = $"{shiftPlan.SupervisorFullName} محترم {shiftPlan.ShiftTitle} تموم شد. برو به کار بچه ها نمره بده و مو رو از ماست بکش و کامنت یادت نره";
await _mediator.Send(new CreateNotificationCommand(superVisorAfterShiftMessage, shiftPlan.SupervisorId, shiftPlan.ComplexId));
break;
case ShiftPlanNotifyType.AfterStartShift2Hour:
-
+ var activities2AfterStartShift = await _repositoryWrapper.SetRepository().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;
default:
return;
diff --git a/Brizco.Domain/Brizco.Domain.csproj b/Brizco.Domain/Brizco.Domain.csproj
index 8ad6271..c096311 100644
--- a/Brizco.Domain/Brizco.Domain.csproj
+++ b/Brizco.Domain/Brizco.Domain.csproj
@@ -61,6 +61,7 @@
+
@@ -70,4 +71,10 @@
+
+
+
+
+
+
diff --git a/Brizco.Domain/CommandQueries/Commands/NewsFeedCommands.cs b/Brizco.Domain/CommandQueries/Commands/NewsFeedCommands.cs
new file mode 100644
index 0000000..1fe0029
--- /dev/null
+++ b/Brizco.Domain/CommandQueries/Commands/NewsFeedCommands.cs
@@ -0,0 +1,5 @@
+namespace Brizco.Domain.CommandQueries.Commands;
+
+public record CreateNewsFeedCommand(string Title,string Content,bool IsPin) : IRequest;
+public record DeleteNewsFeedCommand(Guid Id) : IRequest;
+public record ChangeNewsFeedPinCommand(Guid Id , bool IsPin) : IRequest;
\ No newline at end of file
diff --git a/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs b/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs
index a670b97..61a61eb 100644
--- a/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs
+++ b/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs
@@ -2,7 +2,11 @@
namespace Brizco.Domain.CommandQueries.Queries;
-public sealed record GetActivitiesQuery(int Page = 0 , long SelectedDate = 0 , Guid SelectedShiftPlanId = default , DateQueryFilter? DateQueryFilter = null) : IRequest>;
+public sealed record GetActivitiesQuery(int Page = 0 ,
+ long SelectedDate = 0 ,
+ Guid? SelectedShiftPlanId = null ,
+ DateTimeQueryFilter? DateQueryFilter = null,
+ Guid? UserId = null) : IRequest>;
public sealed record GetActivityQuery(Guid Id) : IRequest;
diff --git a/Brizco.Domain/CommandQueries/Queries/NewsFeedQueries.cs b/Brizco.Domain/CommandQueries/Queries/NewsFeedQueries.cs
new file mode 100644
index 0000000..a9fc8e0
--- /dev/null
+++ b/Brizco.Domain/CommandQueries/Queries/NewsFeedQueries.cs
@@ -0,0 +1,3 @@
+namespace Brizco.Domain.CommandQueries.Queries;
+
+public record GetNewsFeedsQuery(int Page , int? Count = 0) : IRequest>;
\ No newline at end of file
diff --git a/Brizco.Domain/CommandQueries/Queries/NotificationQueries.cs b/Brizco.Domain/CommandQueries/Queries/NotificationQueries.cs
index 46d14dc..b61def6 100644
--- a/Brizco.Domain/CommandQueries/Queries/NotificationQueries.cs
+++ b/Brizco.Domain/CommandQueries/Queries/NotificationQueries.cs
@@ -2,4 +2,5 @@
namespace Brizco.Domain.CommandQueries.Queries;
-public record GetNotificationsQuery(int Page,int Count, Guid? UserId=null) : IRequest>;
\ No newline at end of file
+public record GetNotificationsQuery(int Page,int? Count=null, Guid? UserId=null) : IRequest>;
+public record GetNotificationsCountQuery() : IRequest;
\ No newline at end of file
diff --git a/Brizco.Domain/CommandQueries/Queries/UserQueries.cs b/Brizco.Domain/CommandQueries/Queries/UserQueries.cs
new file mode 100644
index 0000000..ed948a5
--- /dev/null
+++ b/Brizco.Domain/CommandQueries/Queries/UserQueries.cs
@@ -0,0 +1,3 @@
+namespace Brizco.Domain.CommandQueries.Queries;
+
+public record GetStaffQuery(int Page , DateTimeQueryFilter DateTimeQuery , int? Count = null) : IRequest>;
\ No newline at end of file
diff --git a/Brizco.Domain/Dtos/ResponseDto/StaffResponseSDto.cs b/Brizco.Domain/Dtos/ResponseDto/StaffResponseSDto.cs
new file mode 100644
index 0000000..97d80ec
--- /dev/null
+++ b/Brizco.Domain/Dtos/ResponseDto/StaffResponseSDto.cs
@@ -0,0 +1,8 @@
+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;
+}
\ No newline at end of file
diff --git a/Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs b/Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs
index 47ac7ce..b0395f1 100644
--- a/Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs
+++ b/Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs
@@ -20,6 +20,7 @@ public class ActivitySDto : BaseDto
public string UserFirstName { get; set; } = string.Empty;
public string UserLastName { get; set; } = string.Empty;
public string UserFullName => UserFirstName + " " + UserLastName;
+ public Guid UserId { get; set; }
public int Amount { get; set; }
diff --git a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs
index 8dd6d8d..44d9add 100644
--- a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs
+++ b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs
@@ -18,6 +18,7 @@ public class ShiftPlanSDto : BaseDto
public string ShiftTitle { get; set; } = string.Empty;
public TimeSpan StartAt { get; set; }
public TimeSpan EndAt { get; set; }
+ public Guid SupervisorId { get; set; }
public List Users { get; set; } = new();
}
\ No newline at end of file
diff --git a/Brizco.Domain/Enums/DateQueryFilter.cs b/Brizco.Domain/Enums/DateQueryFilter.cs
deleted file mode 100644
index 72e155f..0000000
--- a/Brizco.Domain/Enums/DateQueryFilter.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace Brizco.Domain.Enums;
-
-public enum DateQueryFilter
-{
- Today = 0,
- Tomorrow = 1,
- ThisWeek = 2,
- Yesterday = 3,
-}
\ No newline at end of file
diff --git a/Brizco.Domain/Enums/DateTimeQueryFilter.cs b/Brizco.Domain/Enums/DateTimeQueryFilter.cs
index 634fa3c..1450cbc 100644
--- a/Brizco.Domain/Enums/DateTimeQueryFilter.cs
+++ b/Brizco.Domain/Enums/DateTimeQueryFilter.cs
@@ -5,6 +5,7 @@ public enum DateTimeQueryFilter
CustomDate = 0,
Today = 1,
Yesterday = 2,
+ Tomorrow = 3,
PastWeek = 10,
NextWeek = 11,
ThisWeek = 12,
diff --git a/Brizco.Domain/Mappers/ActivityMapper.g.cs b/Brizco.Domain/Mappers/ActivityMapper.g.cs
index 99eb127..601b055 100644
--- a/Brizco.Domain/Mappers/ActivityMapper.g.cs
+++ b/Brizco.Domain/Mappers/ActivityMapper.g.cs
@@ -20,10 +20,12 @@ namespace Brizco.Domain.Mappers
IsDone = p1.IsDone,
UnDoneReason = p1.UnDoneReason,
PerformanceDescription = p1.PerformanceDescription,
+ UserId = p1.UserId,
User = new ApplicationUser()
{
FirstName = p1.UserFirstName,
- LastName = p1.UserLastName
+ LastName = p1.UserLastName,
+ Id = p1.UserId
},
ShiftPlanId = p1.ShiftPlanId,
ShiftPlan = new ShiftPlan() {Id = p1.ShiftPlanId},
@@ -52,6 +54,7 @@ namespace Brizco.Domain.Mappers
result.IsDone = p2.IsDone;
result.UnDoneReason = p2.UnDoneReason;
result.PerformanceDescription = p2.PerformanceDescription;
+ result.UserId = p2.UserId;
result.User = funcMain1(new Never(), result.User, p2);
result.ShiftPlanId = p2.ShiftPlanId;
result.ShiftPlan = funcMain2(new Never(), result.ShiftPlan, p2);
@@ -75,10 +78,12 @@ namespace Brizco.Domain.Mappers
IsDone = p8.IsDone,
UnDoneReason = p8.UnDoneReason,
PerformanceDescription = p8.PerformanceDescription,
+ UserId = p8.UserId,
User = new ApplicationUser()
{
FirstName = p8.UserFirstName,
- LastName = p8.UserLastName
+ LastName = p8.UserLastName,
+ Id = p8.UserId
},
ShiftPlanId = p8.ShiftPlanId,
ShiftPlan = new ShiftPlan() {Id = p8.ShiftPlanId},
@@ -112,6 +117,7 @@ namespace Brizco.Domain.Mappers
PerformanceDescription = p9.PerformanceDescription,
UserFirstName = p9.User != null ? p9.User.FirstName : string.Empty,
UserLastName = p9.User != null ? p9.User.LastName : string.Empty,
+ UserId = p9.UserId,
Amount = p9.Amount,
ShiftPlanId = p9.ShiftPlanId,
AmountType = p9.AmountType,
@@ -141,6 +147,7 @@ namespace Brizco.Domain.Mappers
result.PerformanceDescription = p10.PerformanceDescription;
result.UserFirstName = p10.User != null ? p10.User.FirstName : string.Empty;
result.UserLastName = p10.User != null ? p10.User.LastName : string.Empty;
+ result.UserId = p10.UserId;
result.Amount = p10.Amount;
result.ShiftPlanId = p10.ShiftPlanId;
result.AmountType = p10.AmountType;
@@ -165,6 +172,7 @@ namespace Brizco.Domain.Mappers
PerformanceDescription = p12.PerformanceDescription,
UserFirstName = p12.User != null ? p12.User.FirstName : string.Empty,
UserLastName = p12.User != null ? p12.User.LastName : string.Empty,
+ UserId = p12.UserId,
Amount = p12.Amount,
ShiftPlanId = p12.ShiftPlanId,
AmountType = p12.AmountType,
@@ -289,6 +297,7 @@ namespace Brizco.Domain.Mappers
result.FirstName = p2.UserFirstName;
result.LastName = p2.UserLastName;
+ result.Id = p2.UserId;
return result;
}
diff --git a/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs b/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs
index cb227fd..422d5e0 100644
--- a/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs
+++ b/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs
@@ -29,6 +29,10 @@ namespace Brizco.Domain.Mappers
Title = p1.ShiftTitle,
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),
Id = p1.Id
};
@@ -47,198 +51,212 @@ namespace Brizco.Domain.Mappers
result.CompleteDescription = p3.CompleteDescription;
result.ShiftId = p3.ShiftId;
result.Shift = funcMain2(new Never(), result.Shift, p3);
- result.Users = funcMain3(p3.Users, result.Users);
+ result.ComplexId = p3.ComplexId;
+ 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;
return result;
}
- public static Expression> ProjectToShiftPlan => p9 => new ShiftPlan()
+ public static Expression> ProjectToShiftPlan => p13 => new ShiftPlan()
{
- PlanFor = p9.PlanFor,
- IsCompleted = p9.IsCompleted,
- CompletePercent = p9.CompletePercent,
- CompleteDescription = p9.CompleteDescription,
- ShiftId = p9.ShiftId,
+ PlanFor = p13.PlanFor,
+ IsCompleted = p13.IsCompleted,
+ CompletePercent = p13.CompletePercent,
+ CompleteDescription = p13.CompleteDescription,
+ ShiftId = p13.ShiftId,
Shift = new Shift()
{
- Title = p9.ShiftTitle,
- Id = p9.ShiftId
+ Title = p13.ShiftTitle,
+ Id = p13.ShiftId
},
- Users = p9.Users.Select(p10 => new ShiftPlanUser()
+ ComplexId = p13.ComplexId,
+ Complex = new Complex() {Id = p13.ComplexId},
+ SupervisorId = p13.SupervisorId,
+ Supervisor = new ApplicationUser() {Id = p13.SupervisorId},
+ Users = p13.Users.Select(p14 => new ShiftPlanUser()
{
- ShiftPlanId = p10.ShiftPlanId,
- ShiftPlan = new ShiftPlan() {Id = p10.ShiftPlanId},
- PositionId = p10.PositionId,
+ ShiftPlanId = p14.ShiftPlanId,
+ ShiftPlan = new ShiftPlan() {Id = p14.ShiftPlanId},
+ PositionId = p14.PositionId,
Position = new Position()
{
- Name = p10.PositionName,
- Id = p10.PositionId
+ Name = p14.PositionName,
+ Id = p14.PositionId
},
- UserId = p10.UserId,
- User = new ApplicationUser() {Id = p10.UserId},
- Id = p10.Id
+ UserId = p14.UserId,
+ User = new ApplicationUser() {Id = p14.UserId},
+ Id = p14.Id
}).ToList(),
- Id = p9.Id
+ Id = p13.Id
};
- public static ShiftPlanSDto AdaptToSDto(this ShiftPlan p11)
+ public static ShiftPlanSDto AdaptToSDto(this ShiftPlan p15)
{
- return p11 == null ? null : new ShiftPlanSDto()
+ return p15 == null ? null : new ShiftPlanSDto()
{
- PlanFor = p11.PlanFor,
- IsCompleted = p11.IsCompleted,
- CompletePercent = p11.CompletePercent,
- SupervisorFullName = p11.Supervisor != null ? p11.Supervisor.FirstName + " " + p11.Supervisor.LastName : string.Empty,
- CompleteDescription = p11.CompleteDescription,
- ShiftId = p11.ShiftId,
- ShiftTitle = p11.Shift == null ? null : p11.Shift.Title,
- StartAt = p11.Shift != null ? p11.Shift.StartAt : TimeSpan.MinValue,
- EndAt = p11.Shift != null ? p11.Shift.EndAt : TimeSpan.MinValue,
- Users = funcMain4(p11.Users),
- Id = p11.Id
+ PlanFor = p15.PlanFor,
+ IsCompleted = p15.IsCompleted,
+ CompletePercent = p15.CompletePercent,
+ SupervisorFullName = p15.Supervisor != null ? p15.Supervisor.FirstName + " " + p15.Supervisor.LastName : string.Empty,
+ CompleteDescription = p15.CompleteDescription,
+ ComplexId = p15.ComplexId,
+ ShiftId = p15.ShiftId,
+ ShiftTitle = p15.Shift == null ? null : p15.Shift.Title,
+ StartAt = p15.Shift != null ? p15.Shift.StartAt : TimeSpan.MinValue,
+ EndAt = p15.Shift != null ? p15.Shift.EndAt : TimeSpan.MinValue,
+ SupervisorId = p15.SupervisorId,
+ Users = funcMain6(p15.Users),
+ Id = p15.Id
};
}
- public static ShiftPlanSDto AdaptTo(this ShiftPlan p13, ShiftPlanSDto p14)
+ public static ShiftPlanSDto AdaptTo(this ShiftPlan p17, ShiftPlanSDto p18)
{
- if (p13 == null)
+ if (p17 == null)
{
return null;
}
- ShiftPlanSDto result = p14 ?? new ShiftPlanSDto();
+ ShiftPlanSDto result = p18 ?? new ShiftPlanSDto();
- result.PlanFor = p13.PlanFor;
- result.IsCompleted = p13.IsCompleted;
- result.CompletePercent = p13.CompletePercent;
- result.SupervisorFullName = p13.Supervisor != null ? p13.Supervisor.FirstName + " " + p13.Supervisor.LastName : string.Empty;
- result.CompleteDescription = p13.CompleteDescription;
- result.ShiftId = p13.ShiftId;
- result.ShiftTitle = p13.Shift == null ? null : p13.Shift.Title;
- result.StartAt = p13.Shift != null ? p13.Shift.StartAt : TimeSpan.MinValue;
- result.EndAt = p13.Shift != null ? p13.Shift.EndAt : TimeSpan.MinValue;
- result.Users = funcMain5(p13.Users, result.Users);
- result.Id = p13.Id;
+ result.PlanFor = p17.PlanFor;
+ result.IsCompleted = p17.IsCompleted;
+ result.CompletePercent = p17.CompletePercent;
+ result.SupervisorFullName = p17.Supervisor != null ? p17.Supervisor.FirstName + " " + p17.Supervisor.LastName : string.Empty;
+ result.CompleteDescription = p17.CompleteDescription;
+ result.ComplexId = p17.ComplexId;
+ result.ShiftId = p17.ShiftId;
+ result.ShiftTitle = p17.Shift == null ? null : p17.Shift.Title;
+ result.StartAt = p17.Shift != null ? p17.Shift.StartAt : TimeSpan.MinValue;
+ result.EndAt = p17.Shift != null ? p17.Shift.EndAt : TimeSpan.MinValue;
+ result.SupervisorId = p17.SupervisorId;
+ result.Users = funcMain7(p17.Users, result.Users);
+ result.Id = p17.Id;
return result;
}
- public static Expression> ProjectToSDto => p17 => new ShiftPlanSDto()
+ public static Expression> ProjectToSDto => p21 => new ShiftPlanSDto()
{
- PlanFor = p17.PlanFor,
- IsCompleted = p17.IsCompleted,
- CompletePercent = p17.CompletePercent,
- SupervisorFullName = p17.Supervisor != null ? p17.Supervisor.FirstName + " " + p17.Supervisor.LastName : string.Empty,
- CompleteDescription = p17.CompleteDescription,
- ShiftId = p17.ShiftId,
- ShiftTitle = p17.Shift.Title,
- StartAt = p17.Shift != null ? p17.Shift.StartAt : TimeSpan.MinValue,
- EndAt = p17.Shift != null ? p17.Shift.EndAt : TimeSpan.MinValue,
- Users = p17.Users.Select(p18 => new ShiftPlanUserSDto()
+ PlanFor = p21.PlanFor,
+ IsCompleted = p21.IsCompleted,
+ CompletePercent = p21.CompletePercent,
+ SupervisorFullName = p21.Supervisor != null ? p21.Supervisor.FirstName + " " + p21.Supervisor.LastName : string.Empty,
+ CompleteDescription = p21.CompleteDescription,
+ ComplexId = p21.ComplexId,
+ ShiftId = p21.ShiftId,
+ ShiftTitle = p21.Shift.Title,
+ StartAt = p21.Shift != null ? p21.Shift.StartAt : TimeSpan.MinValue,
+ EndAt = p21.Shift != null ? p21.Shift.EndAt : TimeSpan.MinValue,
+ SupervisorId = p21.SupervisorId,
+ Users = p21.Users.Select(p22 => new ShiftPlanUserSDto()
{
- ShiftPlanId = p18.ShiftPlanId,
- UserId = p18.UserId,
- UserFullName = p18.User != null ? p18.User.FirstName + " " + p18.User.LastName : string.Empty,
- PositionId = p18.PositionId,
- PositionName = p18.Position != null ? p18.Position.Name : string.Empty,
- Id = p18.Id
+ ShiftPlanId = p22.ShiftPlanId,
+ UserId = p22.UserId,
+ UserFullName = p22.User != null ? p22.User.FirstName + " " + p22.User.LastName : string.Empty,
+ PositionId = p22.PositionId,
+ PositionName = p22.Position != null ? p22.Position.Name : string.Empty,
+ Id = p22.Id
}).ToList(),
- Id = p17.Id
+ Id = p21.Id
};
- public static ShiftPlan AdaptToShiftPlan(this ShiftPlanLDto p19)
+ public static ShiftPlan AdaptToShiftPlan(this ShiftPlanLDto p23)
{
- return p19 == null ? null : new ShiftPlan()
+ return p23 == null ? null : new ShiftPlan()
{
- PlanFor = p19.PlanFor,
- IsCompleted = p19.IsCompleted,
- CompletePercent = p19.CompletePercent,
- CompleteDescription = p19.CompleteDescription,
- ShiftId = p19.ShiftId,
- Shift = new Shift() {Id = p19.ShiftId},
- RoutineId = p19.RoutineId,
- Routine = new Routine() {Id = p19.RoutineId},
- SupervisorId = p19.SupervisorId,
- Supervisor = new ApplicationUser() {Id = p19.SupervisorId},
- Users = funcMain6(p19.Users),
- Id = p19.Id
+ PlanFor = p23.PlanFor,
+ IsCompleted = p23.IsCompleted,
+ CompletePercent = p23.CompletePercent,
+ CompleteDescription = p23.CompleteDescription,
+ ShiftId = p23.ShiftId,
+ Shift = new Shift() {Id = p23.ShiftId},
+ RoutineId = p23.RoutineId,
+ Routine = new Routine() {Id = p23.RoutineId},
+ SupervisorId = p23.SupervisorId,
+ Supervisor = new ApplicationUser() {Id = p23.SupervisorId},
+ Users = funcMain8(p23.Users),
+ Id = p23.Id
};
}
- public static ShiftPlan AdaptTo(this ShiftPlanLDto p21, ShiftPlan p22)
+ public static ShiftPlan AdaptTo(this ShiftPlanLDto p25, ShiftPlan p26)
{
- if (p21 == null)
+ if (p25 == null)
{
return null;
}
- ShiftPlan result = p22 ?? new ShiftPlan();
+ ShiftPlan result = p26 ?? new ShiftPlan();
- result.PlanFor = p21.PlanFor;
- result.IsCompleted = p21.IsCompleted;
- result.CompletePercent = p21.CompletePercent;
- result.CompleteDescription = p21.CompleteDescription;
- result.ShiftId = p21.ShiftId;
- result.Shift = funcMain7(new Never(), result.Shift, p21);
- result.RoutineId = p21.RoutineId;
- result.Routine = funcMain8(new Never(), result.Routine, p21);
- result.SupervisorId = p21.SupervisorId;
- result.Supervisor = funcMain9(new Never(), result.Supervisor, p21);
- result.Users = funcMain10(p21.Users, result.Users);
- result.Id = p21.Id;
+ result.PlanFor = p25.PlanFor;
+ result.IsCompleted = p25.IsCompleted;
+ result.CompletePercent = p25.CompletePercent;
+ result.CompleteDescription = p25.CompleteDescription;
+ result.ShiftId = p25.ShiftId;
+ result.Shift = funcMain9(new Never(), result.Shift, p25);
+ result.RoutineId = p25.RoutineId;
+ result.Routine = funcMain10(new Never(), result.Routine, p25);
+ result.SupervisorId = p25.SupervisorId;
+ result.Supervisor = funcMain11(new Never(), result.Supervisor, p25);
+ result.Users = funcMain12(p25.Users, result.Users);
+ result.Id = p25.Id;
return result;
}
- public static ShiftPlanLDto AdaptToLDto(this ShiftPlan p31)
+ public static ShiftPlanLDto AdaptToLDto(this ShiftPlan p35)
{
- return p31 == null ? null : new ShiftPlanLDto()
+ return p35 == null ? null : new ShiftPlanLDto()
{
- PlanFor = p31.PlanFor,
- RoutineId = p31.RoutineId,
- IsCompleted = p31.IsCompleted,
- CompletePercent = p31.CompletePercent,
- CompleteDescription = p31.CompleteDescription,
- ShiftId = p31.ShiftId,
- Users = funcMain11(p31.Users),
- SupervisorId = p31.SupervisorId,
- SupervisorFullName = p31.Supervisor != null ? p31.Supervisor.FirstName + " " + p31.Supervisor.LastName : string.Empty,
- Id = p31.Id
+ PlanFor = p35.PlanFor,
+ RoutineId = p35.RoutineId,
+ IsCompleted = p35.IsCompleted,
+ CompletePercent = p35.CompletePercent,
+ CompleteDescription = p35.CompleteDescription,
+ ShiftId = p35.ShiftId,
+ Users = funcMain13(p35.Users),
+ SupervisorId = p35.SupervisorId,
+ SupervisorFullName = p35.Supervisor != null ? p35.Supervisor.FirstName + " " + p35.Supervisor.LastName : string.Empty,
+ Id = p35.Id
};
}
- public static ShiftPlanLDto AdaptTo(this ShiftPlan p33, ShiftPlanLDto p34)
+ public static ShiftPlanLDto AdaptTo(this ShiftPlan p37, ShiftPlanLDto p38)
{
- if (p33 == null)
+ if (p37 == null)
{
return null;
}
- ShiftPlanLDto result = p34 ?? new ShiftPlanLDto();
+ ShiftPlanLDto result = p38 ?? new ShiftPlanLDto();
- result.PlanFor = p33.PlanFor;
- result.RoutineId = p33.RoutineId;
- result.IsCompleted = p33.IsCompleted;
- result.CompletePercent = p33.CompletePercent;
- result.CompleteDescription = p33.CompleteDescription;
- result.ShiftId = p33.ShiftId;
- result.Users = funcMain12(p33.Users, result.Users);
- result.SupervisorId = p33.SupervisorId;
- result.SupervisorFullName = p33.Supervisor != null ? p33.Supervisor.FirstName + " " + p33.Supervisor.LastName : string.Empty;
- result.Id = p33.Id;
+ result.PlanFor = p37.PlanFor;
+ result.RoutineId = p37.RoutineId;
+ result.IsCompleted = p37.IsCompleted;
+ result.CompletePercent = p37.CompletePercent;
+ result.CompleteDescription = p37.CompleteDescription;
+ result.ShiftId = p37.ShiftId;
+ result.Users = funcMain14(p37.Users, result.Users);
+ result.SupervisorId = p37.SupervisorId;
+ result.SupervisorFullName = p37.Supervisor != null ? p37.Supervisor.FirstName + " " + p37.Supervisor.LastName : string.Empty;
+ result.Id = p37.Id;
return result;
}
- public static Expression> ProjectToLDto => p37 => new ShiftPlanLDto()
+ public static Expression> ProjectToLDto => p41 => new ShiftPlanLDto()
{
- PlanFor = p37.PlanFor,
- RoutineId = p37.RoutineId,
- IsCompleted = p37.IsCompleted,
- CompletePercent = p37.CompletePercent,
- CompleteDescription = p37.CompleteDescription,
- ShiftId = p37.ShiftId,
- Users = p37.Users.Select(p38 => new ShiftPlanUserSDto()
+ PlanFor = p41.PlanFor,
+ RoutineId = p41.RoutineId,
+ IsCompleted = p41.IsCompleted,
+ CompletePercent = p41.CompletePercent,
+ CompleteDescription = p41.CompleteDescription,
+ ShiftId = p41.ShiftId,
+ Users = p41.Users.Select(p42 => new ShiftPlanUserSDto()
{
- ShiftPlanId = p38.ShiftPlanId,
- UserId = p38.UserId,
- UserFullName = p38.User != null ? p38.User.FirstName + " " + p38.User.LastName : string.Empty,
- PositionId = p38.PositionId,
- PositionName = p38.Position != null ? p38.Position.Name : string.Empty,
- Id = p38.Id
+ ShiftPlanId = p42.ShiftPlanId,
+ UserId = p42.UserId,
+ UserFullName = p42.User != null ? p42.User.FirstName + " " + p42.User.LastName : string.Empty,
+ PositionId = p42.PositionId,
+ PositionName = p42.Position != null ? p42.Position.Name : string.Empty,
+ Id = p42.Id
}).ToList(),
- SupervisorId = p37.SupervisorId,
- SupervisorFullName = p37.Supervisor != null ? p37.Supervisor.FirstName + " " + p37.Supervisor.LastName : string.Empty,
- Id = p37.Id
+ SupervisorId = p41.SupervisorId,
+ SupervisorFullName = p41.Supervisor != null ? p41.Supervisor.FirstName + " " + p41.Supervisor.LastName : string.Empty,
+ Id = p41.Id
};
private static List funcMain1(List p2)
@@ -285,20 +303,38 @@ namespace Brizco.Domain.Mappers
}
- private static List funcMain3(List p7, List p8)
+ private static Complex funcMain3(Never p7, Complex p8, ShiftPlanSDto p3)
{
- if (p7 == null)
+ Complex result = p8 ?? new Complex();
+
+ 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 funcMain5(List p11, List p12)
+ {
+ if (p11 == null)
{
return null;
}
- List result = new List(p7.Count);
+ List result = new List(p11.Count);
int i = 0;
- int len = p7.Count;
+ int len = p11.Count;
while (i < len)
{
- ShiftPlanUserSDto item = p7[i];
+ ShiftPlanUserSDto item = p11[i];
result.Add(item == null ? null : new ShiftPlanUser()
{
ShiftPlanId = item.ShiftPlanId,
@@ -319,20 +355,20 @@ namespace Brizco.Domain.Mappers
}
- private static List funcMain4(List p12)
+ private static List funcMain6(List p16)
{
- if (p12 == null)
+ if (p16 == null)
{
return null;
}
- List result = new List(p12.Count);
+ List result = new List(p16.Count);
int i = 0;
- int len = p12.Count;
+ int len = p16.Count;
while (i < len)
{
- ShiftPlanUser item = p12[i];
+ ShiftPlanUser item = p16[i];
result.Add(item == null ? null : new ShiftPlanUserSDto()
{
ShiftPlanId = item.ShiftPlanId,
@@ -348,20 +384,20 @@ namespace Brizco.Domain.Mappers
}
- private static List funcMain5(List p15, List p16)
+ private static List funcMain7(List p19, List p20)
{
- if (p15 == null)
+ if (p19 == null)
{
return null;
}
- List result = new List(p15.Count);
+ List result = new List(p19.Count);
int i = 0;
- int len = p15.Count;
+ int len = p19.Count;
while (i < len)
{
- ShiftPlanUser item = p15[i];
+ ShiftPlanUser item = p19[i];
result.Add(item == null ? null : new ShiftPlanUserSDto()
{
ShiftPlanId = item.ShiftPlanId,
@@ -377,20 +413,20 @@ namespace Brizco.Domain.Mappers
}
- private static List funcMain6(List p20)
+ private static List funcMain8(List p24)
{
- if (p20 == null)
+ if (p24 == null)
{
return null;
}
- List result = new List(p20.Count);
+ List result = new List(p24.Count);
int i = 0;
- int len = p20.Count;
+ int len = p24.Count;
while (i < len)
{
- ShiftPlanUserSDto item = p20[i];
+ ShiftPlanUserSDto item = p24[i];
result.Add(item == null ? null : new ShiftPlanUser()
{
ShiftPlanId = item.ShiftPlanId,
@@ -411,47 +447,47 @@ namespace Brizco.Domain.Mappers
}
- private static Shift funcMain7(Never p23, Shift p24, ShiftPlanLDto p21)
+ private static Shift funcMain9(Never p27, Shift p28, ShiftPlanLDto p25)
{
- Shift result = p24 ?? new Shift();
+ Shift result = p28 ?? new Shift();
- result.Id = p21.ShiftId;
+ result.Id = p25.ShiftId;
return result;
}
- private static Routine funcMain8(Never p25, Routine p26, ShiftPlanLDto p21)
+ private static Routine funcMain10(Never p29, Routine p30, ShiftPlanLDto p25)
{
- Routine result = p26 ?? new Routine();
+ Routine result = p30 ?? new Routine();
- result.Id = p21.RoutineId;
+ result.Id = p25.RoutineId;
return result;
}
- private static ApplicationUser funcMain9(Never p27, ApplicationUser p28, ShiftPlanLDto p21)
+ private static ApplicationUser funcMain11(Never p31, ApplicationUser p32, ShiftPlanLDto p25)
{
- ApplicationUser result = p28 ?? new ApplicationUser();
+ ApplicationUser result = p32 ?? new ApplicationUser();
- result.Id = p21.SupervisorId;
+ result.Id = p25.SupervisorId;
return result;
}
- private static List funcMain10(List p29, List p30)
+ private static List funcMain12(List p33, List p34)
{
- if (p29 == null)
+ if (p33 == null)
{
return null;
}
- List result = new List(p29.Count);
+ List result = new List(p33.Count);
int i = 0;
- int len = p29.Count;
+ int len = p33.Count;
while (i < len)
{
- ShiftPlanUserSDto item = p29[i];
+ ShiftPlanUserSDto item = p33[i];
result.Add(item == null ? null : new ShiftPlanUser()
{
ShiftPlanId = item.ShiftPlanId,
@@ -472,20 +508,20 @@ namespace Brizco.Domain.Mappers
}
- private static List funcMain11(List p32)
+ private static List funcMain13(List p36)
{
- if (p32 == null)
+ if (p36 == null)
{
return null;
}
- List result = new List(p32.Count);
+ List result = new List(p36.Count);
int i = 0;
- int len = p32.Count;
+ int len = p36.Count;
while (i < len)
{
- ShiftPlanUser item = p32[i];
+ ShiftPlanUser item = p36[i];
result.Add(item == null ? null : new ShiftPlanUserSDto()
{
ShiftPlanId = item.ShiftPlanId,
@@ -501,20 +537,20 @@ namespace Brizco.Domain.Mappers
}
- private static List funcMain12(List p35, List p36)
+ private static List funcMain14(List p39, List p40)
{
- if (p35 == null)
+ if (p39 == null)
{
return null;
}
- List result = new List(p35.Count);
+ List result = new List(p39.Count);
int i = 0;
- int len = p35.Count;
+ int len = p39.Count;
while (i < len)
{
- ShiftPlanUser item = p35[i];
+ ShiftPlanUser item = p39[i];
result.Add(item == null ? null : new ShiftPlanUserSDto()
{
ShiftPlanId = item.ShiftPlanId,
diff --git a/Brizco.Domain/MartenEntities/NewFeeds/NewsFeed.cs b/Brizco.Domain/MartenEntities/NewFeeds/NewsFeed.cs
new file mode 100644
index 0000000..85d80aa
--- /dev/null
+++ b/Brizco.Domain/MartenEntities/NewFeeds/NewsFeed.cs
@@ -0,0 +1,9 @@
+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; }
+}
\ No newline at end of file
diff --git a/Brizco.Infrastructure/Marten/MartenRepository.cs b/Brizco.Infrastructure/Marten/MartenRepository.cs
index a8376f7..0d590ce 100644
--- a/Brizco.Infrastructure/Marten/MartenRepository.cs
+++ b/Brizco.Infrastructure/Marten/MartenRepository.cs
@@ -36,7 +36,7 @@ public class MartenRepository : IMartenRepository
await using var session = _documentStore.QuerySession();
var setting = await session.LoadAsync(id, cancellation);
if (setting == null)
- throw new AppException($"{nameof(setting)} not found", ApiResultStatusCode.NotFound);
+ throw new AppException($"{nameof(TMartenEntity)} not found", ApiResultStatusCode.NotFound);
return setting;
}
diff --git a/Brizco.Repository/Brizco.Repository.csproj b/Brizco.Repository/Brizco.Repository.csproj
index 33db06e..73f5f5b 100644
--- a/Brizco.Repository/Brizco.Repository.csproj
+++ b/Brizco.Repository/Brizco.Repository.csproj
@@ -27,7 +27,7 @@
-
+
@@ -50,6 +50,7 @@
+
diff --git a/Brizco.Repository/Handlers/Activities/GetActivitiesQueryHandler.cs b/Brizco.Repository/Handlers/Activities/GetActivitiesQueryHandler.cs
index 7ba6ee7..7a266d0 100644
--- a/Brizco.Repository/Handlers/Activities/GetActivitiesQueryHandler.cs
+++ b/Brizco.Repository/Handlers/Activities/GetActivitiesQueryHandler.cs
@@ -1,51 +1,52 @@
namespace Brizco.Repository.Handlers.Activities;
-public class GetActivitiesQueryHandler : IRequestHandler>
+public class GetActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
+ : IRequestHandler>
{
- private readonly IRepositoryWrapper _repositoryWrapper;
- private readonly ICurrentUserService _currentUserService;
-
- public GetActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
- {
- _repositoryWrapper = repositoryWrapper;
- _currentUserService = currentUserService;
- }
public async Task> Handle(GetActivitiesQuery request, CancellationToken cancellationToken)
{
- if (_currentUserService.ComplexId == null)
+ if (currentUserService.ComplexId == null)
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);
- if (_currentUserService.UserId == null)
+ if (currentUserService.UserId == null)
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);
- IQueryable activities = _repositoryWrapper.SetRepository().TableNoTracking
+ IQueryable activities = repositoryWrapper.SetRepository().TableNoTracking
.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);
+ else
+ activities = activities.Where(c => c.UserId == request.UserId);
}
if (request.DateQueryFilter != null)
{
+ var date = DateTime.Now;
switch (request.DateQueryFilter)
{
- case DateQueryFilter.Yesterday:
+ case DateTimeQueryFilter.Yesterday:
activities = activities.Where(a => a.SetFor.Date == DateTime.Today.Date.AddDays(-1).Date);
break;
- case DateQueryFilter.Today:
+ case DateTimeQueryFilter.Today:
activities = activities.Where(a => a.SetFor.Date == DateTime.Today.Date);
break;
- case DateQueryFilter.Tomorrow:
+ case DateTimeQueryFilter.Tomorrow:
activities = activities.Where(a => a.SetFor.Date == DateTime.Today.AddDays(1).Date);
break;
- case DateQueryFilter.ThisWeek:
- activities = activities.Where(a => a.SetFor.Date >= DateTime.Today.AddDays(-1).Date && a.SetFor.Date <= DateTime.Today.AddDays(+6).Date);
+ 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 = activities.Where(a => a.SetFor.Date >= startOfWeek.Date && a.SetFor.Date <= endOfWeek.Date);
break;
default:
throw new ArgumentOutOfRangeException();
diff --git a/Brizco.Repository/Handlers/Activities/GetShiftPlanActivitiesQueryHandler.cs b/Brizco.Repository/Handlers/Activities/GetShiftPlanActivitiesQueryHandler.cs
index e76acbd..0057c5f 100644
--- a/Brizco.Repository/Handlers/Activities/GetShiftPlanActivitiesQueryHandler.cs
+++ b/Brizco.Repository/Handlers/Activities/GetShiftPlanActivitiesQueryHandler.cs
@@ -1,16 +1,10 @@
namespace Brizco.Repository.Handlers.Activities;
-public class GetShiftPlanActivitiesQueryHandler : IRequestHandler>
+public class GetShiftPlanActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler>
{
- private IRepositoryWrapper _repositoryWrapper;
- public GetShiftPlanActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper)
- {
- _repositoryWrapper = repositoryWrapper;
- }
-
public async Task> Handle(GetShiftPlanActivitiesQuery request, CancellationToken cancellationToken)
{
- var activities = await _repositoryWrapper.SetRepository()
+ var activities = await repositoryWrapper.SetRepository()
.TableNoTracking
.Where(a => a.ShiftPlanId == request.ShiftPlanId)
.Select(ActivityMapper.ProjectToSDto)
diff --git a/Brizco.Repository/Handlers/ShiftPlans/GetShiftPlansQueryHandler.cs b/Brizco.Repository/Handlers/ShiftPlans/GetShiftPlansQueryHandler.cs
index df074bf..6e22766 100644
--- a/Brizco.Repository/Handlers/ShiftPlans/GetShiftPlansQueryHandler.cs
+++ b/Brizco.Repository/Handlers/ShiftPlans/GetShiftPlansQueryHandler.cs
@@ -2,24 +2,16 @@
namespace Brizco.Repository.Handlers.ShiftPlans;
-public class GetShiftPlansQueryHandler : IRequestHandler>
+public class GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService) : IRequestHandler>
{
- private readonly IRepositoryWrapper _repositoryWrapper;
- private readonly ICurrentUserService _currentUserService;
-
- public GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
- {
- _repositoryWrapper = repositoryWrapper;
- _currentUserService = currentUserService;
- }
public async Task> Handle(GetShiftPlansQuery request, CancellationToken cancellationToken)
{
- if (_currentUserService.ComplexId == null)
+ if (currentUserService.ComplexId == null)
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);
- IQueryable baseQuery = _repositoryWrapper.SetRepository()
+ IQueryable baseQuery = repositoryWrapper.SetRepository()
.TableNoTracking
.OrderByDescending(s => s.CreatedAt)
.Where(s => s.ComplexId == complexId);
@@ -77,7 +69,7 @@ public class GetShiftPlansQueryHandler : IRequestHandler s.PlanFor.Date >= startOfNextWeek.Date && s.PlanFor.Date <= endOfNextWeek.Date)
.OrderByDescending(s => s.CreatedAt)
.Skip(request.Page * 15).Take(15)
@@ -138,13 +130,13 @@ public class GetShiftPlansQueryHandler : IRequestHandler()
+ var activitiesCount = await repositoryWrapper.SetRepository()
.TableNoTracking
.CountAsync(a => a.SetFor.Date == shiftPlan.PlanFor.Date && a.ShiftPlanId == shiftPlan.Id, cancellationToken);
- var doneActivitiesCount = await _repositoryWrapper.SetRepository()
+ var doneActivitiesCount = await repositoryWrapper.SetRepository()
.TableNoTracking
.CountAsync(a => a.Status == ActivityStatus.Done && a.SetFor.Date == shiftPlan.PlanFor.Date && a.ShiftPlanId == shiftPlan.Id, cancellationToken);
- var undoneActivitiesCount = await _repositoryWrapper.SetRepository()
+ var undoneActivitiesCount = await repositoryWrapper.SetRepository()
.TableNoTracking
.CountAsync(a => a.Status == ActivityStatus.UnDone && a.SetFor.Date == shiftPlan.PlanFor.Date && a.ShiftPlanId == shiftPlan.Id, cancellationToken);
shiftPlan.UndoneActivitiesCount = undoneActivitiesCount;
@@ -155,7 +147,7 @@ public class GetShiftPlansQueryHandler : IRequestHandler()
+ shiftPlan.StaffCount = await repositoryWrapper.SetRepository()
.TableNoTracking
.CountAsync(spu => spu.ShiftPlanId == shiftPlan.Id, cancellationToken);
diff --git a/Brizco.Repository/Handlers/Shifts/GetShiftsQueryHandler.cs b/Brizco.Repository/Handlers/Shifts/GetShiftsQueryHandler.cs
index 4a6d024..6f50d57 100644
--- a/Brizco.Repository/Handlers/Shifts/GetShiftsQueryHandler.cs
+++ b/Brizco.Repository/Handlers/Shifts/GetShiftsQueryHandler.cs
@@ -1,22 +1,13 @@
namespace Brizco.Repository.Handlers.Shifts;
-public class GetShiftPlansQueryHandler : IRequestHandler>
+public class GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper, UserManager userManager, ICurrentUserService currentUserService)
+ : IRequestHandler>
{
- private readonly IRepositoryWrapper _repositoryWrapper;
- private readonly UserManager _userManager;
- private readonly ICurrentUserService _currentUserService;
-
- public GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper,UserManager userManager, ICurrentUserService currentUserService)
- {
- _repositoryWrapper = repositoryWrapper;
- _userManager = userManager;
- _currentUserService = currentUserService;
- }
public async Task> Handle(GetShiftsQuery request, CancellationToken cancellationToken)
{
- if (_currentUserService.ComplexId == null)
+ if (currentUserService.ComplexId == null)
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);
List shifts;
@@ -24,46 +15,46 @@ public class GetShiftPlansQueryHandler : IRequestHandler().Entities
- join shift in _repositoryWrapper.SetRepository().Entities on shiftDay.ShiftId equals shift.Id
+ var originalShifts = from shiftDay in repositoryWrapper.SetRepository().Entities
+ join shift in repositoryWrapper.SetRepository().Entities on shiftDay.ShiftId equals shift.Id
where shiftDay.DayOfWeek == selectedDate.DayOfWeek && shift.ComplexId == complexId
- orderby shift.StartAt descending
+ orderby shift.StartAt
select shift;
shifts = await originalShifts.AsNoTracking().Select(ShiftMapper.ProjectToSDto).ToListAsync(cancellationToken);
foreach (var shift in shifts)
{
- var existedShiftPlan = await _repositoryWrapper.SetRepository()
+ var existedShiftPlan = await repositoryWrapper.SetRepository()
.TableNoTracking
.FirstOrDefaultAsync(s => s.ShiftId == shift.Id && s.PlanFor.Date == selectedDate.Date, cancellationToken);
if(existedShiftPlan == null)
continue;
- var supervisor = await _userManager.FindByIdAsync(existedShiftPlan.SupervisorId.ToString());
+ var supervisor = await userManager.FindByIdAsync(existedShiftPlan.SupervisorId.ToString());
if (supervisor != null)
shift.CurrentSupervisorFullName = supervisor.FirstName + " " + supervisor.LastName;
- var activitiesCount = await _repositoryWrapper.SetRepository()
+ var activitiesCount = await repositoryWrapper.SetRepository()
.TableNoTracking
.CountAsync(a => a.SetFor.Date == selectedDate.Date && a.ShiftPlanId == existedShiftPlan.Id, cancellationToken);
- var doneActivitiesCount = await _repositoryWrapper.SetRepository()
+ var doneActivitiesCount = await repositoryWrapper.SetRepository()
.TableNoTracking
.CountAsync(a => a.Status == ActivityStatus.Done && a.SetFor.Date == selectedDate.Date && a.ShiftPlanId == existedShiftPlan.Id, cancellationToken);
- var undoneActivitiesCount = await _repositoryWrapper.SetRepository()
+ var undoneActivitiesCount = await repositoryWrapper.SetRepository()
.TableNoTracking
.CountAsync(a => a.Status == ActivityStatus.UnDone && a.SetFor.Date == selectedDate.Date && a.ShiftPlanId == existedShiftPlan.Id, cancellationToken);
shift.UndoneActivitiesCount = undoneActivitiesCount;
shift.DoneActivitiesCount = doneActivitiesCount;
shift.TotalActivitiesCount = activitiesCount;
- switch (_currentUserService.RoleName)
+ switch (currentUserService.RoleName)
{
case null:
continue;
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");
- var existedSupervisorShiftPlan = await _repositoryWrapper.SetRepository()
+ var existedSupervisorShiftPlan = await repositoryWrapper.SetRepository()
.TableNoTracking
.FirstOrDefaultAsync(s => s.ShiftId == shift.Id && s.PlanFor.Date == selectedDate.Date && s.SupervisorId == userId, cancellationToken);
shift.IsCompleted = existedSupervisorShiftPlan?.IsCompleted ?? false;
@@ -84,9 +75,9 @@ public class GetShiftPlansQueryHandler : IRequestHandler().TableNoTracking
+ shifts = await repositoryWrapper.SetRepository().TableNoTracking
.Where(s => s.ComplexId == complexId)
- .OrderByDescending(s => s.StartAt)
+ .OrderBy(s => s.StartAt)
.Skip(request.Page * 15).Take(15)
.Select(ShiftMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
diff --git a/Brizco.Repository/Handlers/Users/GetStaffQueryHandler.cs b/Brizco.Repository/Handlers/Users/GetStaffQueryHandler.cs
new file mode 100644
index 0000000..c892d7e
--- /dev/null
+++ b/Brizco.Repository/Handlers/Users/GetStaffQueryHandler.cs
@@ -0,0 +1,106 @@
+using MD.PersianDateTime.Standard;
+using Activity = Brizco.Domain.Entities.Tasks.Activity;
+
+namespace Brizco.Repository.Handlers.Users;
+
+public class GetStaffQueryHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService) : IRequestHandler>
+{
+ public async Task> 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()
+ .TableNoTracking
+ .OrderByDescending(s => s.CreatedAt)
+ .Where(s => s.ComplexId == complexId);
+
+ List activities = new List();
+
+ 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();
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/MartenHandlers/NewsFeeds/ChangeNewsFeedPinCommandHandler.cs b/Brizco.Repository/MartenHandlers/NewsFeeds/ChangeNewsFeedPinCommandHandler.cs
new file mode 100644
index 0000000..47264ee
--- /dev/null
+++ b/Brizco.Repository/MartenHandlers/NewsFeeds/ChangeNewsFeedPinCommandHandler.cs
@@ -0,0 +1,20 @@
+namespace Brizco.Repository.MartenHandlers.NewsFeeds;
+
+public class ChangeNewsFeedPinCommandHandler(IMartenRepositoryWrapper martenRepositoryWrapper, ICurrentUserService currentUserService)
+ : IRequestHandler
+{
+ public async Task 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().GetEntityAsync(request.Id, cancellationToken);
+ if (ent.ComplexId != complexId)
+ throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong");
+ ent.IsPin = request.IsPin;
+ await martenRepositoryWrapper.SetRepository().AddOrUpdateEntityAsync(ent, cancellationToken);
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/MartenHandlers/NewsFeeds/CreateNewsFeedCommandHandler.cs b/Brizco.Repository/MartenHandlers/NewsFeeds/CreateNewsFeedCommandHandler.cs
new file mode 100644
index 0000000..cc919f5
--- /dev/null
+++ b/Brizco.Repository/MartenHandlers/NewsFeeds/CreateNewsFeedCommandHandler.cs
@@ -0,0 +1,23 @@
+namespace Brizco.Repository.MartenHandlers.NewsFeeds;
+
+public class CreateNewsFeedCommandHandler (IMartenRepositoryWrapper martenRepositoryWrapper , ICurrentUserService currentUserService)
+ : IRequestHandler
+{
+ public async Task 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().AddOrUpdateEntityAsync(newsFeed, cancellationToken);
+ return newsFeed.Id;
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/MartenHandlers/NewsFeeds/DeleteNewsFeedCommandHandler.cs b/Brizco.Repository/MartenHandlers/NewsFeeds/DeleteNewsFeedCommandHandler.cs
new file mode 100644
index 0000000..640031b
--- /dev/null
+++ b/Brizco.Repository/MartenHandlers/NewsFeeds/DeleteNewsFeedCommandHandler.cs
@@ -0,0 +1,19 @@
+namespace Brizco.Repository.MartenHandlers.NewsFeeds;
+
+public class DeleteNewsFeedCommandHandler(IMartenRepositoryWrapper martenRepositoryWrapper, ICurrentUserService currentUserService)
+ : IRequestHandler
+{
+ public async Task 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().GetEntityAsync(request.Id, cancellationToken);
+ if (ent.ComplexId != complexId)
+ throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong");
+ await martenRepositoryWrapper.SetRepository().RemoveEntityAsync(ent, cancellationToken);
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/MartenHandlers/NewsFeeds/GetNewsFeedsQueryHandler.cs b/Brizco.Repository/MartenHandlers/NewsFeeds/GetNewsFeedsQueryHandler.cs
new file mode 100644
index 0000000..6ccaa1b
--- /dev/null
+++ b/Brizco.Repository/MartenHandlers/NewsFeeds/GetNewsFeedsQueryHandler.cs
@@ -0,0 +1,22 @@
+namespace Brizco.Repository.MartenHandlers.NewsFeeds;
+
+public class GetNewsFeedsQueryHandler (IMartenRepositoryWrapper martenRepositoryWrapper,ICurrentUserService currentUserService) : IRequestHandler>
+{
+ public async Task> 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()
+ .GetQueryAsync(q=>q.ComplexId == complexId);
+
+ query = query.Skip(request.Page * count)
+ .Take(count)
+ .OrderByDescending(c=>c.CreatedAt);
+
+ return await query.ToListAsync(cancellationToken);
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/MartenHandlers/Notifications/CreateNotificationHandlerCommand.cs b/Brizco.Repository/MartenHandlers/Notifications/CreateNotificationHandlerCommand.cs
index de0b94e..e64fc41 100644
--- a/Brizco.Repository/MartenHandlers/Notifications/CreateNotificationHandlerCommand.cs
+++ b/Brizco.Repository/MartenHandlers/Notifications/CreateNotificationHandlerCommand.cs
@@ -1,22 +1,13 @@
-using Brizco.Domain.MartenEntities.Notifications;
+namespace Brizco.Repository.MartenHandlers.Notifications;
-namespace Brizco.Repository.MartenHandlers.Notifications;
-
-public class CreateNotificationHandlerCommand : IRequestHandler
+public class CreateNotificationHandlerCommand(IMartenRepositoryWrapper martenRepositoryWrapper, ICurrentUserService currentUserService)
+ : IRequestHandler
{
- private readonly IMartenRepositoryWrapper _martenRepositoryWrapper;
- private readonly ICurrentUserService _currentUserService;
-
- public CreateNotificationHandlerCommand(IMartenRepositoryWrapper martenRepositoryWrapper, ICurrentUserService currentUserService)
- {
- _martenRepositoryWrapper = martenRepositoryWrapper;
- _currentUserService = currentUserService;
- }
public async Task Handle(CreateNotificationCommand request, CancellationToken cancellationToken)
{
- if (_currentUserService.ComplexId == null)
+ if (currentUserService.ComplexId == 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");
var notification = new Notification
{
@@ -26,7 +17,7 @@ public class CreateNotificationHandlerCommand : IRequestHandler()
+ await martenRepositoryWrapper.SetRepository()
.AddOrUpdateEntityAsync(notification, cancellationToken);
return notification.Id;
}
diff --git a/Brizco.Repository/MartenHandlers/Notifications/GetNotificationsCountQueryHandler.cs b/Brizco.Repository/MartenHandlers/Notifications/GetNotificationsCountQueryHandler.cs
new file mode 100644
index 0000000..dd1f82f
--- /dev/null
+++ b/Brizco.Repository/MartenHandlers/Notifications/GetNotificationsCountQueryHandler.cs
@@ -0,0 +1,25 @@
+namespace Brizco.Repository.MartenHandlers.Notifications;
+
+public class GetNotificationsCountQueryHandler(IMartenRepositoryWrapper martenRepositoryWrapper,ICurrentUserService currentUserService) : IRequestHandler