add version 0.1.3.2
parent
81cb0e8df3
commit
79ab136ac3
|
@ -6,8 +6,8 @@
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
|
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
|
||||||
<AssemblyVersion>0.1.3.1</AssemblyVersion>
|
<AssemblyVersion>0.1.3.2</AssemblyVersion>
|
||||||
<FileVersion>0.1.3.1</FileVersion>
|
<FileVersion>0.1.3.2</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
namespace Brizco.Core.EntityServices.Abstracts;
|
||||||
|
|
||||||
|
public interface IActivityService : IScopedDependency
|
||||||
|
{
|
||||||
|
Task CreateActivitiesByShiftPlan(Guid shiftPlanId, CancellationToken cancellationToken);
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
using Brizco.Domain.CommandQueries.Queries;
|
||||||
|
using Brizco.Domain.Entities.Task;
|
||||||
|
|
||||||
|
namespace Brizco.Core.EntityServices;
|
||||||
|
|
||||||
|
public class ActivityService : IActivityService
|
||||||
|
{
|
||||||
|
private readonly IMediator _mediator;
|
||||||
|
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||||
|
|
||||||
|
public ActivityService(IMediator mediator,IRepositoryWrapper repositoryWrapper)
|
||||||
|
{
|
||||||
|
_mediator = mediator;
|
||||||
|
_repositoryWrapper = repositoryWrapper;
|
||||||
|
}
|
||||||
|
public async System.Threading.Tasks.Task CreateActivitiesByShiftPlan(Guid shiftPlanId,CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var shiftPlan = await _mediator.Send(new GetShiftPlanQuery(shiftPlanId), cancellationToken);
|
||||||
|
var tasks = _repositoryWrapper.SetRepository<Brizco.Domain.Entities.Task.Task>()
|
||||||
|
.ExecuteCommand(
|
||||||
|
$@"SELECT t.Id, t.Type, t.Title t.Description t.IsDisposable t.SetFor t.HasDisposed t.ScheduleType t.Amount t.AmountType
|
||||||
|
FROM Task t
|
||||||
|
INNER JOIN TaskShifts t1 ON t.Id = t1.TaskId
|
||||||
|
INNER JOIN TaskDays t2 ON t.Id = t1.TaskId
|
||||||
|
INNER JOIN TaskRoutines t3 ON t.Id = t1.TaskId
|
||||||
|
WHERE {shiftPlan.ShiftId} = t1.ShiftId
|
||||||
|
AND {shiftPlan.PlanFor.DayOfWeek} = t2.DayOfWeek
|
||||||
|
AND ON {shiftPlan.RoutineId} = t3.RoutineId ");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
namespace Brizco.Domain.CommandQueries.Commands;
|
namespace Brizco.Domain.CommandQueries.Commands;
|
||||||
|
|
||||||
public record CreateShiftPlanCommand(DateTime PlanDate,Guid ShiftId,Guid RoutineId, List<KeyValuePair<Guid,Guid>> UserAndPositionIds)
|
public record CreateShiftPlanCommand(long PlanDate,Guid ShiftId,Guid RoutineId, List<KeyValuePair<Guid,Guid>> UserAndPositionIds)
|
||||||
:IRequest<ShiftPlanLDto>;
|
:IRequest<ShiftPlanLDto>;
|
||||||
|
|
||||||
public record UpdateShiftPlanCommand(Guid Id,DateTime PlanDate, Guid ShiftId, Guid RoutineId, List<KeyValuePair<Guid, Guid>> UserAndPositionIds)
|
public record UpdateShiftPlanCommand(Guid Id,long PlanDate, Guid ShiftId, Guid RoutineId, List<KeyValuePair<Guid, Guid>> UserAndPositionIds)
|
||||||
: IRequest<bool>;
|
: IRequest<bool>;
|
||||||
|
|
||||||
public record DeleteShiftPlanCommand(Guid Id)
|
public record DeleteShiftPlanCommand(Guid Id)
|
||||||
|
|
|
@ -4,8 +4,8 @@ namespace Brizco.Domain.Dtos.LargDtos;
|
||||||
|
|
||||||
public class ShiftPlanLDto : BaseDto<ShiftPlanLDto , ShiftPlan>
|
public class ShiftPlanLDto : BaseDto<ShiftPlanLDto , ShiftPlan>
|
||||||
{
|
{
|
||||||
public DateTime StartAt { get; set; }
|
public DateTime PlanFor { get; set; }
|
||||||
public DateTime EndAt { get; set; }
|
public Guid RoutineId { get; set; }
|
||||||
public Guid ShiftId { get; set; }
|
public Guid ShiftId { get; set; }
|
||||||
public List<ShiftPlanUserSDto> Users { get; internal set; } = new();
|
public List<ShiftPlanUserSDto> Users { get; set; } = new();
|
||||||
}
|
}
|
|
@ -37,4 +37,7 @@ public partial class Activity : Task
|
||||||
public string PerformanceDescription { get; internal set; } = string.Empty;
|
public string PerformanceDescription { get; internal set; } = string.Empty;
|
||||||
public Guid UserId { get; internal set; }
|
public Guid UserId { get; internal set; }
|
||||||
public ApplicationUser? User { get; internal set; }
|
public ApplicationUser? User { get; internal set; }
|
||||||
|
|
||||||
|
public Guid ShiftId { get; internal set; }
|
||||||
|
public Shift.Shift? Shift { get; internal set; }
|
||||||
}
|
}
|
|
@ -19,7 +19,7 @@ public class CreateShiftPlanCommandHandler : IRequestHandler<CreateShiftPlanComm
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _repositoryWrapper.BeginTransaction(cancellationToken);
|
await _repositoryWrapper.BeginTransaction(cancellationToken);
|
||||||
var shiftPlan = shift.AddPlan(request.PlanDate,request.RoutineId);
|
var shiftPlan = shift.AddPlan(DateTimeExtensions.UnixTimeStampToDateTime(request.PlanDate),request.RoutineId);
|
||||||
|
|
||||||
if (request.UserAndPositionIds.Count == 0)
|
if (request.UserAndPositionIds.Count == 0)
|
||||||
throw new AppException("شیفت بندی مورد نظر باید حداقل متشکل از یک فرد باشد", ApiResultStatusCode.BadRequest);
|
throw new AppException("شیفت بندی مورد نظر باید حداقل متشکل از یک فرد باشد", ApiResultStatusCode.BadRequest);
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class UpdateShiftPlanCommandHandler : IRequestHandler<UpdateShiftPlanComm
|
||||||
throw new AppException("Shift not found", ApiResultStatusCode.NotFound);
|
throw new AppException("Shift not found", ApiResultStatusCode.NotFound);
|
||||||
|
|
||||||
|
|
||||||
var newPlan = shift.AddPlan(request.PlanDate,request.RoutineId);
|
var newPlan = shift.AddPlan(DateTimeExtensions.UnixTimeStampToDateTime(request.PlanDate), request.RoutineId);
|
||||||
newPlan.Id = request.Id;
|
newPlan.Id = request.Id;
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,57 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Brizco.Repository.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class editActivity : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "ShiftId",
|
||||||
|
schema: "public",
|
||||||
|
table: "Tasks",
|
||||||
|
type: "uuid",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Tasks_ShiftId",
|
||||||
|
schema: "public",
|
||||||
|
table: "Tasks",
|
||||||
|
column: "ShiftId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Tasks_Shifts_ShiftId",
|
||||||
|
schema: "public",
|
||||||
|
table: "Tasks",
|
||||||
|
column: "ShiftId",
|
||||||
|
principalSchema: "public",
|
||||||
|
principalTable: "Shifts",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Tasks_Shifts_ShiftId",
|
||||||
|
schema: "public",
|
||||||
|
table: "Tasks");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Tasks_ShiftId",
|
||||||
|
schema: "public",
|
||||||
|
table: "Tasks");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "ShiftId",
|
||||||
|
schema: "public",
|
||||||
|
table: "Tasks");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1054,12 +1054,17 @@ namespace Brizco.Repository.Migrations
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("ShiftId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<int>("Status")
|
b.Property<int>("Status")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<Guid>("UserId")
|
b.Property<Guid>("UserId")
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasIndex("ShiftId");
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
b.HasDiscriminator().HasValue("Activity");
|
b.HasDiscriminator().HasValue("Activity");
|
||||||
|
@ -1372,12 +1377,20 @@ namespace Brizco.Repository.Migrations
|
||||||
|
|
||||||
modelBuilder.Entity("Brizco.Domain.Entities.Task.Activity", b =>
|
modelBuilder.Entity("Brizco.Domain.Entities.Task.Activity", b =>
|
||||||
{
|
{
|
||||||
|
b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ShiftId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User")
|
b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Restrict)
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Shift");
|
||||||
|
|
||||||
b.Navigation("User");
|
b.Navigation("User");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
public interface IReadRepository<T> where T : class, IApiEntity
|
public interface IReadRepository<T> where T : class, IApiEntity
|
||||||
{
|
{
|
||||||
DbSet<T> Entities { get; }
|
DbSet<T> Entities { get; }
|
||||||
|
IQueryable<T> ExecuteCommand(FormattableString command);
|
||||||
IQueryable<T> Table { get; }
|
IQueryable<T> Table { get; }
|
||||||
IQueryable<T> TableNoTracking { get; }
|
IQueryable<T> TableNoTracking { get; }
|
||||||
T GetById(params object[] ids);
|
T GetById(params object[] ids);
|
||||||
|
|
|
@ -5,5 +5,6 @@
|
||||||
DbSet<T> Entities { get; }
|
DbSet<T> Entities { get; }
|
||||||
IQueryable<T> Table { get; }
|
IQueryable<T> Table { get; }
|
||||||
IQueryable<T> TableNoTracking { get; }
|
IQueryable<T> TableNoTracking { get; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,7 @@
|
||||||
namespace Brizco.Repository.Repositories.Base
|
using System.Text;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace Brizco.Repository.Repositories.Base
|
||||||
{
|
{
|
||||||
public class Repository<T> : IRepository<T> where T : class, IApiEntity
|
public class Repository<T> : IRepository<T> where T : class, IApiEntity
|
||||||
{
|
{
|
||||||
|
@ -27,5 +30,10 @@
|
||||||
{
|
{
|
||||||
DbContext?.Dispose();
|
DbContext?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IQueryable<T> ExecuteCommand(FormattableString command)
|
||||||
|
{
|
||||||
|
return DbContext.Set<T>().FromSql(command);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue