diff --git a/.version b/.version index 75a498f..f484852 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -0.4.6.6 \ No newline at end of file +0.4.7.7 \ No newline at end of file diff --git a/Brizco.Api/AppSettings/appsettings.Development.json b/Brizco.Api/AppSettings/appsettings.Development.json index 01d19fb..bf839cb 100644 --- a/Brizco.Api/AppSettings/appsettings.Development.json +++ b/Brizco.Api/AppSettings/appsettings.Development.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "PostgresServer": "User ID=postgres;Password=root;Host=localhost;Port=5432;Database=iGarsonDB;", + "PostgresServer": "Host=185.220.227.160;port=5432;Username=postgres;Password=ub0J7sFFThkSBmkc0TzSKsCfheRnQpyu;Database=BrizcoDB", "Postgres": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=BrizcoDB;Load Balance Hosts=true;Target Session Attributes=primary;Application Name=iGLS" }, "Logging": { diff --git a/Brizco.Api/Brizco.Api.csproj b/Brizco.Api/Brizco.Api.csproj index cd844fb..714a3d8 100644 --- a/Brizco.Api/Brizco.Api.csproj +++ b/Brizco.Api/Brizco.Api.csproj @@ -6,8 +6,8 @@ enable Linux ..\docker-compose.dcproj - 0.4.6.6 - 0.4.6.6 + 0.4.7.7 + 0.4.7.7 diff --git a/Brizco.Api/Controllers/ActivityController.cs b/Brizco.Api/Controllers/ActivityController.cs index e95b18f..5b340cb 100644 --- a/Brizco.Api/Controllers/ActivityController.cs +++ b/Brizco.Api/Controllers/ActivityController.cs @@ -1,4 +1,5 @@ using Brizco.Common.Models.Claims; +using Brizco.Domain.Enums; namespace Brizco.Api.Controllers; @@ -50,7 +51,7 @@ public class ActivityController : ICarterModule // GET:Get All Entity - public async Task GetAllAsync([FromQuery] int page, [FromQuery] long? selectedDate, [FromQuery] Guid? selectedShift, ISender sender, CancellationToken cancellationToken) + public async Task GetAllAsync([FromQuery] int page, [FromQuery] DateQueryFilter? dateQueryFilter, [FromQuery] long? selectedDate, [FromQuery] Guid? selectedShift, ISender sender, CancellationToken cancellationToken) => TypedResults.Ok(await sender.Send(new GetActivitiesQuery(Page: page, SelectedDate: selectedDate ?? 0 , SelectedShift: selectedShift ?? default), cancellationToken)); // GET:Get An Entity By Id diff --git a/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs b/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs index 1533582..324a5fb 100644 --- a/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs +++ b/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs @@ -1,6 +1,6 @@ namespace Brizco.Domain.CommandQueries.Queries; -public sealed record GetActivitiesQuery(int Page = 0 , long SelectedDate = 0 , Guid SelectedShift = default) : +public sealed record GetActivitiesQuery(int Page = 0 , long SelectedDate = 0 , Guid SelectedShift = default , DateQueryFilter? DateQueryFilter = null) : IRequest>; public sealed record GetActivityQuery(Guid Id) : diff --git a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs index 336d597..b6cadf7 100644 --- a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs +++ b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs @@ -14,4 +14,6 @@ public class ShiftPlanSDto : BaseDto public string CompleteDescription { get; internal set; } = string.Empty; public Guid ShiftId { get; set; } public string ShiftTitle { get; internal set; } = string.Empty; + + 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 7f5fd1f..98a8f7b 100644 --- a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanUserSDto.cs +++ b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanUserSDto.cs @@ -6,5 +6,7 @@ public class ShiftPlanUserSDto : BaseDto { public Guid ShiftPlanId { get; set; } public Guid UserId { get; set; } + public string UserFullName { get; set; } = string.Empty; public Guid PositionId { get; set; } + public string PositionName { get; set; } = string.Empty; } \ No newline at end of file diff --git a/Brizco.Domain/Enums/DateQueryFilter.cs b/Brizco.Domain/Enums/DateQueryFilter.cs new file mode 100644 index 0000000..b5753c6 --- /dev/null +++ b/Brizco.Domain/Enums/DateQueryFilter.cs @@ -0,0 +1,8 @@ +namespace Brizco.Domain.Enums; + +public enum DateQueryFilter +{ + Today = 0, + Tomorrow = 1, + ThisWeek = 2, +} \ No newline at end of file diff --git a/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs b/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs index d60323d..1eb7ad3 100644 --- a/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs +++ b/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Linq.Expressions; using Brizco.Domain.Dtos.LargDtos; using Brizco.Domain.Dtos.SmallDtos; +using Brizco.Domain.Entities.Complex; using Brizco.Domain.Entities.Routine; using Brizco.Domain.Entities.Shift; using Brizco.Domain.Entities.User; @@ -22,274 +23,292 @@ namespace Brizco.Domain.Mappers CompletePercent = p1.CompletePercent, CompleteDescription = p1.CompleteDescription, ShiftId = p1.ShiftId, + Users = funcMain1(p1.Users), Id = p1.Id }; } - public static ShiftPlan AdaptTo(this ShiftPlanSDto p2, ShiftPlan p3) + public static ShiftPlan AdaptTo(this ShiftPlanSDto p3, ShiftPlan p4) { - if (p2 == null) + if (p3 == null) { return null; } - ShiftPlan result = p3 ?? new ShiftPlan(); + ShiftPlan result = p4 ?? new ShiftPlan(); - result.PlanFor = p2.PlanFor; - result.IsCompleted = p2.IsCompleted; - result.CompletePercent = p2.CompletePercent; - result.CompleteDescription = p2.CompleteDescription; - result.ShiftId = p2.ShiftId; - result.Id = p2.Id; + result.PlanFor = p3.PlanFor; + result.IsCompleted = p3.IsCompleted; + result.CompletePercent = p3.CompletePercent; + result.CompleteDescription = p3.CompleteDescription; + result.ShiftId = p3.ShiftId; + result.Users = funcMain2(p3.Users, result.Users); + result.Id = p3.Id; return result; } - public static Expression> ProjectToShiftPlan => p4 => new ShiftPlan() + public static Expression> ProjectToShiftPlan => p7 => new ShiftPlan() { - PlanFor = p4.PlanFor, - IsCompleted = p4.IsCompleted, - CompletePercent = p4.CompletePercent, - CompleteDescription = p4.CompleteDescription, - ShiftId = p4.ShiftId, - Id = p4.Id - }; - public static ShiftPlanSDto AdaptToSDto(this ShiftPlan p5) - { - return p5 == null ? null : new ShiftPlanSDto() + PlanFor = p7.PlanFor, + IsCompleted = p7.IsCompleted, + CompletePercent = p7.CompletePercent, + CompleteDescription = p7.CompleteDescription, + ShiftId = p7.ShiftId, + Users = p7.Users.Select(p8 => new ShiftPlanUser() { - PlanFor = p5.PlanFor, - IsCompleted = p5.IsCompleted, - CompletePercent = p5.CompletePercent, - CompleteDescription = p5.CompleteDescription, - ShiftId = p5.ShiftId, - ShiftTitle = p5.Shift == null ? null : p5.Shift.Title, - Id = p5.Id - }; - } - public static ShiftPlanSDto AdaptTo(this ShiftPlan p6, ShiftPlanSDto p7) - { - if (p6 == null) - { - return null; - } - ShiftPlanSDto result = p7 ?? new ShiftPlanSDto(); - - result.PlanFor = p6.PlanFor; - result.IsCompleted = p6.IsCompleted; - result.CompletePercent = p6.CompletePercent; - result.CompleteDescription = p6.CompleteDescription; - result.ShiftId = p6.ShiftId; - result.ShiftTitle = p6.Shift == null ? null : p6.Shift.Title; - result.Id = p6.Id; - return result; - - } - public static Expression> ProjectToSDto => p8 => new ShiftPlanSDto() - { - PlanFor = p8.PlanFor, - IsCompleted = p8.IsCompleted, - CompletePercent = p8.CompletePercent, - CompleteDescription = p8.CompleteDescription, - ShiftId = p8.ShiftId, - ShiftTitle = p8.Shift.Title, - Id = p8.Id + ShiftPlanId = p8.ShiftPlanId, + ShiftPlan = new ShiftPlan() {Id = p8.ShiftPlanId}, + PositionId = p8.PositionId, + Position = new Position() + { + Name = p8.PositionName, + Id = p8.PositionId + }, + UserId = p8.UserId, + User = new ApplicationUser() {Id = p8.UserId}, + Id = p8.Id + }).ToList(), + Id = p7.Id }; - public static ShiftPlan AdaptToShiftPlan(this ShiftPlanLDto p9) + public static ShiftPlanSDto AdaptToSDto(this ShiftPlan p9) { - return p9 == null ? null : new ShiftPlan() + return p9 == null ? null : new ShiftPlanSDto() { PlanFor = p9.PlanFor, IsCompleted = p9.IsCompleted, CompletePercent = p9.CompletePercent, CompleteDescription = p9.CompleteDescription, ShiftId = p9.ShiftId, - Shift = new Shift() {Id = p9.ShiftId}, - RoutineId = p9.RoutineId, - Routine = new Routine() {Id = p9.RoutineId}, - SupervisorId = p9.SupervisorId, - Supervisor = new ApplicationUser() {Id = p9.SupervisorId}, - Users = funcMain1(p9.Users), + ShiftTitle = p9.Shift == null ? null : p9.Shift.Title, + Users = funcMain3(p9.Users), Id = p9.Id }; } - public static ShiftPlan AdaptTo(this ShiftPlanLDto p11, ShiftPlan p12) + public static ShiftPlanSDto AdaptTo(this ShiftPlan p11, ShiftPlanSDto p12) { if (p11 == null) { return null; } - ShiftPlan result = p12 ?? new ShiftPlan(); + ShiftPlanSDto result = p12 ?? new ShiftPlanSDto(); result.PlanFor = p11.PlanFor; result.IsCompleted = p11.IsCompleted; result.CompletePercent = p11.CompletePercent; result.CompleteDescription = p11.CompleteDescription; result.ShiftId = p11.ShiftId; - result.Shift = funcMain2(new Never(), result.Shift, p11); - result.RoutineId = p11.RoutineId; - result.Routine = funcMain3(new Never(), result.Routine, p11); - result.SupervisorId = p11.SupervisorId; - result.Supervisor = funcMain4(new Never(), result.Supervisor, p11); - result.Users = funcMain5(p11.Users, result.Users); + result.ShiftTitle = p11.Shift == null ? null : p11.Shift.Title; + result.Users = funcMain4(p11.Users, result.Users); result.Id = p11.Id; return result; } - public static ShiftPlanLDto AdaptToLDto(this ShiftPlan p21) + public static Expression> ProjectToSDto => p15 => new ShiftPlanSDto() { - return p21 == null ? null : new ShiftPlanLDto() + PlanFor = p15.PlanFor, + IsCompleted = p15.IsCompleted, + CompletePercent = p15.CompletePercent, + CompleteDescription = p15.CompleteDescription, + ShiftId = p15.ShiftId, + ShiftTitle = p15.Shift.Title, + Users = p15.Users.Select(p16 => new ShiftPlanUserSDto() { - PlanFor = p21.PlanFor, - RoutineId = p21.RoutineId, - IsCompleted = p21.IsCompleted, - CompletePercent = p21.CompletePercent, - CompleteDescription = p21.CompleteDescription, - ShiftId = p21.ShiftId, - Users = funcMain6(p21.Users), - SupervisorId = p21.SupervisorId, - SupervisorFullName = p21.Supervisor != null ? p21.Supervisor.FirstName + " " + p21.Supervisor.LastName : string.Empty, - Id = p21.Id + ShiftPlanId = p16.ShiftPlanId, + UserId = p16.UserId, + UserFullName = p16.User != null ? p16.User.FirstName + " " + p16.User.LastName : string.Empty, + PositionId = p16.PositionId, + PositionName = p16.Position != null ? p16.Position.Name : string.Empty, + Id = p16.Id + }).ToList(), + Id = p15.Id + }; + public static ShiftPlan AdaptToShiftPlan(this ShiftPlanLDto p17) + { + return p17 == null ? null : new ShiftPlan() + { + PlanFor = p17.PlanFor, + IsCompleted = p17.IsCompleted, + CompletePercent = p17.CompletePercent, + CompleteDescription = p17.CompleteDescription, + ShiftId = p17.ShiftId, + Shift = new Shift() {Id = p17.ShiftId}, + RoutineId = p17.RoutineId, + Routine = new Routine() {Id = p17.RoutineId}, + SupervisorId = p17.SupervisorId, + Supervisor = new ApplicationUser() {Id = p17.SupervisorId}, + Users = funcMain5(p17.Users), + Id = p17.Id }; } - public static ShiftPlanLDto AdaptTo(this ShiftPlan p23, ShiftPlanLDto p24) + public static ShiftPlan AdaptTo(this ShiftPlanLDto p19, ShiftPlan p20) { - if (p23 == null) + if (p19 == null) { return null; } - ShiftPlanLDto result = p24 ?? new ShiftPlanLDto(); + ShiftPlan result = p20 ?? new ShiftPlan(); - result.PlanFor = p23.PlanFor; - result.RoutineId = p23.RoutineId; - result.IsCompleted = p23.IsCompleted; - result.CompletePercent = p23.CompletePercent; - result.CompleteDescription = p23.CompleteDescription; - result.ShiftId = p23.ShiftId; - result.Users = funcMain7(p23.Users, result.Users); - result.SupervisorId = p23.SupervisorId; - result.SupervisorFullName = p23.Supervisor != null ? p23.Supervisor.FirstName + " " + p23.Supervisor.LastName : string.Empty; - result.Id = p23.Id; + result.PlanFor = p19.PlanFor; + result.IsCompleted = p19.IsCompleted; + result.CompletePercent = p19.CompletePercent; + result.CompleteDescription = p19.CompleteDescription; + result.ShiftId = p19.ShiftId; + result.Shift = funcMain6(new Never(), result.Shift, p19); + result.RoutineId = p19.RoutineId; + result.Routine = funcMain7(new Never(), result.Routine, p19); + result.SupervisorId = p19.SupervisorId; + result.Supervisor = funcMain8(new Never(), result.Supervisor, p19); + result.Users = funcMain9(p19.Users, result.Users); + result.Id = p19.Id; return result; } - public static Expression> ProjectToLDto => p27 => new ShiftPlanLDto() + public static ShiftPlanLDto AdaptToLDto(this ShiftPlan p29) { - PlanFor = p27.PlanFor, - RoutineId = p27.RoutineId, - IsCompleted = p27.IsCompleted, - CompletePercent = p27.CompletePercent, - CompleteDescription = p27.CompleteDescription, - ShiftId = p27.ShiftId, - Users = p27.Users.Select(p28 => new ShiftPlanUserSDto() + return p29 == null ? null : new ShiftPlanLDto() { - ShiftPlanId = p28.ShiftPlanId, - UserId = p28.UserId, - PositionId = p28.PositionId, - Id = p28.Id + PlanFor = p29.PlanFor, + RoutineId = p29.RoutineId, + IsCompleted = p29.IsCompleted, + CompletePercent = p29.CompletePercent, + CompleteDescription = p29.CompleteDescription, + ShiftId = p29.ShiftId, + Users = funcMain10(p29.Users), + SupervisorId = p29.SupervisorId, + SupervisorFullName = p29.Supervisor != null ? p29.Supervisor.FirstName + " " + p29.Supervisor.LastName : string.Empty, + Id = p29.Id + }; + } + public static ShiftPlanLDto AdaptTo(this ShiftPlan p31, ShiftPlanLDto p32) + { + if (p31 == null) + { + return null; + } + ShiftPlanLDto result = p32 ?? new ShiftPlanLDto(); + + result.PlanFor = p31.PlanFor; + result.RoutineId = p31.RoutineId; + result.IsCompleted = p31.IsCompleted; + result.CompletePercent = p31.CompletePercent; + result.CompleteDescription = p31.CompleteDescription; + result.ShiftId = p31.ShiftId; + result.Users = funcMain11(p31.Users, result.Users); + result.SupervisorId = p31.SupervisorId; + result.SupervisorFullName = p31.Supervisor != null ? p31.Supervisor.FirstName + " " + p31.Supervisor.LastName : string.Empty; + result.Id = p31.Id; + return result; + + } + public static Expression> ProjectToLDto => p35 => new ShiftPlanLDto() + { + PlanFor = p35.PlanFor, + RoutineId = p35.RoutineId, + IsCompleted = p35.IsCompleted, + CompletePercent = p35.CompletePercent, + CompleteDescription = p35.CompleteDescription, + ShiftId = p35.ShiftId, + Users = p35.Users.Select(p36 => new ShiftPlanUserSDto() + { + ShiftPlanId = p36.ShiftPlanId, + UserId = p36.UserId, + UserFullName = p36.User != null ? p36.User.FirstName + " " + p36.User.LastName : string.Empty, + PositionId = p36.PositionId, + PositionName = p36.Position != null ? p36.Position.Name : string.Empty, + Id = p36.Id }).ToList(), - SupervisorId = p27.SupervisorId, - SupervisorFullName = p27.Supervisor != null ? p27.Supervisor.FirstName + " " + p27.Supervisor.LastName : string.Empty, - Id = p27.Id + SupervisorId = p35.SupervisorId, + SupervisorFullName = p35.Supervisor != null ? p35.Supervisor.FirstName + " " + p35.Supervisor.LastName : string.Empty, + Id = p35.Id }; - private static List funcMain1(List p10) + private static List funcMain1(List p2) + { + if (p2 == null) + { + return null; + } + List result = new List(p2.Count); + + int i = 0; + int len = p2.Count; + + while (i < len) + { + ShiftPlanUserSDto item = p2[i]; + result.Add(item == null ? null : new ShiftPlanUser() + { + ShiftPlanId = item.ShiftPlanId, + ShiftPlan = new ShiftPlan() {Id = item.ShiftPlanId}, + PositionId = item.PositionId, + Position = new Position() + { + Name = item.PositionName, + Id = item.PositionId + }, + UserId = item.UserId, + User = new ApplicationUser() {Id = item.UserId}, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain2(List p5, List p6) + { + if (p5 == null) + { + return null; + } + List result = new List(p5.Count); + + int i = 0; + int len = p5.Count; + + while (i < len) + { + ShiftPlanUserSDto item = p5[i]; + result.Add(item == null ? null : new ShiftPlanUser() + { + ShiftPlanId = item.ShiftPlanId, + ShiftPlan = new ShiftPlan() {Id = item.ShiftPlanId}, + PositionId = item.PositionId, + Position = new Position() + { + Name = item.PositionName, + Id = item.PositionId + }, + UserId = item.UserId, + User = new ApplicationUser() {Id = item.UserId}, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain3(List p10) { if (p10 == null) { return null; } - List result = new List(p10.Count); + List result = new List(p10.Count); int i = 0; int len = p10.Count; while (i < len) { - ShiftPlanUserSDto item = p10[i]; - result.Add(item == null ? null : new ShiftPlanUser() - { - ShiftPlanId = item.ShiftPlanId, - PositionId = item.PositionId, - UserId = item.UserId, - Id = item.Id - }); - i++; - } - return result; - - } - - private static Shift funcMain2(Never p13, Shift p14, ShiftPlanLDto p11) - { - Shift result = p14 ?? new Shift(); - - result.Id = p11.ShiftId; - return result; - - } - - private static Routine funcMain3(Never p15, Routine p16, ShiftPlanLDto p11) - { - Routine result = p16 ?? new Routine(); - - result.Id = p11.RoutineId; - return result; - - } - - private static ApplicationUser funcMain4(Never p17, ApplicationUser p18, ShiftPlanLDto p11) - { - ApplicationUser result = p18 ?? new ApplicationUser(); - - result.Id = p11.SupervisorId; - return result; - - } - - private static List funcMain5(List p19, List p20) - { - if (p19 == null) - { - return null; - } - List result = new List(p19.Count); - - int i = 0; - int len = p19.Count; - - while (i < len) - { - ShiftPlanUserSDto item = p19[i]; - result.Add(item == null ? null : new ShiftPlanUser() - { - ShiftPlanId = item.ShiftPlanId, - PositionId = item.PositionId, - UserId = item.UserId, - Id = item.Id - }); - i++; - } - return result; - - } - - private static List funcMain6(List p22) - { - if (p22 == null) - { - return null; - } - List result = new List(p22.Count); - - int i = 0; - int len = p22.Count; - - while (i < len) - { - ShiftPlanUser item = p22[i]; + ShiftPlanUser item = p10[i]; result.Add(item == null ? null : new ShiftPlanUserSDto() { ShiftPlanId = item.ShiftPlanId, UserId = item.UserId, + UserFullName = item.User != null ? item.User.FirstName + " " + item.User.LastName : string.Empty, PositionId = item.PositionId, + PositionName = item.Position != null ? item.Position.Name : string.Empty, Id = item.Id }); i++; @@ -298,25 +317,180 @@ namespace Brizco.Domain.Mappers } - private static List funcMain7(List p25, List p26) + private static List funcMain4(List p13, List p14) { - if (p25 == null) + if (p13 == null) { return null; } - List result = new List(p25.Count); + List result = new List(p13.Count); int i = 0; - int len = p25.Count; + int len = p13.Count; while (i < len) { - ShiftPlanUser item = p25[i]; + ShiftPlanUser item = p13[i]; result.Add(item == null ? null : new ShiftPlanUserSDto() { ShiftPlanId = item.ShiftPlanId, UserId = item.UserId, + UserFullName = item.User != null ? item.User.FirstName + " " + item.User.LastName : string.Empty, PositionId = item.PositionId, + PositionName = item.Position != null ? item.Position.Name : string.Empty, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain5(List p18) + { + if (p18 == null) + { + return null; + } + List result = new List(p18.Count); + + int i = 0; + int len = p18.Count; + + while (i < len) + { + ShiftPlanUserSDto item = p18[i]; + result.Add(item == null ? null : new ShiftPlanUser() + { + ShiftPlanId = item.ShiftPlanId, + ShiftPlan = new ShiftPlan() {Id = item.ShiftPlanId}, + PositionId = item.PositionId, + Position = new Position() + { + Name = item.PositionName, + Id = item.PositionId + }, + UserId = item.UserId, + User = new ApplicationUser() {Id = item.UserId}, + Id = item.Id + }); + i++; + } + return result; + + } + + private static Shift funcMain6(Never p21, Shift p22, ShiftPlanLDto p19) + { + Shift result = p22 ?? new Shift(); + + result.Id = p19.ShiftId; + return result; + + } + + private static Routine funcMain7(Never p23, Routine p24, ShiftPlanLDto p19) + { + Routine result = p24 ?? new Routine(); + + result.Id = p19.RoutineId; + return result; + + } + + private static ApplicationUser funcMain8(Never p25, ApplicationUser p26, ShiftPlanLDto p19) + { + ApplicationUser result = p26 ?? new ApplicationUser(); + + result.Id = p19.SupervisorId; + return result; + + } + + private static List funcMain9(List p27, List p28) + { + if (p27 == null) + { + return null; + } + List result = new List(p27.Count); + + int i = 0; + int len = p27.Count; + + while (i < len) + { + ShiftPlanUserSDto item = p27[i]; + result.Add(item == null ? null : new ShiftPlanUser() + { + ShiftPlanId = item.ShiftPlanId, + ShiftPlan = new ShiftPlan() {Id = item.ShiftPlanId}, + PositionId = item.PositionId, + Position = new Position() + { + Name = item.PositionName, + Id = item.PositionId + }, + UserId = item.UserId, + User = new ApplicationUser() {Id = item.UserId}, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain10(List p30) + { + if (p30 == null) + { + return null; + } + List result = new List(p30.Count); + + int i = 0; + int len = p30.Count; + + while (i < len) + { + ShiftPlanUser item = p30[i]; + result.Add(item == null ? null : new ShiftPlanUserSDto() + { + ShiftPlanId = item.ShiftPlanId, + UserId = item.UserId, + UserFullName = item.User != null ? item.User.FirstName + " " + item.User.LastName : string.Empty, + PositionId = item.PositionId, + PositionName = item.Position != null ? item.Position.Name : string.Empty, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain11(List p33, List p34) + { + if (p33 == null) + { + return null; + } + List result = new List(p33.Count); + + int i = 0; + int len = p33.Count; + + while (i < len) + { + ShiftPlanUser item = p33[i]; + result.Add(item == null ? null : new ShiftPlanUserSDto() + { + ShiftPlanId = item.ShiftPlanId, + UserId = item.UserId, + UserFullName = item.User != null ? item.User.FirstName + " " + item.User.LastName : string.Empty, + PositionId = item.PositionId, + PositionName = item.Position != null ? item.Position.Name : string.Empty, Id = item.Id }); i++; diff --git a/Brizco.Domain/Mappers/ShiftPlanUserMapper.g.cs b/Brizco.Domain/Mappers/ShiftPlanUserMapper.g.cs index b29219a..ad91c26 100644 --- a/Brizco.Domain/Mappers/ShiftPlanUserMapper.g.cs +++ b/Brizco.Domain/Mappers/ShiftPlanUserMapper.g.cs @@ -1,7 +1,10 @@ using System; using System.Linq.Expressions; using Brizco.Domain.Dtos.SmallDtos; +using Brizco.Domain.Entities.Complex; using Brizco.Domain.Entities.Shift; +using Brizco.Domain.Entities.User; +using Mapster.Models; namespace Brizco.Domain.Mappers { @@ -12,8 +15,15 @@ namespace Brizco.Domain.Mappers return p1 == null ? null : new ShiftPlanUser() { ShiftPlanId = p1.ShiftPlanId, + ShiftPlan = new ShiftPlan() {Id = p1.ShiftPlanId}, PositionId = p1.PositionId, + Position = new Position() + { + Name = p1.PositionName, + Id = p1.PositionId + }, UserId = p1.UserId, + User = new ApplicationUser() {Id = p1.UserId}, Id = p1.Id }; } @@ -26,50 +36,94 @@ namespace Brizco.Domain.Mappers ShiftPlanUser result = p3 ?? new ShiftPlanUser(); result.ShiftPlanId = p2.ShiftPlanId; + result.ShiftPlan = funcMain1(new Never(), result.ShiftPlan, p2); result.PositionId = p2.PositionId; + result.Position = funcMain2(new Never(), result.Position, p2); result.UserId = p2.UserId; + result.User = funcMain3(new Never(), result.User, p2); result.Id = p2.Id; return result; } - public static Expression> ProjectToShiftPlanUser => p4 => new ShiftPlanUser() + public static Expression> ProjectToShiftPlanUser => p10 => new ShiftPlanUser() { - ShiftPlanId = p4.ShiftPlanId, - PositionId = p4.PositionId, - UserId = p4.UserId, - Id = p4.Id - }; - public static ShiftPlanUserSDto AdaptToSDto(this ShiftPlanUser p5) - { - return p5 == null ? null : new ShiftPlanUserSDto() + ShiftPlanId = p10.ShiftPlanId, + ShiftPlan = new ShiftPlan() {Id = p10.ShiftPlanId}, + PositionId = p10.PositionId, + Position = new Position() { - ShiftPlanId = p5.ShiftPlanId, - UserId = p5.UserId, - PositionId = p5.PositionId, - Id = p5.Id + Name = p10.PositionName, + Id = p10.PositionId + }, + UserId = p10.UserId, + User = new ApplicationUser() {Id = p10.UserId}, + Id = p10.Id + }; + public static ShiftPlanUserSDto AdaptToSDto(this ShiftPlanUser p11) + { + return p11 == null ? null : new ShiftPlanUserSDto() + { + ShiftPlanId = p11.ShiftPlanId, + UserId = p11.UserId, + UserFullName = p11.User != null ? p11.User.FirstName + " " + p11.User.LastName : string.Empty, + PositionId = p11.PositionId, + PositionName = p11.Position != null ? p11.Position.Name : string.Empty, + Id = p11.Id }; } - public static ShiftPlanUserSDto AdaptTo(this ShiftPlanUser p6, ShiftPlanUserSDto p7) + public static ShiftPlanUserSDto AdaptTo(this ShiftPlanUser p12, ShiftPlanUserSDto p13) { - if (p6 == null) + if (p12 == null) { return null; } - ShiftPlanUserSDto result = p7 ?? new ShiftPlanUserSDto(); + ShiftPlanUserSDto result = p13 ?? new ShiftPlanUserSDto(); - result.ShiftPlanId = p6.ShiftPlanId; - result.UserId = p6.UserId; - result.PositionId = p6.PositionId; - result.Id = p6.Id; + result.ShiftPlanId = p12.ShiftPlanId; + result.UserId = p12.UserId; + result.UserFullName = p12.User != null ? p12.User.FirstName + " " + p12.User.LastName : string.Empty; + result.PositionId = p12.PositionId; + result.PositionName = p12.Position != null ? p12.Position.Name : string.Empty; + result.Id = p12.Id; return result; } - public static Expression> ProjectToSDto => p8 => new ShiftPlanUserSDto() + public static Expression> ProjectToSDto => p14 => new ShiftPlanUserSDto() { - ShiftPlanId = p8.ShiftPlanId, - UserId = p8.UserId, - PositionId = p8.PositionId, - Id = p8.Id + ShiftPlanId = p14.ShiftPlanId, + UserId = p14.UserId, + UserFullName = p14.User != null ? p14.User.FirstName + " " + p14.User.LastName : string.Empty, + PositionId = p14.PositionId, + PositionName = p14.Position != null ? p14.Position.Name : string.Empty, + Id = p14.Id }; + + private static ShiftPlan funcMain1(Never p4, ShiftPlan p5, ShiftPlanUserSDto p2) + { + ShiftPlan result = p5 ?? new ShiftPlan(); + + result.Id = p2.ShiftPlanId; + return result; + + } + + private static Position funcMain2(Never p6, Position p7, ShiftPlanUserSDto p2) + { + Position result = p7 ?? new Position(); + + result.Name = p2.PositionName; + result.Id = p2.PositionId; + return result; + + } + + private static ApplicationUser funcMain3(Never p8, ApplicationUser p9, ShiftPlanUserSDto p2) + { + ApplicationUser result = p9 ?? new ApplicationUser(); + + result.Id = p2.UserId; + return result; + + } } } \ No newline at end of file diff --git a/Brizco.Domain/MapsterRegister.cs b/Brizco.Domain/MapsterRegister.cs index aa16e34..4f5951c 100644 --- a/Brizco.Domain/MapsterRegister.cs +++ b/Brizco.Domain/MapsterRegister.cs @@ -44,6 +44,11 @@ public class MapsterRegister : IRegister .Map("SupervisorFullName", o => o.Supervisor != null ? o.Supervisor.FirstName + " " + o.Supervisor.LastName : string.Empty) .TwoWays(); + config.NewConfig() + .Map("UserFullName", o => o.User != null ? o.User.FirstName + " " + o.User.LastName : string.Empty) + .Map("PositionName", o => o.Position != null ? o.Position.Name : string.Empty) + .TwoWays(); + config.NewConfig() .Map("RoleName", org => org.Role!.PersianName) .TwoWays(); diff --git a/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs b/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs index 0207d9a..3975b17 100644 --- a/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs +++ b/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs @@ -26,6 +26,23 @@ public class GetActivitiesQueryHandler : IRequestHandler activities = _repositoryWrapper.SetRepository().TableNoTracking .Where(a=>a.IsActivity); + if (request.DateQueryFilter != null) + { + switch (request.DateQueryFilter) + { + case DateQueryFilter.Today: + activities = activities.Where(a => a.SetFor.Date == DateTime.Today.Date); + break; + case DateQueryFilter.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); + break; + default: + throw new ArgumentOutOfRangeException(); + } + } if (request.SelectedDate > 0) { diff --git a/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlansQueryHandler.cs b/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlansQueryHandler.cs index e19c0e8..b3e29e2 100644 --- a/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlansQueryHandler.cs +++ b/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlansQueryHandler.cs @@ -117,6 +117,7 @@ public class GetShiftPlansQueryHandler : IRequestHandler() .TableNoTracking .CountAsync(spu => spu.ShiftPlanId == shiftPlan.Id, cancellationToken); + } return shiftPlans; diff --git a/Brizco.Repository/Services/DbInitializerService.cs b/Brizco.Repository/Services/DbInitializerService.cs index 5573c1b..bd0e11c 100644 --- a/Brizco.Repository/Services/DbInitializerService.cs +++ b/Brizco.Repository/Services/DbInitializerService.cs @@ -89,5 +89,55 @@ public class DbInitializerService : IDbInitializerService foreach (var claim in ApplicationClaims.AllClaims) await _roleManager.AddClaimAsync(managerRole, claim); } + + //var roles = await _roleManager.Roles.ToListAsync(); + //foreach (var role in roles) + //{ + // if (role.EnglishName == "Manager") + // { + // var claims = await _roleManager.GetClaimsAsync(role); + + // foreach (var claim in ApplicationClaims.ManagerClaims) + // { + // if(!claims.Contains(claim)) + // await _roleManager.AddClaimAsync(role, claim); + // } + // } + // else if (role.EnglishName == "ViewerOwner") + // { + + // var claims = await _roleManager.GetClaimsAsync(role); + + // foreach (var claim in ApplicationClaims.ViewerOwnerClaims) + // { + // if (!claims.Contains(claim)) + // await _roleManager.AddClaimAsync(role, claim); + // } + // } + // else if (role.EnglishName == "SuperVisor") + // { + + + // var claims = await _roleManager.GetClaimsAsync(role); + + // foreach (var claim in ApplicationClaims.SuperVisorClaims) + // { + // if (!claims.Contains(claim)) + // await _roleManager.AddClaimAsync(role, claim); + // } + // } + // else if (role.EnglishName == "Staff") + // { + + + // var claims = await _roleManager.GetClaimsAsync(role); + + // foreach (var claim in ApplicationClaims.StaffClaims) + // { + // if (!claims.Contains(claim)) + // await _roleManager.AddClaimAsync(role, claim); + // } + // } + //} } } \ No newline at end of file