add vesrion 0.7.12.12 , feat add shiftplanid to activites , fix issues
parent
1cac63112e
commit
ab343077bd
|
@ -51,8 +51,8 @@ public class ActivityController : ICarterModule
|
|||
|
||||
|
||||
// GET:Get All Entity
|
||||
public async Task<IResult> 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 , DateQueryFilter: dateQueryFilter ?? null), cancellationToken));
|
||||
public async Task<IResult> 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));
|
||||
|
||||
// GET:Get An Entity By Id
|
||||
public async Task<IResult> GetAsync(Guid id, IActivityService activityService, CancellationToken cancellationToken)
|
||||
|
|
|
@ -10,12 +10,20 @@ public class PageController : ICarterModule
|
|||
.MapGroup($"api/page")
|
||||
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser());
|
||||
|
||||
group.MapGet("/dashboard/app", GetAppDashboardAsync)
|
||||
group.MapGet("/app/dashboard", GetAppDashboardAsync)
|
||||
.WithDisplayName("GetAppDashboard")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapGet("/app/shifting", GetAppShiftingPageAsync)
|
||||
.WithDisplayName("Get App Shifting Page")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public async Task<IResult> GetAppDashboardAsync([FromServices] IPageService pageService, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await pageService.GetAppDashboardAsync(cancellationToken));
|
||||
|
||||
public async Task<IResult> GetAppShiftingPageAsync([FromQuery]Guid routineId,[FromServices] IPageService pageService, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await pageService.GetShiftingPageAsync(routineId,cancellationToken));
|
||||
}
|
|
@ -39,7 +39,7 @@ public class ShiftController : ICarterModule
|
|||
|
||||
// GET:Get An Entity By Id
|
||||
public async Task<IResult> GetAsync(Guid id, ISender sender, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await sender.Send(new GetShiftQuery(id)));
|
||||
=> TypedResults.Ok(await sender.Send(new GetShiftQuery(id),cancellationToken));
|
||||
|
||||
// POST:Create Entity
|
||||
public async Task<IResult> Post([FromBody] CreateShiftCommand ent, ISender mediator, CancellationToken cancellationToken)
|
||||
|
|
|
@ -26,6 +26,12 @@ public class ShiftPlanController : ICarterModule
|
|||
.RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageShiftPlans))
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
|
||||
group.MapPost("{id:guid}/activity", GetShiftPlanActivitiesAsync)
|
||||
.WithDisplayName("Get Shift Plan Activities")
|
||||
.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);
|
||||
|
@ -42,6 +48,10 @@ public class ShiftPlanController : ICarterModule
|
|||
public async Task<IResult> CompletePlanAsync(Guid id,[FromBody] CompleteShiftPlanRequestDto requestDtos, [FromServices] IShiftPlanService shiftPlanService, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await shiftPlanService.CompleteShiftPlanAsync(id,requestDtos, cancellationToken));
|
||||
|
||||
// GET:Get All Entity
|
||||
public async Task<IResult> GetShiftPlanActivitiesAsync([FromRoute]Guid id,ISender sender, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await sender.Send(new GetShiftPlanActivitiesQuery(ShiftPlanId: id), cancellationToken));
|
||||
|
||||
|
||||
// GET:Get All Entity
|
||||
public async Task<IResult> GetAllAsync([FromQuery] int page, [FromQuery] long? selectedDate, [FromQuery] DateTimeQueryFilter? dateFilter , ISender sender, CancellationToken cancellationToken)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<meta charset="utf-8">
|
||||
<meta content="width=device-width, initial-scale=1.0" name="viewport">
|
||||
|
||||
<title>iGarson API</title>
|
||||
<title>BrizCo API</title>
|
||||
<meta content="" name="description">
|
||||
<meta content="" name="keywords">
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@ public static class SwaggerConfiguration
|
|||
new OpenApiInfo
|
||||
{
|
||||
Version = "v1",
|
||||
Title = "iGarson Api Dacument",
|
||||
Description = "iGarson api for clients that wana use",
|
||||
License = new OpenApiLicense { Name = "Vira Safir Fanavar " },
|
||||
Title = "BrizCo Api Document",
|
||||
Description = "BrizCo api document OpenApi based",
|
||||
License = new OpenApiLicense { Name = "Briz Corp" },
|
||||
Contact = new OpenApiContact
|
||||
{
|
||||
Name = "Amir Hossein Khademi",
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -3,4 +3,5 @@
|
|||
public interface IPageService : IScopedDependency
|
||||
{
|
||||
Task<AppDashboardPageDto> GetAppDashboardAsync(CancellationToken cancellationToken);
|
||||
Task<List<AppShiftingPageDayDto>> GetShiftingPageAsync(Guid routineId,CancellationToken cancellationToken);
|
||||
}
|
|
@ -1,9 +1,4 @@
|
|||
using Brizco.Domain.Entities.Complex;
|
||||
using Brizco.Domain.Mappers;
|
||||
using System.Linq;
|
||||
using Mapster;
|
||||
|
||||
namespace Brizco.Core.CoreServices;
|
||||
namespace Brizco.Core.CoreServices;
|
||||
|
||||
public class AccountService : IAccountService
|
||||
{
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using Brizco.Domain.Entities.Task;
|
||||
using System.Linq;
|
||||
using Brizco.Domain.Entities.Routine;
|
||||
using Brizco.Domain.Entities.Shift;
|
||||
using Task = Brizco.Domain.Entities.Task.Task;
|
||||
|
@ -11,15 +10,18 @@ public class PageService : IPageService
|
|||
private readonly ICurrentUserService _currentUserService;
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly RoleManager<ApplicationRole> _roleManager;
|
||||
private readonly IMediator _mediator;
|
||||
|
||||
public PageService(
|
||||
ICurrentUserService currentUserService,
|
||||
IRepositoryWrapper repositoryWrapper,
|
||||
RoleManager<ApplicationRole> roleManager)
|
||||
RoleManager<ApplicationRole> roleManager,
|
||||
IMediator mediator)
|
||||
{
|
||||
_currentUserService = currentUserService;
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_roleManager = roleManager;
|
||||
_mediator = mediator;
|
||||
}
|
||||
public async Task<AppDashboardPageDto> GetAppDashboardAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
|
@ -169,4 +171,40 @@ public class PageService : IPageService
|
|||
|
||||
return page;
|
||||
}
|
||||
|
||||
public async Task<List<AppShiftingPageDayDto>> GetShiftingPageAsync(Guid routineId,CancellationToken cancellationToken)
|
||||
{
|
||||
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 days = new List<AppShiftingPageDayDto>();
|
||||
DateTime day = DateTime.Today;
|
||||
|
||||
var shifts = await _mediator.Send(new GetRoutineShiftsQuery(routineId, 0),
|
||||
cancellationToken);
|
||||
|
||||
for (int i = 0 ; i < 15; i++ , day = day.AddDays(i))
|
||||
{
|
||||
var item = new AppShiftingPageDayDto
|
||||
{
|
||||
DateTime = DateTimeExtensions.DateTimeToUnixTimeStamp(day)
|
||||
};
|
||||
shifts.Where(s=>s.Day == day.DayOfWeek).SelectMany(s=>s.Shifts).ToList().ForEach(s=>item.Shifts.Add(s.Clone()));
|
||||
foreach (var shift in item.Shifts)
|
||||
{
|
||||
var existedShiftPlan = await _repositoryWrapper.SetRepository<Domain.Entities.Shift.ShiftPlan>()
|
||||
.TableNoTracking
|
||||
.FirstOrDefaultAsync(s => s.ShiftId == shift.Id && s.PlanFor.Date == day.Date, cancellationToken);
|
||||
shift.CurrentShiftPlanId = existedShiftPlan?.Id ?? default;
|
||||
shift.HasCurrentShiftPlan = shift.CurrentShiftPlanId != default;
|
||||
}
|
||||
item.TotalShifts = item.Shifts.Count;
|
||||
item.TotalShiftPlans = item.Shifts.Count(s => s.CurrentShiftPlanId != default);
|
||||
days.Add(item);
|
||||
}
|
||||
|
||||
return days;
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@ public class ShiftPlanReportCommandHandler : IRequestHandler<ShiftPlanReportComm
|
|||
throw new AppException("ShiftPlan not found", ApiResultStatusCode.NotFound);
|
||||
var activities = await _repositoryWrapper.SetRepository<Activity>()
|
||||
.TableNoTracking
|
||||
.Where(sp => sp.ShiftId == shiftPlan.ShiftId && sp.SetFor.Date == shiftPlan.PlanFor.Date)
|
||||
.Where(sp => sp.ShiftPlanId == shiftPlan.ShiftId && sp.SetFor.Date == shiftPlan.PlanFor.Date)
|
||||
.Select(ActivityMapper.ProjectToSDto)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
using Brizco.Domain.CommandQueries.Queries;
|
||||
using Brizco.Domain.Entities.Shift;
|
||||
using Brizco.Domain.Entities.Shift;
|
||||
using Brizco.Domain.Entities.Task;
|
||||
using System.Threading.Tasks;
|
||||
using Brizco.Domain.Mappers;
|
||||
using Task = Brizco.Domain.Entities.Task.Task;
|
||||
|
||||
namespace Brizco.Core.EntityServices;
|
||||
|
@ -25,7 +22,7 @@ public class ActivityService : IActivityService
|
|||
.TableNoTracking
|
||||
.FirstOrDefaultAsync(a => a.Id == activityId, cancellationToken);
|
||||
if (activity == null)
|
||||
throw new AppException("Activity not found ", ApiResultStatusCode.NotFound);
|
||||
throw new AppException("Activity not found", ApiResultStatusCode.NotFound);
|
||||
activity.DoneActivity();
|
||||
_repositoryWrapper.SetRepository<Activity>()
|
||||
.Update(activity);
|
||||
|
@ -109,7 +106,7 @@ public class ActivityService : IActivityService
|
|||
|
||||
var activities = await _repositoryWrapper.SetRepository<Activity>()
|
||||
.TableNoTracking
|
||||
.Where(a => a.ShiftId == shiftPlan.ShiftId && a.SetFor.Date == shiftPlan.PlanFor.Date)
|
||||
.Where(a => a.ShiftPlanId == shiftPlan.ShiftId && a.SetFor.Date == shiftPlan.PlanFor.Date)
|
||||
.Select(ActivityMapper.ProjectToLDto)
|
||||
.ToListAsync(cancellationToken);
|
||||
foreach (var activity in activities)
|
||||
|
@ -133,7 +130,7 @@ public class ActivityService : IActivityService
|
|||
|
||||
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.ShiftId, foundedUser.UserId), cancellationToken);
|
||||
, activity.AmountType, activity.ScheduleType, shiftPlan.Id, foundedUser.UserId), cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +192,7 @@ public class ActivityService : IActivityService
|
|||
{
|
||||
await _mediator.Send(new CreateActivityCommand(task.Type, task.Title, task.Description, task.IsDisposable,
|
||||
shiftPlan.PlanFor, task.HasDisposed, task.Amount, task.AmountType,
|
||||
task.ScheduleType, shiftPlan.ShiftId, fundedUser.UserId), cancellationToken);
|
||||
task.ScheduleType, shiftPlan.Id, fundedUser.UserId), cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!--<PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
@ -13,10 +13,10 @@
|
|||
<PackageReference Include="MediatR" Version="12.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.4" />
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
|
||||
</ItemGroup>-->
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<!--<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
|
@ -32,7 +32,7 @@
|
|||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
|
||||
</ItemGroup>
|
||||
</ItemGroup>-->
|
||||
|
||||
|
||||
<Target Name="Mapster">
|
||||
|
@ -69,10 +69,4 @@
|
|||
<Using Include="MediatR" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Dtos\PageDto\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -10,7 +10,7 @@ public sealed record CreateActivityCommand(
|
|||
int Amount,
|
||||
PurchaseAmountType AmountType,
|
||||
TaskScheduleType ScheduleType,
|
||||
Guid ShiftId,
|
||||
Guid ShiftPlanId,
|
||||
Guid UserId) : IRequest<ActivityLDto>;
|
||||
|
||||
public sealed record UpdateActivityCommand(Guid Id,
|
||||
|
@ -26,7 +26,7 @@ public sealed record UpdateActivityCommand(Guid Id,
|
|||
int Amount,
|
||||
PurchaseAmountType AmountType,
|
||||
TaskScheduleType ScheduleType,
|
||||
Guid ShiftId,
|
||||
Guid ShiftPlanId,
|
||||
Guid UserId) : IRequest<bool>;
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
namespace Brizco.Domain.CommandQueries.Queries;
|
||||
|
||||
public sealed record GetActivitiesQuery(int Page = 0 , long SelectedDate = 0 , Guid SelectedShift = default , DateQueryFilter? DateQueryFilter = null) :
|
||||
IRequest<List<ActivitySDto>>;
|
||||
public sealed record GetActivitiesQuery(int Page = 0 , long SelectedDate = 0 , Guid SelectedShiftPlanId = default , DateQueryFilter? DateQueryFilter = null) : IRequest<List<ActivitySDto>>;
|
||||
|
||||
public sealed record GetActivityQuery(Guid Id) :
|
||||
IRequest<ActivityLDto>;
|
||||
public sealed record GetActivityQuery(Guid Id) : IRequest<ActivityLDto>;
|
||||
|
||||
public sealed record GetShiftPlanActivitiesQuery(Guid ShiftPlanId) : IRequest<List<ActivitySDto>>;
|
|
@ -0,0 +1,15 @@
|
|||
namespace Brizco.Domain.Dtos.PageDto;
|
||||
|
||||
public class AppShiftingPageDto
|
||||
{
|
||||
public List<RoutineSDto> Routines { get; set; } = new List<RoutineSDto>();
|
||||
public List<AppShiftingPageDayDto> Days { get; set; } = new List<AppShiftingPageDayDto>();
|
||||
}
|
||||
|
||||
public class AppShiftingPageDayDto
|
||||
{
|
||||
public long DateTime { get; set; }
|
||||
public int TotalShifts { get; set; }
|
||||
public int TotalShiftPlans { get; set; }
|
||||
public List<ShiftSDto> Shifts { get; set; } = new List<ShiftSDto>();
|
||||
}
|
|
@ -2,25 +2,25 @@
|
|||
|
||||
public class ActivitySDto : BaseDto<ActivitySDto , Activity>
|
||||
{
|
||||
public TaskType Type { get; internal set; }
|
||||
public string Title { get; internal set; } = string.Empty;
|
||||
public string Description { get; internal set; } = string.Empty;
|
||||
public bool IsDisposable { get; internal set; }
|
||||
public DateTime SetFor { get; internal set; }
|
||||
public bool HasDisposed { get; internal set; }
|
||||
public TaskType Type { get; set; }
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public bool IsDisposable { get; set; }
|
||||
public DateTime SetFor { get; set; }
|
||||
public bool HasDisposed { get; set; }
|
||||
public TaskScheduleType ScheduleType { get; set; }
|
||||
public string UnDoneReason { get; set; } = string.Empty;
|
||||
public ActivityStatus Status { get; internal set; }
|
||||
public DateTime DoneAt { get; internal set; }
|
||||
public ActivityStatus Status { get; set; }
|
||||
public DateTime DoneAt { get; set; }
|
||||
public bool IsDone { get; set; }
|
||||
public string ShiftTitle { get; set; } = string.Empty;
|
||||
public string PerformanceDescription { get; internal set; } = string.Empty;
|
||||
public string PerformanceDescription { get; set; } = string.Empty;
|
||||
public string UserFirstName { get; set; } = string.Empty;
|
||||
public string UserLastName { get; set; } = string.Empty;
|
||||
public string UserFullName => UserFirstName + " " + UserLastName;
|
||||
|
||||
|
||||
public int Amount { get; internal set; }
|
||||
public Guid ShiftId { get; internal set; }
|
||||
public PurchaseAmountType AmountType { get; internal set; }
|
||||
public int Amount { get; set; }
|
||||
public Guid ShiftPlanId { get; set; }
|
||||
public PurchaseAmountType AmountType { get; set; }
|
||||
}
|
|
@ -1,6 +1,4 @@
|
|||
using Brizco.Domain.Entities.Shift;
|
||||
|
||||
namespace Brizco.Domain.Dtos.SmallDtos;
|
||||
namespace Brizco.Domain.Dtos.SmallDtos;
|
||||
public class ShiftSDto : BaseDto<ShiftSDto,Shift>
|
||||
{
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
@ -15,4 +13,5 @@ public class ShiftSDto : BaseDto<ShiftSDto,Shift>
|
|||
public TimeSpan EndAt { get; set; }
|
||||
public Guid ComplexId { get; set; }
|
||||
public List<DayOfWeek> Days { get; set; } = new();
|
||||
public string CurrentSupervisorFullName { get; set; } = string.Empty;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,6 @@ public partial class Activity : Task
|
|||
public Guid UserId { get; internal set; }
|
||||
public ApplicationUser? User { get; internal set; }
|
||||
|
||||
public Guid ShiftId { get; internal set; }
|
||||
public Shift.Shift? Shift { get; internal set; }
|
||||
public Guid ShiftPlanId { get; internal set; }
|
||||
public ShiftPlan? ShiftPlan { get; internal set; }
|
||||
}
|
|
@ -128,9 +128,9 @@ public partial class Activity
|
|||
scheduleType);
|
||||
}
|
||||
|
||||
public void SetShift(Guid shiftId)
|
||||
public void SetShiftPlan(Guid shiftPlanId)
|
||||
{
|
||||
this.ShiftId = shiftId;
|
||||
this.ShiftPlanId = shiftPlanId;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,4 +5,5 @@ public enum DateQueryFilter
|
|||
Today = 0,
|
||||
Tomorrow = 1,
|
||||
ThisWeek = 2,
|
||||
Yesterday = 3,
|
||||
}
|
|
@ -25,12 +25,8 @@ namespace Brizco.Domain.Mappers
|
|||
FirstName = p1.UserFirstName,
|
||||
LastName = p1.UserLastName
|
||||
},
|
||||
ShiftId = p1.ShiftId,
|
||||
Shift = new Shift()
|
||||
{
|
||||
Title = p1.ShiftTitle,
|
||||
Id = p1.ShiftId
|
||||
},
|
||||
ShiftPlanId = p1.ShiftPlanId,
|
||||
ShiftPlan = new ShiftPlan() {Id = p1.ShiftPlanId},
|
||||
Type = p1.Type,
|
||||
Title = p1.Title,
|
||||
Description = p1.Description,
|
||||
|
@ -57,8 +53,8 @@ namespace Brizco.Domain.Mappers
|
|||
result.UnDoneReason = p2.UnDoneReason;
|
||||
result.PerformanceDescription = p2.PerformanceDescription;
|
||||
result.User = funcMain1(new Never(), result.User, p2);
|
||||
result.ShiftId = p2.ShiftId;
|
||||
result.Shift = funcMain2(new Never(), result.Shift, p2);
|
||||
result.ShiftPlanId = p2.ShiftPlanId;
|
||||
result.ShiftPlan = funcMain2(new Never(), result.ShiftPlan, p2);
|
||||
result.Type = p2.Type;
|
||||
result.Title = p2.Title;
|
||||
result.Description = p2.Description;
|
||||
|
@ -84,12 +80,8 @@ namespace Brizco.Domain.Mappers
|
|||
FirstName = p8.UserFirstName,
|
||||
LastName = p8.UserLastName
|
||||
},
|
||||
ShiftId = p8.ShiftId,
|
||||
Shift = new Shift()
|
||||
{
|
||||
Title = p8.ShiftTitle,
|
||||
Id = p8.ShiftId
|
||||
},
|
||||
ShiftPlanId = p8.ShiftPlanId,
|
||||
ShiftPlan = new ShiftPlan() {Id = p8.ShiftPlanId},
|
||||
Type = p8.Type,
|
||||
Title = p8.Title,
|
||||
Description = p8.Description,
|
||||
|
@ -116,12 +108,12 @@ namespace Brizco.Domain.Mappers
|
|||
Status = p9.Status,
|
||||
DoneAt = p9.DoneAt,
|
||||
IsDone = p9.IsDone,
|
||||
ShiftTitle = p9.Shift != null ? p9.Shift.Title : string.Empty,
|
||||
ShiftTitle = p9.ShiftPlan != null ? (p9.ShiftPlan.Shift != null ? p9.ShiftPlan.Shift.Title : string.Empty) : string.Empty,
|
||||
PerformanceDescription = p9.PerformanceDescription,
|
||||
UserFirstName = p9.User != null ? p9.User.FirstName : string.Empty,
|
||||
UserLastName = p9.User != null ? p9.User.LastName : string.Empty,
|
||||
Amount = p9.Amount,
|
||||
ShiftId = p9.ShiftId,
|
||||
ShiftPlanId = p9.ShiftPlanId,
|
||||
AmountType = p9.AmountType,
|
||||
Id = p9.Id
|
||||
};
|
||||
|
@ -145,12 +137,12 @@ namespace Brizco.Domain.Mappers
|
|||
result.Status = p10.Status;
|
||||
result.DoneAt = p10.DoneAt;
|
||||
result.IsDone = p10.IsDone;
|
||||
result.ShiftTitle = p10.Shift != null ? p10.Shift.Title : string.Empty;
|
||||
result.ShiftTitle = p10.ShiftPlan != null ? (p10.ShiftPlan.Shift != null ? p10.ShiftPlan.Shift.Title : string.Empty) : string.Empty;
|
||||
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.Amount = p10.Amount;
|
||||
result.ShiftId = p10.ShiftId;
|
||||
result.ShiftPlanId = p10.ShiftPlanId;
|
||||
result.AmountType = p10.AmountType;
|
||||
result.Id = p10.Id;
|
||||
return result;
|
||||
|
@ -169,12 +161,12 @@ namespace Brizco.Domain.Mappers
|
|||
Status = p12.Status,
|
||||
DoneAt = p12.DoneAt,
|
||||
IsDone = p12.IsDone,
|
||||
ShiftTitle = p12.Shift != null ? p12.Shift.Title : string.Empty,
|
||||
ShiftTitle = p12.ShiftPlan != null ? (p12.ShiftPlan.Shift != null ? p12.ShiftPlan.Shift.Title : string.Empty) : string.Empty,
|
||||
PerformanceDescription = p12.PerformanceDescription,
|
||||
UserFirstName = p12.User != null ? p12.User.FirstName : string.Empty,
|
||||
UserLastName = p12.User != null ? p12.User.LastName : string.Empty,
|
||||
Amount = p12.Amount,
|
||||
ShiftId = p12.ShiftId,
|
||||
ShiftPlanId = p12.ShiftPlanId,
|
||||
AmountType = p12.AmountType,
|
||||
Id = p12.Id
|
||||
};
|
||||
|
@ -301,12 +293,11 @@ namespace Brizco.Domain.Mappers
|
|||
|
||||
}
|
||||
|
||||
private static Shift funcMain2(Never p6, Shift p7, ActivitySDto p2)
|
||||
private static ShiftPlan funcMain2(Never p6, ShiftPlan p7, ActivitySDto p2)
|
||||
{
|
||||
Shift result = p7 ?? new Shift();
|
||||
ShiftPlan result = p7 ?? new ShiftPlan();
|
||||
|
||||
result.Title = p2.ShiftTitle;
|
||||
result.Id = p2.ShiftId;
|
||||
result.Id = p2.ShiftPlanId;
|
||||
return result;
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class MapsterRegister : IRegister
|
|||
config.NewConfig<Activity, ActivitySDto>()
|
||||
.Map("UserFirstName", o => o.User !=null ? o.User.FirstName : string.Empty)
|
||||
.Map("UserLastName", o => o.User != null ? o.User.LastName : string.Empty)
|
||||
.Map("ShiftTitle",o=>o.Shift != null ? o.Shift.Title : string.Empty)
|
||||
.Map("ShiftTitle",o=>o.ShiftPlan != null ? o.ShiftPlan.Shift != null ? o.ShiftPlan.Shift.Title : string.Empty : string.Empty)
|
||||
.TwoWays();
|
||||
|
||||
config.NewConfig<Task, TaskLDto>()
|
||||
|
|
|
@ -37,7 +37,7 @@ public class CreateActivityCommandHandler : IRequestHandler<CreateActivityComman
|
|||
request.ScheduleType);
|
||||
activity.SetUser(request.UserId);
|
||||
|
||||
activity.SetShift(request.ShiftId);
|
||||
activity.SetShiftPlan(request.ShiftPlanId);
|
||||
|
||||
_repositoryWrapper.SetRepository<Domain.Entities.Task.Activity>().Add(activity);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
|
|
|
@ -35,6 +35,9 @@ public class GetActivitiesQueryHandler : IRequestHandler<GetActivitiesQuery, Lis
|
|||
{
|
||||
switch (request.DateQueryFilter)
|
||||
{
|
||||
case DateQueryFilter.Yesterday:
|
||||
activities = activities.Where(a => a.SetFor.Date == DateTime.Today.Date.AddDays(-1).Date);
|
||||
break;
|
||||
case DateQueryFilter.Today:
|
||||
activities = activities.Where(a => a.SetFor.Date == DateTime.Today.Date);
|
||||
break;
|
||||
|
@ -55,8 +58,8 @@ public class GetActivitiesQueryHandler : IRequestHandler<GetActivitiesQuery, Lis
|
|||
activities = activities.Where(a => a.SetFor.Date == selectedDate.Date);
|
||||
}
|
||||
|
||||
if (request.SelectedShift != default)
|
||||
activities = activities.Where(a => a.ShiftId == request.SelectedShift);
|
||||
if (request.SelectedShiftPlanId != default)
|
||||
activities = activities.Where(a => a.ShiftPlanId == request.SelectedShiftPlanId);
|
||||
|
||||
|
||||
var response= await activities.OrderByDescending(s => s.UserId)
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
namespace Brizco.Repository.Handlers.Activity;
|
||||
|
||||
public class GetShiftPlanActivitiesQueryHandler : IRequestHandler<GetShiftPlanActivitiesQuery, List<ActivitySDto>>
|
||||
{
|
||||
private IRepositoryWrapper _repositoryWrapper;
|
||||
public GetShiftPlanActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
}
|
||||
|
||||
public async Task<List<ActivitySDto>> Handle(GetShiftPlanActivitiesQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var activities = await _repositoryWrapper.SetRepository<Domain.Entities.Task.Activity>()
|
||||
.TableNoTracking
|
||||
.Where(a => a.ShiftPlanId == request.ShiftPlanId)
|
||||
.Select(ActivityMapper.ProjectToSDto)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
return activities;
|
||||
}
|
||||
}
|
|
@ -43,7 +43,7 @@ public class UpdateActivityCommandHandler : IRequestHandler<UpdateActivityComman
|
|||
newTask.Id = request.Id;
|
||||
|
||||
newTask.SetUser(request.UserId);
|
||||
newTask.SetShift(request.ShiftId);
|
||||
newTask.SetShiftPlan(request.ShiftPlanId);
|
||||
|
||||
_repositoryWrapper.SetRepository<Domain.Entities.Task.Activity>()
|
||||
.Update(newTask);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Brizco.Domain.Entities.Shift;
|
||||
using Brizco.Domain.Entities.User;
|
||||
using Guid = System.Guid;
|
||||
|
||||
namespace Brizco.Repository.Handlers.Shift;
|
||||
|
@ -6,11 +7,13 @@ namespace Brizco.Repository.Handlers.Shift;
|
|||
public class GetShiftPlansQueryHandler : IRequestHandler<GetShiftsQuery, List<ShiftSDto>>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly UserManager<ApplicationUser> _userManager;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
|
||||
public GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper,UserManager<ApplicationUser> userManager, ICurrentUserService currentUserService)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_userManager = userManager;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
public async Task<List<ShiftSDto>> Handle(GetShiftsQuery request, CancellationToken cancellationToken)
|
||||
|
@ -20,6 +23,7 @@ public class GetShiftPlansQueryHandler : IRequestHandler<GetShiftsQuery, List<Sh
|
|||
if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
|
||||
throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound);
|
||||
List<ShiftSDto> shifts;
|
||||
|
||||
if (request.SelectedDate > 0)
|
||||
{
|
||||
var selectedDate = DateTimeExtensions.UnixTimeStampToDateTime(request.SelectedDate);
|
||||
|
@ -32,15 +36,24 @@ public class GetShiftPlansQueryHandler : IRequestHandler<GetShiftsQuery, List<Sh
|
|||
shifts = await originalShifts.AsNoTracking().Select(ShiftMapper.ProjectToSDto).ToListAsync(cancellationToken);
|
||||
foreach (var shift in shifts)
|
||||
{
|
||||
var existedShiftPlan = await _repositoryWrapper.SetRepository<Domain.Entities.Shift.ShiftPlan>()
|
||||
.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());
|
||||
if (supervisor != null)
|
||||
shift.CurrentSupervisorFullName = supervisor.FirstName + " " + supervisor.LastName;
|
||||
|
||||
var activitiesCount = await _repositoryWrapper.SetRepository<Domain.Entities.Task.Activity>()
|
||||
.TableNoTracking
|
||||
.CountAsync(a => a.SetFor.Date == selectedDate.Date && a.ShiftId == shift.Id, cancellationToken);
|
||||
.CountAsync(a => a.SetFor.Date == selectedDate.Date && a.ShiftPlanId == existedShiftPlan.Id, cancellationToken);
|
||||
var doneActivitiesCount = await _repositoryWrapper.SetRepository<Domain.Entities.Task.Activity>()
|
||||
.TableNoTracking
|
||||
.CountAsync(a => a.Status == ActivityStatus.Done && a.SetFor.Date == selectedDate.Date && a.ShiftId == shift.Id, cancellationToken);
|
||||
.CountAsync(a => a.Status == ActivityStatus.Done && a.SetFor.Date == selectedDate.Date && a.ShiftPlanId == existedShiftPlan.Id, cancellationToken);
|
||||
var undoneActivitiesCount = await _repositoryWrapper.SetRepository<Domain.Entities.Task.Activity>()
|
||||
.TableNoTracking
|
||||
.CountAsync(a => a.Status == ActivityStatus.UnDone && a.SetFor.Date == selectedDate.Date && a.ShiftId == shift.Id, cancellationToken);
|
||||
.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;
|
||||
|
@ -53,19 +66,16 @@ public class GetShiftPlansQueryHandler : IRequestHandler<GetShiftsQuery, List<Sh
|
|||
{
|
||||
if (!Guid.TryParse(_currentUserService.UserId, out Guid userId))
|
||||
throw new AppException("User id is wrong");
|
||||
var existedShiftPlan = await _repositoryWrapper.SetRepository<Domain.Entities.Shift.ShiftPlan>()
|
||||
var existedSupervisorShiftPlan = await _repositoryWrapper.SetRepository<Domain.Entities.Shift.ShiftPlan>()
|
||||
.TableNoTracking
|
||||
.FirstOrDefaultAsync(s => s.ShiftId == shift.Id && s.PlanFor.Date == selectedDate.Date && s.SupervisorId == userId, cancellationToken);
|
||||
shift.IsCompleted = existedShiftPlan?.IsCompleted ?? false;
|
||||
shift.CurrentShiftPlanId = existedShiftPlan?.Id ?? default;
|
||||
shift.HasCurrentShiftPlan = existedShiftPlan != null;
|
||||
shift.IsCompleted = existedSupervisorShiftPlan?.IsCompleted ?? false;
|
||||
shift.CurrentShiftPlanId = existedSupervisorShiftPlan?.Id ?? default;
|
||||
shift.HasCurrentShiftPlan = existedSupervisorShiftPlan != null;
|
||||
break;
|
||||
}
|
||||
case ApplicationRoles.Manager:
|
||||
{
|
||||
var existedShiftPlan = await _repositoryWrapper.SetRepository<Domain.Entities.Shift.ShiftPlan>()
|
||||
.TableNoTracking
|
||||
.FirstOrDefaultAsync(s => s.ShiftId == shift.Id && s.PlanFor.Date == selectedDate.Date, cancellationToken);
|
||||
shift.IsCompleted = existedShiftPlan?.IsCompleted ?? false;
|
||||
shift.CurrentShiftPlanId = existedShiftPlan?.Id ?? default;
|
||||
shift.HasCurrentShiftPlan = existedShiftPlan != null;
|
||||
|
@ -94,10 +104,7 @@ public class GetShiftPlansQueryHandler : IRequestHandler<GetShiftsQuery, List<Sh
|
|||
if (d == DayOfWeek.Saturday)
|
||||
shiftDays.Insert(0, d);
|
||||
else
|
||||
{
|
||||
shiftDays.Add(d);
|
||||
}
|
||||
|
||||
});
|
||||
shift.Days = shiftDays;
|
||||
}
|
||||
|
|
|
@ -141,13 +141,13 @@ public class GetShiftPlansQueryHandler : IRequestHandler<GetShiftPlansQuery, Lis
|
|||
{
|
||||
var activitiesCount = await _repositoryWrapper.SetRepository<Domain.Entities.Task.Activity>()
|
||||
.TableNoTracking
|
||||
.CountAsync(a => a.SetFor.Date == shiftPlan.PlanFor.Date && a.ShiftId == shiftPlan.Id, cancellationToken);
|
||||
.CountAsync(a => a.SetFor.Date == shiftPlan.PlanFor.Date && a.ShiftPlanId == shiftPlan.Id, cancellationToken);
|
||||
var doneActivitiesCount = await _repositoryWrapper.SetRepository<Domain.Entities.Task.Activity>()
|
||||
.TableNoTracking
|
||||
.CountAsync(a => a.Status == ActivityStatus.Done && a.SetFor.Date == shiftPlan.PlanFor.Date && a.ShiftId == shiftPlan.Id, cancellationToken);
|
||||
.CountAsync(a => a.Status == ActivityStatus.Done && a.SetFor.Date == shiftPlan.PlanFor.Date && a.ShiftPlanId == shiftPlan.Id, cancellationToken);
|
||||
var undoneActivitiesCount = await _repositoryWrapper.SetRepository<Domain.Entities.Task.Activity>()
|
||||
.TableNoTracking
|
||||
.CountAsync(a => a.Status == ActivityStatus.UnDone && a.SetFor.Date == shiftPlan.PlanFor.Date && a.ShiftId == shiftPlan.Id, cancellationToken);
|
||||
.CountAsync(a => a.Status == ActivityStatus.UnDone && a.SetFor.Date == shiftPlan.PlanFor.Date && a.ShiftPlanId == shiftPlan.Id, cancellationToken);
|
||||
shiftPlan.UndoneActivitiesCount = undoneActivitiesCount;
|
||||
shiftPlan.DoneActivitiesCount = doneActivitiesCount;
|
||||
shiftPlan.TotalActivitiesCount = activitiesCount;
|
||||
|
|
1416
Brizco.Repository/Migrations/20240518121502_editActivityAddShiftPlanId.Designer.cs
generated
100644
1416
Brizco.Repository/Migrations/20240518121502_editActivityAddShiftPlanId.Designer.cs
generated
100644
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,72 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Brizco.Repository.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class editActivityAddShiftPlanId : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Tasks_Shifts_ShiftId",
|
||||
schema: "public",
|
||||
table: "Tasks");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "ShiftId",
|
||||
schema: "public",
|
||||
table: "Tasks",
|
||||
newName: "ShiftPlanId");
|
||||
|
||||
migrationBuilder.RenameIndex(
|
||||
name: "IX_Tasks_ShiftId",
|
||||
schema: "public",
|
||||
table: "Tasks",
|
||||
newName: "IX_Tasks_ShiftPlanId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Tasks_ShiftPlans_ShiftPlanId",
|
||||
schema: "public",
|
||||
table: "Tasks",
|
||||
column: "ShiftPlanId",
|
||||
principalSchema: "public",
|
||||
principalTable: "ShiftPlans",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Tasks_ShiftPlans_ShiftPlanId",
|
||||
schema: "public",
|
||||
table: "Tasks");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "ShiftPlanId",
|
||||
schema: "public",
|
||||
table: "Tasks",
|
||||
newName: "ShiftId");
|
||||
|
||||
migrationBuilder.RenameIndex(
|
||||
name: "IX_Tasks_ShiftPlanId",
|
||||
schema: "public",
|
||||
table: "Tasks",
|
||||
newName: "IX_Tasks_ShiftId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Tasks_Shifts_ShiftId",
|
||||
schema: "public",
|
||||
table: "Tasks",
|
||||
column: "ShiftId",
|
||||
principalSchema: "public",
|
||||
principalTable: "Shifts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@ namespace Brizco.Repository.Migrations
|
|||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasDefaultSchema("public")
|
||||
.HasAnnotation("ProductVersion", "8.0.0")
|
||||
.HasAnnotation("ProductVersion", "8.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
@ -1030,7 +1030,7 @@ namespace Brizco.Repository.Migrations
|
|||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("ShiftId")
|
||||
b.Property<Guid>("ShiftPlanId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Status")
|
||||
|
@ -1043,7 +1043,7 @@ namespace Brizco.Repository.Migrations
|
|||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasIndex("ShiftId");
|
||||
b.HasIndex("ShiftPlanId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
|
@ -1340,9 +1340,9 @@ namespace Brizco.Repository.Migrations
|
|||
|
||||
modelBuilder.Entity("Brizco.Domain.Entities.Task.Activity", b =>
|
||||
{
|
||||
b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift")
|
||||
b.HasOne("Brizco.Domain.Entities.Shift.ShiftPlan", "ShiftPlan")
|
||||
.WithMany()
|
||||
.HasForeignKey("ShiftId")
|
||||
.HasForeignKey("ShiftPlanId")
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User")
|
||||
|
@ -1350,7 +1350,7 @@ namespace Brizco.Repository.Migrations
|
|||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
b.Navigation("Shift");
|
||||
b.Navigation("ShiftPlan");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue