diff --git a/.version b/.version index 961423f..20b894d 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -0.5.9.10 \ No newline at end of file +0.6.10.11 \ No newline at end of file diff --git a/Brizco.Api/AppSettings/appsettings.Development.json b/Brizco.Api/AppSettings/appsettings.Development.json index 7668ae8..4ac73f7 100644 --- a/Brizco.Api/AppSettings/appsettings.Development.json +++ b/Brizco.Api/AppSettings/appsettings.Development.json @@ -13,7 +13,7 @@ } }, "SiteSettings": { - "BaseUrl": "http://192.168.88.251:32769", + "BaseUrl": "http://192.168.1.12:32767", "KaveNegarApiKey": "3735494B4143727A794346457461576A2B4B6668414973424E333561505A694B", "UserSetting": { "Username": "root", diff --git a/Brizco.Api/Brizco.Api.csproj b/Brizco.Api/Brizco.Api.csproj index 74a8b5a..1723c35 100644 --- a/Brizco.Api/Brizco.Api.csproj +++ b/Brizco.Api/Brizco.Api.csproj @@ -6,8 +6,8 @@ enable Linux ..\docker-compose.dcproj - 0.5.9.10 - 0.5.9.10 + 0.6.10.11 + 0.6.10.11 diff --git a/Brizco.Api/Controllers/ReportController.cs b/Brizco.Api/Controllers/ReportController.cs index d70490b..48f8e66 100644 --- a/Brizco.Api/Controllers/ReportController.cs +++ b/Brizco.Api/Controllers/ReportController.cs @@ -1,5 +1,4 @@ using Brizco.Core.CoreServices.ReportServices.Commands; -using MediatR; namespace Brizco.Api.Controllers; diff --git a/Brizco.Common/Brizco.Common.csproj b/Brizco.Common/Brizco.Common.csproj index 295d5ba..c2f2938 100644 --- a/Brizco.Common/Brizco.Common.csproj +++ b/Brizco.Common/Brizco.Common.csproj @@ -1,6 +1,6 @@  - + - + diff --git a/Brizco.Core/CoreServices/PageService.cs b/Brizco.Core/CoreServices/PageService.cs index c99c464..0a0a2fd 100644 --- a/Brizco.Core/CoreServices/PageService.cs +++ b/Brizco.Core/CoreServices/PageService.cs @@ -50,7 +50,14 @@ public class PageService : IPageService TodayStaffNames = names, TotalStaffToday = todayShiftPlans.SelectMany(sp => sp.Users).Count() }; - + + var currentShift = todayShiftPlans.FirstOrDefault(s => s.EndAt >= DateTime.Now.TimeOfDay && s.StartAt <= DateTime.Now.TimeOfDay); + if (currentShift != null) + { + page.CurrentShift = currentShift.ShiftTitle; + page.CurrentPosition = currentShift.Users.FirstOrDefault(f => f.UserId == userId)?.PositionName ?? string.Empty; + } + if (_currentUserService.Permissions != null) { int totalStepCount = 0; @@ -61,8 +68,8 @@ public class PageService : IPageService totalStepCount++; var hasRoutine = await _repositoryWrapper.SetRepository() .TableNoTracking - .AnyAsync(r=>r.ComplexId== complexId, cancellationToken); - if(hasRoutine) + .AnyAsync(r => r.ComplexId == complexId, cancellationToken); + if (hasRoutine) completeStepCount++; else { diff --git a/Brizco.Core/CoreServices/ReportServices/ShiftPlanReportCommandHandler.cs b/Brizco.Core/CoreServices/ReportServices/ShiftPlanReportCommandHandler.cs index 485e541..eb4e455 100644 --- a/Brizco.Core/CoreServices/ReportServices/ShiftPlanReportCommandHandler.cs +++ b/Brizco.Core/CoreServices/ReportServices/ShiftPlanReportCommandHandler.cs @@ -1,5 +1,6 @@ using Brizco.Domain.Entities.Shift; using Brizco.Domain.Entities.Task; +using MD.PersianDateTime.Standard; namespace Brizco.Core.CoreServices.ReportServices; public class ShiftPlanReportCommandHandler : IRequestHandler @@ -52,11 +53,16 @@ public class ShiftPlanReportCommandHandler : IRequestHandler - + - + diff --git a/Brizco.Domain/Dtos/PageDto/AppDashboardPageDto.cs b/Brizco.Domain/Dtos/PageDto/AppDashboardPageDto.cs index 95f7f72..a3d174d 100644 --- a/Brizco.Domain/Dtos/PageDto/AppDashboardPageDto.cs +++ b/Brizco.Domain/Dtos/PageDto/AppDashboardPageDto.cs @@ -8,6 +8,9 @@ public class AppDashboardPageDto public int TotalShiftToday { get; set; } public int TotalStaffToday { get; set; } public List TodayStaffNames { get; set; } = new(); + public string CurrentPosition { get; set; } = string.Empty; + public string CurrentShift { get; set; } = string.Empty; + public string CurrentSignUpStep { get; set; } = string.Empty; public int SignUpCompletePercent { get; set; } diff --git a/Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs b/Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs index bf23146..96b4954 100644 --- a/Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs +++ b/Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs @@ -1,6 +1,4 @@ -using Brizco.Domain.Entities.Task; - -namespace Brizco.Domain.Dtos.SmallDtos; +namespace Brizco.Domain.Dtos.SmallDtos; public class ActivitySDto : BaseDto { diff --git a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs index f129675..56411c2 100644 --- a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs +++ b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs @@ -13,6 +13,8 @@ public class ShiftPlanSDto : BaseDto public string CompleteDescription { get; set; } = string.Empty; public Guid ShiftId { get; set; } public string ShiftTitle { get; set; } = string.Empty; + public TimeSpan StartAt { get; set; } + public TimeSpan EndAt { get; set; } public List Users { get; set; } = new(); } \ No newline at end of file diff --git a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanUserSDto.cs b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanUserSDto.cs index 98a8f7b..800bff1 100644 --- a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanUserSDto.cs +++ b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanUserSDto.cs @@ -1,6 +1,4 @@ -using Brizco.Domain.Entities.Shift; - -namespace Brizco.Domain.Dtos.SmallDtos; +namespace Brizco.Domain.Dtos.SmallDtos; public class ShiftPlanUserSDto : BaseDto { diff --git a/Brizco.Domain/Dtos/SmallDtos/TaskSDto.cs b/Brizco.Domain/Dtos/SmallDtos/TaskSDto.cs index 96d5042..57ad3a1 100644 --- a/Brizco.Domain/Dtos/SmallDtos/TaskSDto.cs +++ b/Brizco.Domain/Dtos/SmallDtos/TaskSDto.cs @@ -14,6 +14,7 @@ public class TaskSDto : BaseDto public List Shifts { get; set; } = new(); public List Routines { get; set; } = new(); public List Positions { get; set; } = new(); + public List Days { get; set; } = new(); public int Amount { get; set; } public PurchaseAmountType AmountType { get; set; } diff --git a/Brizco.Domain/Enums/DateTimeQueryFilter.cs b/Brizco.Domain/Enums/DateTimeQueryFilter.cs index 1bd4065..634fa3c 100644 --- a/Brizco.Domain/Enums/DateTimeQueryFilter.cs +++ b/Brizco.Domain/Enums/DateTimeQueryFilter.cs @@ -7,6 +7,8 @@ public enum DateTimeQueryFilter Yesterday = 2, PastWeek = 10, NextWeek = 11, + ThisWeek = 12, PastMonth = 20, - NextMonth = 21 + NextMonth = 21, + ThisMonth = 22, } \ No newline at end of file diff --git a/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs b/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs index 3b63c1d..f2986db 100644 --- a/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs +++ b/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs @@ -90,6 +90,8 @@ namespace Brizco.Domain.Mappers 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 }; @@ -109,6 +111,8 @@ namespace Brizco.Domain.Mappers 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; return result; @@ -123,6 +127,8 @@ namespace Brizco.Domain.Mappers 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() { ShiftPlanId = p18.ShiftPlanId, diff --git a/Brizco.Domain/Mappers/TaskMapper.g.cs b/Brizco.Domain/Mappers/TaskMapper.g.cs index 866fa14..dc1a447 100644 --- a/Brizco.Domain/Mappers/TaskMapper.g.cs +++ b/Brizco.Domain/Mappers/TaskMapper.g.cs @@ -31,246 +31,252 @@ namespace Brizco.Domain.Mappers Amount = p1.Amount, AmountType = p1.AmountType, Shifts = funcMain1(p1.Shifts), - Routines = funcMain2(p1.Routines), - Positions = funcMain3(p1.Positions), + Days = funcMain2(p1.Days), + Routines = funcMain3(p1.Routines), + Positions = funcMain4(p1.Positions), Id = p1.Id }; } - public static Task AdaptTo(this TaskSDto p5, Task p6) + public static Task AdaptTo(this TaskSDto p6, Task p7) { - if (p5 == null) + if (p6 == null) { return null; } - Task result = p6 ?? new Task(); + Task result = p7 ?? new Task(); - result.Type = p5.Type; - result.Title = p5.Title; - result.Description = p5.Description; - result.IsDisposable = p5.IsDisposable; - result.SetFor = Convert.ToDateTime(p5.SetFor); - result.HasDisposed = p5.HasDisposed; - result.ScheduleType = p5.ScheduleType; - result.ComplexId = p5.ComplexId; - result.Complex = funcMain4(new Never(), result.Complex, p5); - result.Amount = p5.Amount; - result.AmountType = p5.AmountType; - result.Shifts = funcMain5(p5.Shifts, result.Shifts); - result.Routines = funcMain6(p5.Routines, result.Routines); - result.Positions = funcMain7(p5.Positions, result.Positions); - result.Id = p5.Id; + result.Type = p6.Type; + result.Title = p6.Title; + result.Description = p6.Description; + result.IsDisposable = p6.IsDisposable; + result.SetFor = Convert.ToDateTime(p6.SetFor); + result.HasDisposed = p6.HasDisposed; + result.ScheduleType = p6.ScheduleType; + result.ComplexId = p6.ComplexId; + result.Complex = funcMain5(new Never(), result.Complex, p6); + result.Amount = p6.Amount; + result.AmountType = p6.AmountType; + result.Shifts = funcMain6(p6.Shifts, result.Shifts); + result.Days = funcMain7(p6.Days, result.Days); + result.Routines = funcMain8(p6.Routines, result.Routines); + result.Positions = funcMain9(p6.Positions, result.Positions); + result.Id = p6.Id; return result; } - public static Expression> ProjectToTask => p15 => new Task() + public static Expression> ProjectToTask => p18 => new Task() { - Type = p15.Type, - Title = p15.Title, - Description = p15.Description, - IsDisposable = p15.IsDisposable, - SetFor = Convert.ToDateTime(p15.SetFor), - HasDisposed = p15.HasDisposed, - ScheduleType = p15.ScheduleType, - ComplexId = p15.ComplexId, - Complex = new Complex() {Id = p15.ComplexId}, - Amount = p15.Amount, - AmountType = p15.AmountType, - Shifts = p15.Shifts.Select(p16 => (TaskShift)Convert.ChangeType((object)p16, typeof(TaskShift))).ToList(), - Routines = p15.Routines.Select(p17 => (TaskRoutine)Convert.ChangeType((object)p17, typeof(TaskRoutine))).ToList(), - Positions = p15.Positions.Select(p18 => (TaskPosition)Convert.ChangeType((object)p18, typeof(TaskPosition))).ToList(), - Id = p15.Id + Type = p18.Type, + Title = p18.Title, + Description = p18.Description, + IsDisposable = p18.IsDisposable, + SetFor = Convert.ToDateTime(p18.SetFor), + HasDisposed = p18.HasDisposed, + ScheduleType = p18.ScheduleType, + ComplexId = p18.ComplexId, + Complex = new Complex() {Id = p18.ComplexId}, + Amount = p18.Amount, + AmountType = p18.AmountType, + Shifts = p18.Shifts.Select(p19 => (TaskShift)Convert.ChangeType((object)p19, typeof(TaskShift))).ToList(), + Days = p18.Days.Select(p20 => (TaskDay)Convert.ChangeType((object)p20, typeof(TaskDay))).ToList(), + Routines = p18.Routines.Select(p21 => (TaskRoutine)Convert.ChangeType((object)p21, typeof(TaskRoutine))).ToList(), + Positions = p18.Positions.Select(p22 => (TaskPosition)Convert.ChangeType((object)p22, typeof(TaskPosition))).ToList(), + Id = p18.Id }; - public static TaskSDto AdaptToSDto(this Task p19) + public static TaskSDto AdaptToSDto(this Task p23) { - return p19 == null ? null : new TaskSDto() + return p23 == null ? null : new TaskSDto() { - Type = p19.Type, - Title = p19.Title, - Description = p19.Description, - IsDisposable = p19.IsDisposable, - SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p19.SetFor), - HasDisposed = p19.HasDisposed, - ComplexId = p19.ComplexId, - ScheduleType = p19.ScheduleType, - Shifts = funcMain8(p19.Shifts.Select(funcMain9)), - Routines = funcMain10(p19.Routines.Select(funcMain11)), - Positions = funcMain12(p19.Positions.Select(funcMain13)), - Amount = p19.Amount, - AmountType = p19.AmountType, - Id = p19.Id + Type = p23.Type, + Title = p23.Title, + Description = p23.Description, + IsDisposable = p23.IsDisposable, + SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p23.SetFor), + HasDisposed = p23.HasDisposed, + ComplexId = p23.ComplexId, + ScheduleType = p23.ScheduleType, + Shifts = funcMain10(p23.Shifts.Select(funcMain11)), + Routines = funcMain12(p23.Routines.Select(funcMain13)), + Positions = funcMain14(p23.Positions.Select(funcMain15)), + Days = funcMain16(p23.Days.Select(funcMain17).ToList()), + Amount = p23.Amount, + AmountType = p23.AmountType, + Id = p23.Id }; } - public static TaskSDto AdaptTo(this Task p23, TaskSDto p24) + public static TaskSDto AdaptTo(this Task p28, TaskSDto p29) { - if (p23 == null) + if (p28 == null) { return null; } - TaskSDto result = p24 ?? new TaskSDto(); + TaskSDto result = p29 ?? new TaskSDto(); - result.Type = p23.Type; - result.Title = p23.Title; - result.Description = p23.Description; - result.IsDisposable = p23.IsDisposable; - result.SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p23.SetFor); - result.HasDisposed = p23.HasDisposed; - result.ComplexId = p23.ComplexId; - result.ScheduleType = p23.ScheduleType; - result.Shifts = funcMain14(p23.Shifts.Select(funcMain9), result.Shifts); - result.Routines = funcMain15(p23.Routines.Select(funcMain11), result.Routines); - result.Positions = funcMain16(p23.Positions.Select(funcMain13), result.Positions); - result.Amount = p23.Amount; - result.AmountType = p23.AmountType; - result.Id = p23.Id; + result.Type = p28.Type; + result.Title = p28.Title; + result.Description = p28.Description; + result.IsDisposable = p28.IsDisposable; + result.SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p28.SetFor); + result.HasDisposed = p28.HasDisposed; + result.ComplexId = p28.ComplexId; + result.ScheduleType = p28.ScheduleType; + result.Shifts = funcMain18(p28.Shifts.Select(funcMain11), result.Shifts); + result.Routines = funcMain19(p28.Routines.Select(funcMain13), result.Routines); + result.Positions = funcMain20(p28.Positions.Select(funcMain15), result.Positions); + result.Days = funcMain21(p28.Days.Select(funcMain17).ToList(), result.Days); + result.Amount = p28.Amount; + result.AmountType = p28.AmountType; + result.Id = p28.Id; return result; } - public static Expression> ProjectToSDto => p31 => new TaskSDto() + public static Expression> ProjectToSDto => p38 => new TaskSDto() { - Type = p31.Type, - Title = p31.Title, - Description = p31.Description, - IsDisposable = p31.IsDisposable, - SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p31.SetFor), - HasDisposed = p31.HasDisposed, - ComplexId = p31.ComplexId, - ScheduleType = p31.ScheduleType, - Shifts = (List)p31.Shifts.Select(d => d.Shift != null ? d.Shift.Title : string.Empty), - Routines = (List)p31.Routines.Select(d => d.Routine != null ? d.Routine.Name : string.Empty), - Positions = (List)p31.Positions.Select(d => d.Position != null ? d.Position.Name : string.Empty), - Amount = p31.Amount, - AmountType = p31.AmountType, - Id = p31.Id + Type = p38.Type, + Title = p38.Title, + Description = p38.Description, + IsDisposable = p38.IsDisposable, + SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p38.SetFor), + HasDisposed = p38.HasDisposed, + ComplexId = p38.ComplexId, + ScheduleType = p38.ScheduleType, + Shifts = (List)p38.Shifts.Select(d => d.Shift != null ? d.Shift.Title : string.Empty), + Routines = (List)p38.Routines.Select(d => d.Routine != null ? d.Routine.Name : string.Empty), + Positions = (List)p38.Positions.Select(d => d.Position != null ? d.Position.Name : string.Empty), + Days = p38.Days.Select(d => d.DayOfWeek.GetPersianDayOfWeek()).ToList(), + Amount = p38.Amount, + AmountType = p38.AmountType, + Id = p38.Id }; - public static Task AdaptToTask(this TaskLDto p32) + public static Task AdaptToTask(this TaskLDto p39) { - return p32 == null ? null : new Task() + return p39 == null ? null : new Task() { - Type = p32.Type, - Title = p32.Title, - Description = p32.Description, - IsDisposable = p32.IsDisposable, - SetFor = Convert.ToDateTime(p32.SetFor), - HasDisposed = p32.HasDisposed, - ScheduleType = p32.ScheduleType, - Amount = p32.Amount, - AmountType = p32.AmountType, - Shifts = funcMain17(p32.Shifts), - Days = funcMain18(p32.Days), - Routines = funcMain19(p32.Routines), - Positions = funcMain20(p32.Positions), - Id = p32.Id + Type = p39.Type, + Title = p39.Title, + Description = p39.Description, + IsDisposable = p39.IsDisposable, + SetFor = Convert.ToDateTime(p39.SetFor), + HasDisposed = p39.HasDisposed, + ScheduleType = p39.ScheduleType, + Amount = p39.Amount, + AmountType = p39.AmountType, + Shifts = funcMain22(p39.Shifts), + Days = funcMain23(p39.Days), + Routines = funcMain24(p39.Routines), + Positions = funcMain25(p39.Positions), + Id = p39.Id }; } - public static Task AdaptTo(this TaskLDto p37, Task p38) + public static Task AdaptTo(this TaskLDto p44, Task p45) { - if (p37 == null) + if (p44 == null) { return null; } - Task result = p38 ?? new Task(); + Task result = p45 ?? new Task(); - result.Type = p37.Type; - result.Title = p37.Title; - result.Description = p37.Description; - result.IsDisposable = p37.IsDisposable; - result.SetFor = Convert.ToDateTime(p37.SetFor); - result.HasDisposed = p37.HasDisposed; - result.ScheduleType = p37.ScheduleType; - result.Amount = p37.Amount; - result.AmountType = p37.AmountType; - result.Shifts = funcMain21(p37.Shifts, result.Shifts); - result.Days = funcMain22(p37.Days, result.Days); - result.Routines = funcMain23(p37.Routines, result.Routines); - result.Positions = funcMain24(p37.Positions, result.Positions); - result.Id = p37.Id; + result.Type = p44.Type; + result.Title = p44.Title; + result.Description = p44.Description; + result.IsDisposable = p44.IsDisposable; + result.SetFor = Convert.ToDateTime(p44.SetFor); + result.HasDisposed = p44.HasDisposed; + result.ScheduleType = p44.ScheduleType; + result.Amount = p44.Amount; + result.AmountType = p44.AmountType; + result.Shifts = funcMain26(p44.Shifts, result.Shifts); + result.Days = funcMain27(p44.Days, result.Days); + result.Routines = funcMain28(p44.Routines, result.Routines); + result.Positions = funcMain29(p44.Positions, result.Positions); + result.Id = p44.Id; return result; } - public static TaskLDto AdaptToLDto(this Task p47) + public static TaskLDto AdaptToLDto(this Task p54) { - return p47 == null ? null : new TaskLDto() + return p54 == null ? null : new TaskLDto() { - Type = p47.Type, - Title = p47.Title, - Description = p47.Description, - IsDisposable = p47.IsDisposable, - SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p47.SetFor), - HasDisposed = p47.HasDisposed, - ScheduleType = p47.ScheduleType, - Amount = p47.Amount, - AmountType = p47.AmountType, - Shifts = funcMain25(p47.Shifts), - Positions = funcMain26(p47.Positions), - Days = funcMain27(p47.Days), - Routines = funcMain28(p47.Routines), - Id = p47.Id + Type = p54.Type, + Title = p54.Title, + Description = p54.Description, + IsDisposable = p54.IsDisposable, + SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p54.SetFor), + HasDisposed = p54.HasDisposed, + ScheduleType = p54.ScheduleType, + Amount = p54.Amount, + AmountType = p54.AmountType, + Shifts = funcMain30(p54.Shifts), + Positions = funcMain31(p54.Positions), + Days = funcMain32(p54.Days), + Routines = funcMain33(p54.Routines), + Id = p54.Id }; } - public static TaskLDto AdaptTo(this Task p52, TaskLDto p53) + public static TaskLDto AdaptTo(this Task p59, TaskLDto p60) { - if (p52 == null) + if (p59 == null) { return null; } - TaskLDto result = p53 ?? new TaskLDto(); + TaskLDto result = p60 ?? new TaskLDto(); - result.Type = p52.Type; - result.Title = p52.Title; - result.Description = p52.Description; - result.IsDisposable = p52.IsDisposable; - result.SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p52.SetFor); - result.HasDisposed = p52.HasDisposed; - result.ScheduleType = p52.ScheduleType; - result.Amount = p52.Amount; - result.AmountType = p52.AmountType; - result.Shifts = funcMain29(p52.Shifts, result.Shifts); - result.Positions = funcMain30(p52.Positions, result.Positions); - result.Days = funcMain31(p52.Days, result.Days); - result.Routines = funcMain32(p52.Routines, result.Routines); - result.Id = p52.Id; + result.Type = p59.Type; + result.Title = p59.Title; + result.Description = p59.Description; + result.IsDisposable = p59.IsDisposable; + result.SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p59.SetFor); + result.HasDisposed = p59.HasDisposed; + result.ScheduleType = p59.ScheduleType; + result.Amount = p59.Amount; + result.AmountType = p59.AmountType; + result.Shifts = funcMain34(p59.Shifts, result.Shifts); + result.Positions = funcMain35(p59.Positions, result.Positions); + result.Days = funcMain36(p59.Days, result.Days); + result.Routines = funcMain37(p59.Routines, result.Routines); + result.Id = p59.Id; return result; } - public static Expression> ProjectToLDto => p62 => new TaskLDto() + public static Expression> ProjectToLDto => p69 => new TaskLDto() { - Type = p62.Type, - Title = p62.Title, - Description = p62.Description, - IsDisposable = p62.IsDisposable, - SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p62.SetFor), - HasDisposed = p62.HasDisposed, - ScheduleType = p62.ScheduleType, - Amount = p62.Amount, - AmountType = p62.AmountType, - Shifts = p62.Shifts.Select(p63 => new TaskShiftSDto() + Type = p69.Type, + Title = p69.Title, + Description = p69.Description, + IsDisposable = p69.IsDisposable, + SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p69.SetFor), + HasDisposed = p69.HasDisposed, + ScheduleType = p69.ScheduleType, + Amount = p69.Amount, + AmountType = p69.AmountType, + Shifts = p69.Shifts.Select(p70 => new TaskShiftSDto() { - ShiftId = p63.ShiftId, - ShiftName = p63.Shift != null ? p63.Shift.Title : string.Empty, - TaskId = p63.TaskId, - TaskTitle = p63.Task != null ? p63.Task.Title : string.Empty, - Id = p63.Id + ShiftId = p70.ShiftId, + ShiftName = p70.Shift != null ? p70.Shift.Title : string.Empty, + TaskId = p70.TaskId, + TaskTitle = p70.Task != null ? p70.Task.Title : string.Empty, + Id = p70.Id }).ToList(), - Positions = p62.Positions.Select(p64 => new TaskPositionSDto() + Positions = p69.Positions.Select(p71 => new TaskPositionSDto() { - PositionId = p64.PositionId, - PositionName = p64.Position != null ? p64.Position.Name : string.Empty, - TaskId = p64.TaskId, - Id = p64.Id + PositionId = p71.PositionId, + PositionName = p71.Position != null ? p71.Position.Name : string.Empty, + TaskId = p71.TaskId, + Id = p71.Id }).ToList(), - Days = p62.Days.Select(p65 => new TaskDaySDto() + Days = p69.Days.Select(p72 => new TaskDaySDto() { - DayOfWeek = p65.DayOfWeek, - TaskId = p65.TaskId, - Id = p65.Id + DayOfWeek = p72.DayOfWeek, + TaskId = p72.TaskId, + Id = p72.Id }).ToList(), - Routines = p62.Routines.Select(p66 => new TaskRoutineSDto() + Routines = p69.Routines.Select(p73 => new TaskRoutineSDto() { - TaskId = p66.TaskId, - RoutineId = p66.RoutineId, - Id = p66.Id + TaskId = p73.TaskId, + RoutineId = p73.RoutineId, + Id = p73.Id }).ToList(), - Id = p62.Id + Id = p69.Id }; private static List funcMain1(List p2) @@ -294,13 +300,13 @@ namespace Brizco.Domain.Mappers } - private static List funcMain2(List p3) + private static List funcMain2(List p3) { if (p3 == null) { return null; } - List result = new List(p3.Count); + List result = new List(p3.Count); int i = 0; int len = p3.Count; @@ -308,20 +314,20 @@ namespace Brizco.Domain.Mappers while (i < len) { string item = p3[i]; - result.Add(item == null ? null : (TaskRoutine)Convert.ChangeType((object)item, typeof(TaskRoutine))); + result.Add(item == null ? null : (TaskDay)Convert.ChangeType((object)item, typeof(TaskDay))); i++; } return result; } - private static List funcMain3(List p4) + private static List funcMain3(List p4) { if (p4 == null) { return null; } - List result = new List(p4.Count); + List result = new List(p4.Count); int i = 0; int len = p4.Count; @@ -329,57 +335,6 @@ namespace Brizco.Domain.Mappers while (i < len) { string item = p4[i]; - result.Add(item == null ? null : (TaskPosition)Convert.ChangeType((object)item, typeof(TaskPosition))); - i++; - } - return result; - - } - - private static Complex funcMain4(Never p7, Complex p8, TaskSDto p5) - { - Complex result = p8 ?? new Complex(); - - result.Id = p5.ComplexId; - return result; - - } - - private static List funcMain5(List p9, List p10) - { - if (p9 == null) - { - return null; - } - List result = new List(p9.Count); - - int i = 0; - int len = p9.Count; - - while (i < len) - { - string item = p9[i]; - result.Add(item == null ? null : (TaskShift)Convert.ChangeType((object)item, typeof(TaskShift))); - i++; - } - return result; - - } - - private static List funcMain6(List p11, List p12) - { - if (p11 == null) - { - return null; - } - List result = new List(p11.Count); - - int i = 0; - int len = p11.Count; - - while (i < len) - { - string item = p11[i]; result.Add(item == null ? null : (TaskRoutine)Convert.ChangeType((object)item, typeof(TaskRoutine))); i++; } @@ -387,20 +342,20 @@ namespace Brizco.Domain.Mappers } - private static List funcMain7(List p13, List p14) + private static List funcMain4(List p5) { - if (p13 == null) + if (p5 == null) { return null; } - List result = new List(p13.Count); + List result = new List(p5.Count); int i = 0; - int len = p13.Count; + int len = p5.Count; while (i < len) { - string item = p13[i]; + string item = p5[i]; result.Add(item == null ? null : (TaskPosition)Convert.ChangeType((object)item, typeof(TaskPosition))); i++; } @@ -408,15 +363,108 @@ namespace Brizco.Domain.Mappers } - private static List funcMain8(IEnumerable p20) + private static Complex funcMain5(Never p8, Complex p9, TaskSDto p6) { - if (p20 == null) + Complex result = p9 ?? new Complex(); + + result.Id = p6.ComplexId; + return result; + + } + + private static List funcMain6(List p10, List p11) + { + if (p10 == null) + { + return null; + } + List result = new List(p10.Count); + + int i = 0; + int len = p10.Count; + + while (i < len) + { + string item = p10[i]; + result.Add(item == null ? null : (TaskShift)Convert.ChangeType((object)item, typeof(TaskShift))); + i++; + } + return result; + + } + + private static List funcMain7(List p12, List p13) + { + if (p12 == null) + { + return null; + } + List result = new List(p12.Count); + + int i = 0; + int len = p12.Count; + + while (i < len) + { + string item = p12[i]; + result.Add(item == null ? null : (TaskDay)Convert.ChangeType((object)item, typeof(TaskDay))); + i++; + } + return result; + + } + + private static List funcMain8(List p14, List p15) + { + if (p14 == null) + { + return null; + } + List result = new List(p14.Count); + + int i = 0; + int len = p14.Count; + + while (i < len) + { + string item = p14[i]; + result.Add(item == null ? null : (TaskRoutine)Convert.ChangeType((object)item, typeof(TaskRoutine))); + i++; + } + return result; + + } + + private static List funcMain9(List p16, List p17) + { + if (p16 == null) + { + return null; + } + List result = new List(p16.Count); + + int i = 0; + int len = p16.Count; + + while (i < len) + { + string item = p16[i]; + result.Add(item == null ? null : (TaskPosition)Convert.ChangeType((object)item, typeof(TaskPosition))); + i++; + } + return result; + + } + + private static List funcMain10(IEnumerable p24) + { + if (p24 == null) { return null; } List result = new List(); - IEnumerator enumerator = p20.GetEnumerator(); + IEnumerator enumerator = p24.GetEnumerator(); while (enumerator.MoveNext()) { @@ -427,60 +475,12 @@ namespace Brizco.Domain.Mappers } - private static string funcMain9(TaskShift d) + private static string funcMain11(TaskShift d) { return d.Shift != null ? d.Shift.Title : string.Empty; } - private static List funcMain10(IEnumerable p21) - { - if (p21 == null) - { - return null; - } - List result = new List(); - - IEnumerator enumerator = p21.GetEnumerator(); - - while (enumerator.MoveNext()) - { - string item = enumerator.Current; - result.Add(item); - } - return result; - - } - - private static string funcMain11(TaskRoutine d) - { - return d.Routine != null ? d.Routine.Name : string.Empty; - } - - private static List funcMain12(IEnumerable p22) - { - if (p22 == null) - { - return null; - } - List result = new List(); - - IEnumerator enumerator = p22.GetEnumerator(); - - while (enumerator.MoveNext()) - { - string item = enumerator.Current; - result.Add(item); - } - return result; - - } - - private static string funcMain13(TaskPosition d) - { - return d.Position != null ? d.Position.Name : string.Empty; - } - - private static List funcMain14(IEnumerable p25, List p26) + private static List funcMain12(IEnumerable p25) { if (p25 == null) { @@ -499,174 +499,153 @@ namespace Brizco.Domain.Mappers } - private static List funcMain15(IEnumerable p27, List p28) + private static string funcMain13(TaskRoutine d) + { + return d.Routine != null ? d.Routine.Name : string.Empty; + } + + private static List funcMain14(IEnumerable p26) + { + if (p26 == null) + { + return null; + } + List result = new List(); + + IEnumerator enumerator = p26.GetEnumerator(); + + while (enumerator.MoveNext()) + { + string item = enumerator.Current; + result.Add(item); + } + return result; + + } + + private static string funcMain15(TaskPosition d) + { + return d.Position != null ? d.Position.Name : string.Empty; + } + + private static List funcMain16(List p27) { if (p27 == null) { return null; } - List result = new List(); - - IEnumerator enumerator = p27.GetEnumerator(); - - while (enumerator.MoveNext()) - { - string item = enumerator.Current; - result.Add(item); - } - return result; - - } - - private static List funcMain16(IEnumerable p29, List p30) - { - if (p29 == null) - { - return null; - } - List result = new List(); - - IEnumerator enumerator = p29.GetEnumerator(); - - while (enumerator.MoveNext()) - { - string item = enumerator.Current; - result.Add(item); - } - return result; - - } - - private static List funcMain17(List p33) - { - if (p33 == null) - { - return null; - } - List result = new List(p33.Count); + List result = new List(p27.Count); int i = 0; - int len = p33.Count; + int len = p27.Count; while (i < len) { - TaskShiftSDto item = p33[i]; - result.Add(item == null ? null : new TaskShift() - { - TaskId = item.TaskId, - Task = new Task() - { - Title = item.TaskTitle, - Id = item.TaskId - }, - ShiftId = item.ShiftId, - Shift = new Shift() {Id = item.ShiftId}, - Id = item.Id - }); + string item = p27[i]; + result.Add(item); i++; } return result; } - private static List funcMain18(List p34) + private static string funcMain17(TaskDay d) + { + return d.DayOfWeek.GetPersianDayOfWeek(); + } + + private static List funcMain18(IEnumerable p30, List p31) + { + if (p30 == null) + { + return null; + } + List result = new List(); + + IEnumerator enumerator = p30.GetEnumerator(); + + while (enumerator.MoveNext()) + { + string item = enumerator.Current; + result.Add(item); + } + return result; + + } + + private static List funcMain19(IEnumerable p32, List p33) + { + if (p32 == null) + { + return null; + } + List result = new List(); + + IEnumerator enumerator = p32.GetEnumerator(); + + while (enumerator.MoveNext()) + { + string item = enumerator.Current; + result.Add(item); + } + return result; + + } + + private static List funcMain20(IEnumerable p34, List p35) { if (p34 == null) { return null; } - List result = new List(p34.Count); + List result = new List(); - int i = 0; - int len = p34.Count; + IEnumerator enumerator = p34.GetEnumerator(); - while (i < len) + while (enumerator.MoveNext()) { - TaskDaySDto item = p34[i]; - result.Add(item == null ? null : new TaskDay() - { - DayOfWeek = item.DayOfWeek, - TaskId = item.TaskId, - Id = item.Id - }); - i++; + string item = enumerator.Current; + result.Add(item); } return result; } - private static List funcMain19(List p35) - { - if (p35 == null) - { - return null; - } - List result = new List(p35.Count); - - int i = 0; - int len = p35.Count; - - while (i < len) - { - TaskRoutineSDto item = p35[i]; - result.Add(item == null ? null : new TaskRoutine() - { - TaskId = item.TaskId, - RoutineId = item.RoutineId, - Id = item.Id - }); - i++; - } - return result; - - } - - private static List funcMain20(List p36) + private static List funcMain21(List p36, List p37) { if (p36 == null) { return null; } - List result = new List(p36.Count); + List result = new List(p36.Count); int i = 0; int len = p36.Count; while (i < len) { - TaskPositionSDto item = p36[i]; - result.Add(item == null ? null : new TaskPosition() - { - PositionId = item.PositionId, - Position = new Position() - { - Name = item.PositionName, - Id = item.PositionId - }, - TaskId = item.TaskId, - Task = new Task() {Id = item.TaskId}, - Id = item.Id - }); + string item = p36[i]; + result.Add(item); i++; } return result; } - private static List funcMain21(List p39, List p40) + private static List funcMain22(List p40) { - if (p39 == null) + if (p40 == null) { return null; } - List result = new List(p39.Count); + List result = new List(p40.Count); int i = 0; - int len = p39.Count; + int len = p40.Count; while (i < len) { - TaskShiftSDto item = p39[i]; + TaskShiftSDto item = p40[i]; result.Add(item == null ? null : new TaskShift() { TaskId = item.TaskId, @@ -685,7 +664,7 @@ namespace Brizco.Domain.Mappers } - private static List funcMain22(List p41, List p42) + private static List funcMain23(List p41) { if (p41 == null) { @@ -711,20 +690,20 @@ namespace Brizco.Domain.Mappers } - private static List funcMain23(List p43, List p44) + private static List funcMain24(List p42) { - if (p43 == null) + if (p42 == null) { return null; } - List result = new List(p43.Count); + List result = new List(p42.Count); int i = 0; - int len = p43.Count; + int len = p42.Count; while (i < len) { - TaskRoutineSDto item = p43[i]; + TaskRoutineSDto item = p42[i]; result.Add(item == null ? null : new TaskRoutine() { TaskId = item.TaskId, @@ -737,20 +716,20 @@ namespace Brizco.Domain.Mappers } - private static List funcMain24(List p45, List p46) + private static List funcMain25(List p43) { - if (p45 == null) + if (p43 == null) { return null; } - List result = new List(p45.Count); + List result = new List(p43.Count); int i = 0; - int len = p45.Count; + int len = p43.Count; while (i < len) { - TaskPositionSDto item = p45[i]; + TaskPositionSDto item = p43[i]; result.Add(item == null ? null : new TaskPosition() { PositionId = item.PositionId, @@ -769,76 +748,53 @@ namespace Brizco.Domain.Mappers } - private static List funcMain25(List p48) + private static List funcMain26(List p46, List p47) + { + if (p46 == null) + { + return null; + } + List result = new List(p46.Count); + + int i = 0; + int len = p46.Count; + + while (i < len) + { + TaskShiftSDto item = p46[i]; + result.Add(item == null ? null : new TaskShift() + { + TaskId = item.TaskId, + Task = new Task() + { + Title = item.TaskTitle, + Id = item.TaskId + }, + ShiftId = item.ShiftId, + Shift = new Shift() {Id = item.ShiftId}, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain27(List p48, List p49) { if (p48 == null) { return null; } - List result = new List(p48.Count); + List result = new List(p48.Count); int i = 0; int len = p48.Count; while (i < len) { - TaskShift item = p48[i]; - result.Add(item == null ? null : new TaskShiftSDto() - { - ShiftId = item.ShiftId, - ShiftName = item.Shift != null ? item.Shift.Title : string.Empty, - TaskId = item.TaskId, - TaskTitle = item.Task != null ? item.Task.Title : string.Empty, - Id = item.Id - }); - i++; - } - return result; - - } - - private static List funcMain26(List p49) - { - if (p49 == null) - { - return null; - } - List result = new List(p49.Count); - - int i = 0; - int len = p49.Count; - - while (i < len) - { - TaskPosition item = p49[i]; - result.Add(item == null ? null : new TaskPositionSDto() - { - PositionId = item.PositionId, - PositionName = item.Position != null ? item.Position.Name : string.Empty, - TaskId = item.TaskId, - Id = item.Id - }); - i++; - } - return result; - - } - - private static List funcMain27(List p50) - { - if (p50 == null) - { - return null; - } - List result = new List(p50.Count); - - int i = 0; - int len = p50.Count; - - while (i < len) - { - TaskDay item = p50[i]; - result.Add(item == null ? null : new TaskDaySDto() + TaskDaySDto item = p48[i]; + result.Add(item == null ? null : new TaskDay() { DayOfWeek = item.DayOfWeek, TaskId = item.TaskId, @@ -850,21 +806,21 @@ namespace Brizco.Domain.Mappers } - private static List funcMain28(List p51) + private static List funcMain28(List p50, List p51) { - if (p51 == null) + if (p50 == null) { return null; } - List result = new List(p51.Count); + List result = new List(p50.Count); int i = 0; - int len = p51.Count; + int len = p50.Count; while (i < len) { - TaskRoutine item = p51[i]; - result.Add(item == null ? null : new TaskRoutineSDto() + TaskRoutineSDto item = p50[i]; + result.Add(item == null ? null : new TaskRoutine() { TaskId = item.TaskId, RoutineId = item.RoutineId, @@ -876,20 +832,52 @@ namespace Brizco.Domain.Mappers } - private static List funcMain29(List p54, List p55) + private static List funcMain29(List p52, List p53) { - if (p54 == null) + if (p52 == null) { return null; } - List result = new List(p54.Count); + List result = new List(p52.Count); int i = 0; - int len = p54.Count; + int len = p52.Count; while (i < len) { - TaskShift item = p54[i]; + TaskPositionSDto item = p52[i]; + result.Add(item == null ? null : new TaskPosition() + { + PositionId = item.PositionId, + Position = new Position() + { + Name = item.PositionName, + Id = item.PositionId + }, + TaskId = item.TaskId, + Task = new Task() {Id = item.TaskId}, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain30(List p55) + { + if (p55 == null) + { + return null; + } + List result = new List(p55.Count); + + int i = 0; + int len = p55.Count; + + while (i < len) + { + TaskShift item = p55[i]; result.Add(item == null ? null : new TaskShiftSDto() { ShiftId = item.ShiftId, @@ -904,7 +892,7 @@ namespace Brizco.Domain.Mappers } - private static List funcMain30(List p56, List p57) + private static List funcMain31(List p56) { if (p56 == null) { @@ -931,20 +919,20 @@ namespace Brizco.Domain.Mappers } - private static List funcMain31(List p58, List p59) + private static List funcMain32(List p57) { - if (p58 == null) + if (p57 == null) { return null; } - List result = new List(p58.Count); + List result = new List(p57.Count); int i = 0; - int len = p58.Count; + int len = p57.Count; while (i < len) { - TaskDay item = p58[i]; + TaskDay item = p57[i]; result.Add(item == null ? null : new TaskDaySDto() { DayOfWeek = item.DayOfWeek, @@ -957,20 +945,127 @@ namespace Brizco.Domain.Mappers } - private static List funcMain32(List p60, List p61) + private static List funcMain33(List p58) { - if (p60 == null) + if (p58 == null) { return null; } - List result = new List(p60.Count); + List result = new List(p58.Count); int i = 0; - int len = p60.Count; + int len = p58.Count; while (i < len) { - TaskRoutine item = p60[i]; + TaskRoutine item = p58[i]; + result.Add(item == null ? null : new TaskRoutineSDto() + { + TaskId = item.TaskId, + RoutineId = item.RoutineId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain34(List p61, List p62) + { + if (p61 == null) + { + return null; + } + List result = new List(p61.Count); + + int i = 0; + int len = p61.Count; + + while (i < len) + { + TaskShift item = p61[i]; + result.Add(item == null ? null : new TaskShiftSDto() + { + ShiftId = item.ShiftId, + ShiftName = item.Shift != null ? item.Shift.Title : string.Empty, + TaskId = item.TaskId, + TaskTitle = item.Task != null ? item.Task.Title : string.Empty, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain35(List p63, List p64) + { + if (p63 == null) + { + return null; + } + List result = new List(p63.Count); + + int i = 0; + int len = p63.Count; + + while (i < len) + { + TaskPosition item = p63[i]; + result.Add(item == null ? null : new TaskPositionSDto() + { + PositionId = item.PositionId, + PositionName = item.Position != null ? item.Position.Name : string.Empty, + TaskId = item.TaskId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain36(List p65, List p66) + { + if (p65 == null) + { + return null; + } + List result = new List(p65.Count); + + int i = 0; + int len = p65.Count; + + while (i < len) + { + TaskDay item = p65[i]; + result.Add(item == null ? null : new TaskDaySDto() + { + DayOfWeek = item.DayOfWeek, + TaskId = item.TaskId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain37(List p67, List p68) + { + if (p67 == null) + { + return null; + } + List result = new List(p67.Count); + + int i = 0; + int len = p67.Count; + + while (i < len) + { + TaskRoutine item = p67[i]; result.Add(item == null ? null : new TaskRoutineSDto() { TaskId = item.TaskId, diff --git a/Brizco.Domain/MapsterRegister.cs b/Brizco.Domain/MapsterRegister.cs index 5a64664..44bea03 100644 --- a/Brizco.Domain/MapsterRegister.cs +++ b/Brizco.Domain/MapsterRegister.cs @@ -1,4 +1,5 @@ -using Task = Brizco.Domain.Entities.Task.Task; +using MD.PersianDateTime.Standard; +using Task = Brizco.Domain.Entities.Task.Task; namespace Brizco.Domain; @@ -11,6 +12,7 @@ public class MapsterRegister : IRegister .Map("Shifts", o => o.Shifts.Select(d => d.Shift != null ? d.Shift.Title : string.Empty)) .Map("Routines", o => o.Routines.Select(d => d.Routine != null ? d.Routine.Name : string.Empty)) .Map("Positions", o => o.Positions.Select(d => d.Position != null ? d.Position.Name : string.Empty)) + .Map(s=>s.Days,o=>o.Days.Select(d=> d.DayOfWeek.GetPersianDayOfWeek()).ToList()) .TwoWays(); config.NewConfig() @@ -46,6 +48,8 @@ public class MapsterRegister : IRegister config.NewConfig() .Map("SupervisorFullName", o => o.Supervisor != null ? o.Supervisor.FirstName + " " + o.Supervisor.LastName : string.Empty) + .Map(s=>s.StartAt , o=>o.Shift != null ? o.Shift.StartAt : TimeSpan.MinValue) + .Map(s=>s.EndAt , o=>o.Shift != null ? o.Shift.EndAt : TimeSpan.MinValue) .TwoWays(); config.NewConfig() diff --git a/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs b/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs index d1a6d43..973bc33 100644 --- a/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs +++ b/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs @@ -24,7 +24,7 @@ public class GetActivitiesQueryHandler : IRequestHandler activities = _repositoryWrapper.SetRepository().TableNoTracking - .Where(a=>a.IsActivity); + .Where(a=>a.IsActivity && a.ComplexId == complexId); if (_currentUserService is { Permissions: not null, RoleName: not null }) { if (_currentUserService.Permissions.Contains(ApplicationPermission.ViewMineActivities) && _currentUserService.RoleName == ApplicationRoles.Staff) @@ -52,12 +52,11 @@ public class GetActivitiesQueryHandler : IRequestHandler 0) { var selectedDate = DateTimeExtensions.UnixTimeStampToDateTime(request.SelectedDate); - activities = activities.Where(a => a.ComplexId == complexId && a.SetFor.Date == selectedDate.Date); + activities = activities.Where(a => a.SetFor.Date == selectedDate.Date); } if (request.SelectedShift != default) - activities = activities.Where(a => a.ComplexId == complexId && a.ShiftId == request.SelectedShift); - + activities = activities.Where(a => a.ShiftId == request.SelectedShift); var response= await activities.OrderByDescending(s => s.UserId) diff --git a/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlansQueryHandler.cs b/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlansQueryHandler.cs index b3e29e2..a9f3536 100644 --- a/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlansQueryHandler.cs +++ b/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlansQueryHandler.cs @@ -1,4 +1,5 @@ using Brizco.Domain.Entities.Shift; +using MD.PersianDateTime.Standard; namespace Brizco.Repository.Handlers.ShiftPlan; @@ -25,10 +26,11 @@ public class GetShiftPlansQueryHandler : IRequestHandler s.ComplexId == complexId); List shiftPlans = new List(); + bool setActiviesCount = false; if (request.SelectedDate == 0) { - return await baseQuery + shiftPlans = await baseQuery .Skip(request.Page * 15).Take(15) .Select(ShiftPlanMapper.ProjectToSDto) .ToListAsync(cancellationToken); @@ -36,64 +38,104 @@ public class GetShiftPlansQueryHandler : IRequestHandler 0) { - if (request.SelectedDate > 0) + var selectedDate = DateTimeExtensions.UnixTimeStampToDateTime(request.SelectedDate); + shiftPlans = await baseQuery.Where(s => s.PlanFor.Date == selectedDate.Date) + .Skip(request.Page * 15).Take(15) + .Select(ShiftPlanMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + setActiviesCount = true; + } + + if (request.DateTimeQueryFilter != null) + { + + setActiviesCount = true; + switch (request.DateTimeQueryFilter) { - var selectedDate = DateTimeExtensions.UnixTimeStampToDateTime(request.SelectedDate); - shiftPlans = await baseQuery.Where(s => s.PlanFor.Date == selectedDate.Date) - .Skip(request.Page * 15).Take(15) - .Select(ShiftPlanMapper.ProjectToSDto) - .ToListAsync(cancellationToken); - } - else - { - switch (request.DateTimeQueryFilter) - { - case DateTimeQueryFilter.Today: - shiftPlans = await baseQuery.Where(s => s.PlanFor.Date == DateTime.Now.Date) - .Skip(request.Page * 15).Take(15) - .Select(ShiftPlanMapper.ProjectToSDto) - .ToListAsync(cancellationToken); - break; - case DateTimeQueryFilter.Yesterday: - shiftPlans = await baseQuery.Where(s => s.PlanFor.Date == DateTime.Now.AddDays(-1).Date) - .Skip(request.Page * 15).Take(15) - .Select(ShiftPlanMapper.ProjectToSDto) - .ToListAsync(cancellationToken); - break; - case DateTimeQueryFilter.PastWeek: - shiftPlans = await baseQuery.Where(s => s.PlanFor.Date >= DateTime.Now.AddDays(-7).Date) - .OrderByDescending(s => s.CreatedAt) - .Skip(request.Page * 15).Take(15) - .Select(ShiftPlanMapper.ProjectToSDto) - .ToListAsync(cancellationToken); - break; - case DateTimeQueryFilter.NextWeek: - shiftPlans = await baseQuery.Where(s => s.PlanFor.Date >= DateTime.Now.Date && s.PlanFor.Date <= DateTime.Today.AddDays(+7)) - .OrderByDescending(s => s.CreatedAt) - .Skip(request.Page * 15).Take(15) - .Select(ShiftPlanMapper.ProjectToSDto) - .ToListAsync(cancellationToken); - break; - case DateTimeQueryFilter.PastMonth: - shiftPlans = await baseQuery.Where(s => s.PlanFor.Date >= DateTime.Now.AddDays(-31).Date) - .OrderByDescending(s => s.CreatedAt) - .Skip(request.Page * 15).Take(15) - .Select(ShiftPlanMapper.ProjectToSDto) - .ToListAsync(cancellationToken); - break; - case DateTimeQueryFilter.NextMonth: - shiftPlans = await baseQuery.Where(s => s.PlanFor.Date >= DateTime.Now.Date && s.PlanFor.Date <= DateTime.Today.AddDays(+31)) - .OrderByDescending(s => s.CreatedAt) - .Skip(request.Page * 15).Take(15) - .Select(ShiftPlanMapper.ProjectToSDto) - .ToListAsync(cancellationToken); - break; - case null: - break; - default: - throw new ArgumentOutOfRangeException(); - } + case DateTimeQueryFilter.Today: + shiftPlans = await baseQuery.Where(s => s.PlanFor.Date == DateTime.Now.Date) + .Skip(request.Page * 15).Take(15) + .Select(ShiftPlanMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + break; + case DateTimeQueryFilter.Yesterday: + shiftPlans = await baseQuery.Where(s => s.PlanFor.Date == DateTime.Now.AddDays(-1).Date) + .Skip(request.Page * 15).Take(15) + .Select(ShiftPlanMapper.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); + shiftPlans = await baseQuery.Where(s => s.PlanFor.Date >= startOfPastWeek.Date && s.PlanFor.Date <= endOfPastWeek.Date) + .OrderByDescending(s => s.CreatedAt) + .Skip(request.Page * 15).Take(15) + .Select(ShiftPlanMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + break; + case DateTimeQueryFilter.NextWeek: + DateTime startOfNextWeek = DateTime.Today.AddDays(7 - (int)DateTime.Today.DayOfWeek + 1); + DateTime endOfNextWeek = startOfNextWeek.AddDays(5); + shiftPlans = await baseQuery.Where(s => s.PlanFor.Date >= startOfNextWeek.Date && s.PlanFor.Date <= endOfNextWeek.Date) + .OrderByDescending(s => s.CreatedAt) + .Skip(request.Page * 15).Take(15) + .Select(ShiftPlanMapper.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); + shiftPlans = await baseQuery.Where(s => s.PlanFor.Date >= startOfWeek.Date && s.PlanFor.Date <= endOfWeek.Date) + .OrderByDescending(s => s.CreatedAt) + .Skip(request.Page * 15).Take(15) + .Select(ShiftPlanMapper.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); + shiftPlans = await baseQuery.Where(s => s.PlanFor.Date >= startOfPastMonth.Date && s.PlanFor.Date < endOfPastMonth.Date) + .OrderByDescending(s => s.CreatedAt) + .Skip(request.Page * 15).Take(15) + .Select(ShiftPlanMapper.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); + shiftPlans = await baseQuery.Where(s => s.PlanFor.Date >= startOfNextMonth.Date && s.PlanFor.Date < endOfNextMonth.Date) + .OrderByDescending(s => s.CreatedAt) + .Skip(request.Page * 15).Take(15) + .Select(ShiftPlanMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + break; + + case DateTimeQueryFilter.ThisMonth: + DateTime startOfThisMonth = new PersianDateTime(PersianDateTime.Today.Year, PersianDateTime.Today.Month, 1).ToDateTime(); + DateTime endOfThisMonth = startOfThisMonth.AddMonths(1); + shiftPlans = await baseQuery.Where(s => s.PlanFor.Date >= startOfThisMonth.Date && s.PlanFor.Date < endOfThisMonth.Date) + .OrderByDescending(s => s.CreatedAt) + .Skip(request.Page * 15).Take(15) + .Select(ShiftPlanMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + break; + case null: + break; + default: + throw new ArgumentOutOfRangeException(); + } + } + + if (setActiviesCount) + { foreach (var shiftPlan in shiftPlans) {