feat : add report controller , change models

add task and shiftplan report handlers , chnage shfitplan and taskshift dtos
master
Amir Hossein Khademi 2024-02-21 02:07:41 +03:30
parent 5ab4c601fb
commit 70f83b627b
34 changed files with 6193 additions and 257 deletions

View File

@ -13,7 +13,7 @@
}
},
"SiteSettings": {
"BaseUrl": "http://192.168.88.12:32769",
"BaseUrl": "http://192.168.88.251:32769",
"KaveNegarApiKey": "3735494B4143727A794346457461576A2B4B6668414973424E333561505A694B",
"UserSetting": {
"Username": "root",

View File

@ -11,47 +11,47 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Asp.Versioning.Http" Version="7.1.0" />
<PackageReference Include="Asp.Versioning.Http" Version="8.0.0" />
<PackageReference Include="Ben.BlockingDetector" Version="0.0.4" />
<PackageReference Include="Carter" Version="7.2.0" />
<PackageReference Include="FluentValidation" Version="11.8.1" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.8.1" />
<PackageReference Include="MediatR.Extensions.Autofac.DependencyInjection" Version="11.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0">
<PackageReference Include="Carter" Version="8.0.0" />
<PackageReference Include="FluentValidation" Version="11.9.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.0" />
<PackageReference Include="MediatR.Extensions.Autofac.DependencyInjection" Version="12.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Autofac" Version="7.1.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Autofac" Version="8.0.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Elmah.Io.AspNetCore.Serilog" Version="5.0.17" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.0" />
<PackageReference Include="Sentry.Serilog" Version="3.41.3" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.1" />
<PackageReference Include="Sentry.Serilog" Version="4.1.1" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.PostgreSQL" Version="2.3.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.ElmahIo" Version="5.0.38" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="StackExchange.Redis.Extensions.AspNetCore" Version="9.1.0" />
<PackageReference Include="StackExchange.Redis.Extensions.Core" Version="9.1.0" />
<PackageReference Include="StackExchange.Redis.Extensions.Newtonsoft" Version="9.1.0" />
<PackageReference Include="StackExchange.Redis.Extensions.AspNetCore" Version="10.2.0" />
<PackageReference Include="StackExchange.Redis.Extensions.Core" Version="10.2.0" />
<PackageReference Include="StackExchange.Redis.Extensions.Newtonsoft" Version="10.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="7.0.12" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
<PackageReference Include="System.Drawing.Common" Version="8.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="8.0.1" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
<PackageReference Include="System.Drawing.Common" Version="8.0.2" />
</ItemGroup>
<ItemGroup>
<Using Include="Autofac" />

View File

@ -0,0 +1,35 @@
using Brizco.Core.CoreServices.ReportServices.Commands;
using MediatR;
namespace Brizco.Api.Controllers;
public class ReportController : ICarterModule
{
public void AddRoutes(IEndpointRouteBuilder app)
{
var group = app.NewVersionedApi("Report")
.MapGroup("api/report");
group.MapGet("task", GetTasksReportAsync)
.WithDisplayName("Get Tasks Report")
.HasApiVersion(1.0);
group.MapGet("shit/plan/{shiftPLanId}", GetShiftPlanReportAsync)
.WithDisplayName("Get ShiftPlan Report")
.HasApiVersion(1.0);
}
public async Task<IResult> GetTasksReportAsync([FromServices]IMediator mediator,CancellationToken cancellationToken)
{
var file = await mediator.Send(new TaskReportCommand(),cancellationToken);
string fileName = $"TaskReport_{DateTime.Now:yyyy-MM-dd}.xlsx";
return TypedResults.File(file, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName);
}
public async Task<IResult> GetShiftPlanReportAsync(Guid shiftPLanId,[FromServices] IMediator mediator, CancellationToken cancellationToken)
{
var file = await mediator.Send(new ShiftPlanReportCommand(ShiftPlanId: shiftPLanId), cancellationToken);
string fileName = $"ShiftPlanReport_{DateTime.Now:yyyy-MM-dd}.xlsx";
return TypedResults.File(file, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName);
}
}

View File

@ -11,7 +11,7 @@
<PackageReference Include="MD.PersianDateTime.Standard" Version="2.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.0.3" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.3.1" />
</ItemGroup>-->
<PropertyGroup>

View File

@ -245,6 +245,27 @@ public static class ApplicationClaims
ViewComplexSettings.GetClaim
};
public static List<Claim> ViewerOwnerClaims = new List<Claim>
{
ViewStaffs.GetClaim,
ViewActivities.GetClaim,
ViewTasks.GetClaim,
ViewShiftPlans.GetClaim,
ViewShifts.GetClaim,
ViewRoutines.GetClaim,
ViewPositions.GetClaim,
ViewSections.GetClaim,
ViewDashboard.GetClaim,
ViewComplexSettings.GetClaim
};
public static List<Claim> SuperVisorClaims = new List<Claim>
{

View File

@ -12,7 +12,8 @@
<PackageReference Include="AspNetCoreRateLimit.Redis" Version="2.0.0" />
<PackageReference Include="Autofac.Extras.Quartz" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="Quartz" Version="3.8.0" />
<PackageReference Include="NPOI" Version="2.6.2" />
<PackageReference Include="Quartz" Version="3.8.1" />
</ItemGroup>
<ItemGroup>
@ -32,8 +33,10 @@
<Using Include="Brizco.Core.Abstracts" />
<Using Include="Brizco.Core.BaseServices.Abstracts" />
<Using Include="Brizco.Core.CoreServices.Abstracts" />
<Using Include="Brizco.Core.CoreServices.ReportServices.Commands" />
<Using Include="Brizco.Core.EntityServices.Abstracts" />
<Using Include="Brizco.Domain.CommandQueries.Commands" />
<Using Include="Brizco.Domain.Dtos.LargDtos" />
<Using Include="Brizco.Domain.Dtos.PageDto" />
<Using Include="Brizco.Domain.Dtos.RequestDtos" />
<Using Include="Brizco.Domain.Dtos.ResponseDto" />
@ -41,12 +44,16 @@
<Using Include="Brizco.Domain.Entities.Complex" />
<Using Include="Brizco.Domain.Entities.User" />
<Using Include="Brizco.Domain.Enums" />
<Using Include="Brizco.Domain.Mappers" />
<Using Include="Brizco.Repository.Abstracts" />
<Using Include="Brizco.Repository.Repositories.Base.Contracts" />
<Using Include="MediatR" />
<Using Include="Microsoft.AspNetCore.Identity" />
<Using Include="Microsoft.EntityFrameworkCore" />
<Using Include="Microsoft.IdentityModel.Tokens" />
<Using Include="NPOI.SS.UserModel" />
<Using Include="NPOI.SS.Util" />
<Using Include="NPOI.XSSF.UserModel" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,6 @@
namespace Brizco.Core.CoreServices.ReportServices.Commands;
public interface IReportService : IScopedDependency
{
Task<byte[]> GetTaskReportAsync();
}

View File

@ -0,0 +1,4 @@
namespace Brizco.Core.CoreServices.ReportServices.Commands;
public sealed record TaskReportCommand() : IRequest<byte[]>;
public sealed record ShiftPlanReportCommand(Guid ShiftPlanId) : IRequest<byte[]>;

View File

@ -0,0 +1,126 @@
using Brizco.Domain.Entities.Shift;
using Brizco.Domain.Entities.Task;
namespace Brizco.Core.CoreServices.ReportServices;
public class ShiftPlanReportCommandHandler : IRequestHandler<ShiftPlanReportCommand, byte[]>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public ShiftPlanReportCommandHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<byte[]> Handle(ShiftPlanReportCommand request, CancellationToken cancellationToken)
{
var shiftPlan = await _repositoryWrapper.SetRepository<ShiftPlan>()
.TableNoTracking
.Where(sp => sp.Id == request.ShiftPlanId)
.Select(ShiftPlanMapper.ProjectToSDto)
.FirstOrDefaultAsync(cancellationToken);
if (shiftPlan == null)
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)
.Select(ActivityMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
var workbook = new XSSFWorkbook();
var sheet = workbook.CreateSheet($"شیفت {shiftPlan.ShiftTitle} - {shiftPlan.PlanFor.ToPersianDateTime().ToLongDateString()}");
sheet.IsRightToLeft = true;
int selectedRow = 1;
CreateHeader(sheet, workbook);
foreach (var activity in activities)
{
var row = sheet.GetRow(selectedRow) ?? sheet.CreateRow(selectedRow);
row.Height = 700;
var style = workbook.CreateCellStyle();
style.VerticalAlignment = VerticalAlignment.Center;
style.Alignment = HorizontalAlignment.Center;
style.WrapText = true;
var cell = row.CreateCell(0);
cell.CellStyle = style;
cell.SetCellValue(activity.Title);
var personCell = row.CreateCell(1);
personCell.CellStyle = style;
personCell.SetCellValue(activity.UserFullName);
var statusCell = row.CreateCell(2);
statusCell.CellStyle = style;
statusCell.SetCellValue(activity.Status.ToDisplay());
var doneAtCell = row.CreateCell(3);
doneAtCell.CellStyle = style;
doneAtCell.SetCellValue(activity.Title);
var unDoneReasonCell = row.CreateCell(4);
unDoneReasonCell.CellStyle = style;
unDoneReasonCell.SetCellValue(activity.UnDoneReason);
selectedRow++;
}
sheet.SetColumnWidth(0, 25600);
sheet.SetColumnWidth(1, 7000);
sheet.SetColumnWidth(2, 7000);
sheet.SetColumnWidth(3, 7000);
sheet.SetColumnWidth(4, 7000);
var stream = new MemoryStream();
workbook.Write(stream);
var content = stream.ToArray();
return content;
}
void CreateHeader(ISheet sheet, XSSFWorkbook workbook)
{
var headerRow = sheet.GetRow(0) ?? sheet.CreateRow(0);
headerRow.Height = 700;
var font = workbook.CreateFont();
font.IsBold = true;
font.Color = NPOI.HSSF.Util.HSSFColor.White.Index;
//font.FontHeight = 16;
var style = workbook.CreateCellStyle();
style.Alignment = HorizontalAlignment.Center;
style.VerticalAlignment = VerticalAlignment.Center;
style.WrapText = true;
style.SetFont(font);
byte[] rgb = new byte[3] { 30, 81, 123 };
XSSFColor color = new XSSFColor(rgb);
//style.SetFillBackgroundColor(color);
//style.SetFillForegroundColor(color);
style.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.BlueGrey.Index;
style.FillPattern = FillPattern.SolidForeground;
var shiftNameHeaderCell = headerRow.CreateCell(0);
shiftNameHeaderCell.CellStyle = style;
shiftNameHeaderCell.SetCellValue("تسکــــ");
var taskNameHeaderCell = headerRow.CreateCell(1);
taskNameHeaderCell.CellStyle = style;
taskNameHeaderCell.SetCellValue("شخص");
var positionNameHeaderCell = headerRow.CreateCell(2);
positionNameHeaderCell.CellStyle = style;
positionNameHeaderCell.SetCellValue("وضعیت");
var doneAtHeaderCell = headerRow.CreateCell(3);
doneAtHeaderCell.CellStyle = style;
doneAtHeaderCell.SetCellValue("انجام شده در");
var unDoneReasonAtHeaderCell = headerRow.CreateCell(4);
unDoneReasonAtHeaderCell.CellStyle = style;
unDoneReasonAtHeaderCell.SetCellValue("دلیل انجام نشدن");
}
}

View File

@ -0,0 +1,213 @@
using Brizco.Domain.Entities.Task;
using Task = System.Threading.Tasks.Task;
namespace Brizco.Core.CoreServices.ReportServices;
public class TaskReportCommandHandler : IRequestHandler<TaskReportCommand , byte[]>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public TaskReportCommandHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<byte[]> Handle(TaskReportCommand request, CancellationToken cancellationToken)
{
var tasks = await _repositoryWrapper.SetRepository<Brizco.Domain.Entities.Task.Task>()
.TableNoTracking
.Select(TaskMapper.ProjectToLDto)
.ToListAsync(cancellationToken);
var workbook = new XSSFWorkbook();
var sheet = workbook.CreateSheet("روزانه");
sheet.IsRightToLeft = true;
int selectedRow = 1;
var originalTasks = tasks.Where(t => t.ScheduleType == TaskScheduleType.Daily).ToList();
CreateHeader(sheet, workbook);
var shiftsTask = originalTasks.SelectMany(dt => dt.Shifts).ToList();
foreach (var taskShiftGrouped in shiftsTask.GroupBy(t => t.ShiftId))
{
var count = taskShiftGrouped.ToList().Count - 1;
var shiftName = taskShiftGrouped.FirstOrDefault()?.ShiftName ?? string.Empty;
CreateShiftName(selectedRow, selectedRow + count, shiftName, sheet, workbook);
int j = selectedRow;
foreach (var taskShiftSDto in taskShiftGrouped)
{
var row = sheet.GetRow(j) ?? sheet.CreateRow(j);
row.Height = 700;
var style = workbook.CreateCellStyle();
style.VerticalAlignment = VerticalAlignment.Center;
style.Alignment = HorizontalAlignment.Center;
style.WrapText = true;
var cell = row.CreateCell(1);
cell.CellStyle = style;
cell.SetCellValue(taskShiftSDto.TaskTitle);
var position = await _repositoryWrapper.SetRepository<TaskPosition>()
.TableNoTracking
.Where(t => t.TaskId == taskShiftSDto.TaskId)
.Select(TaskPositionMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
var positionCell = row.CreateCell(2);
positionCell.CellStyle = style;
positionCell.SetCellValue(string.Join(" , ", position.Select(p => p.PositionName)));
j++;
}
selectedRow += count + 1;
}
sheet.SetColumnWidth(1, 25600);
sheet.SetColumnWidth(2, 7000);
await CreateSheetForWeek(tasks, 6, workbook);
for (int i = 0; i < 6; i++)
{
await CreateSheetForWeek(tasks, i, workbook);
}
var stream = new MemoryStream();
workbook.Write(stream);
var content = stream.ToArray();
return content;
}
async Task CreateSheetForWeek(List<TaskLDto> tasks, int day, XSSFWorkbook workbook)
{
var dayOfWeek = (DayOfWeek)day;
var sheet = workbook.CreateSheet(dayOfWeek.GetPersianDayOfWeek());
int selectedRow = 1;
CreateHeader(sheet, workbook);
sheet.IsRightToLeft = true;
var dayTasks = tasks.Where(t => t.Days.Any(d => d.DayOfWeek == (DayOfWeek)day)).ToList();
var shiftsTask = dayTasks.SelectMany(dt => dt.Shifts).ToList();
foreach (var taskShiftGrouped in shiftsTask.GroupBy(t => t.ShiftId))
{
var count = taskShiftGrouped.ToList().Count - 1;
var shiftName = taskShiftGrouped.FirstOrDefault()?.ShiftName ?? string.Empty;
CreateShiftName(selectedRow, selectedRow + count, shiftName, sheet, workbook);
int j = selectedRow;
foreach (var taskShiftSDto in taskShiftGrouped)
{
var row = sheet.GetRow(j) ?? sheet.CreateRow(j);
row.Height = 700;
var style = workbook.CreateCellStyle();
style.VerticalAlignment = VerticalAlignment.Center;
style.Alignment = HorizontalAlignment.Center;
style.WrapText = true;
var cell = row.CreateCell(1);
cell.CellStyle = style;
cell.SetCellValue(taskShiftSDto.TaskTitle);
var position = await _repositoryWrapper.SetRepository<TaskPosition>()
.TableNoTracking
.Where(t => t.TaskId == taskShiftSDto.TaskId)
.Select(TaskPositionMapper.ProjectToSDto)
.ToListAsync();
var positionCell = row.CreateCell(2);
positionCell.CellStyle = style;
positionCell.SetCellValue(string.Join(" , ", position.Select(p => p.PositionName)));
j++;
}
selectedRow = (selectedRow) + count + 1;
}
sheet.SetColumnWidth(1, 25600);
sheet.SetColumnWidth(2, 7000);
}
void CreateHeader(ISheet sheet, XSSFWorkbook workbook)
{
var headerRow = sheet.GetRow(0) ?? sheet.CreateRow(0);
headerRow.Height = 700;
var font = workbook.CreateFont();
font.IsBold = true;
font.Color = NPOI.HSSF.Util.HSSFColor.White.Index;
//font.FontHeight = 16;
var style = workbook.CreateCellStyle();
style.Alignment = HorizontalAlignment.Center;
style.VerticalAlignment = VerticalAlignment.Center;
style.WrapText = true;
style.SetFont(font);
byte[] rgb = new byte[3] { 30, 81, 123 };
XSSFColor color = new XSSFColor(rgb);
//style.SetFillBackgroundColor(color);
//style.SetFillForegroundColor(color);
style.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.BlueGrey.Index;
style.FillPattern = FillPattern.SolidForeground;
var shiftNameHeaderCell = headerRow.CreateCell(0);
shiftNameHeaderCell.CellStyle = style;
shiftNameHeaderCell.SetCellValue("شیفتــ");
var taskNameHeaderCell = headerRow.CreateCell(1);
taskNameHeaderCell.CellStyle = style;
taskNameHeaderCell.SetCellValue("تسکــــ");
var positionNameHeaderCell = headerRow.CreateCell(2);
positionNameHeaderCell.CellStyle = style;
positionNameHeaderCell.SetCellValue("پوزیشن");
}
void CreateShiftName(int startRow, int lastRow, string name, ISheet sheet, XSSFWorkbook workbook)
{
var style = workbook.CreateCellStyle();
var font = workbook.CreateFont();
font.IsBold = true;
style.Alignment = HorizontalAlignment.Center;
style.VerticalAlignment = VerticalAlignment.Center;
style.WrapText = true;
style.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Gold.Index;
style.FillPattern = FillPattern.SolidForeground;
style.SetFont(font);
if (lastRow > startRow)
{
sheet.AddMergedRegion(new CellRangeAddress(startRow, lastRow, 0, 0));
var rowHeader = sheet.CreateRow(startRow);
style.Rotation = 90;
var cell = rowHeader.CreateCell(0);
cell.SetCellValue(name);
cell.CellStyle = style;
}
else
{
var rowHeader = sheet.CreateRow(startRow);
var cell = rowHeader.CreateCell(0);
cell.SetCellValue(name);
cell.CellStyle = style;
}
}
}

View File

@ -36,6 +36,23 @@ public class ComplexService : IComplexService
foreach (var claim in ApplicationClaims.ManagerClaims)
await _roleManager.AddClaimAsync(managerRole, claim);
var viewOwnerRole = new ApplicationRole
{
ComplexId = complex.Id,
EnglishName = "ViewerOwner",
PersianName = "ناظر",
Description = "ناظر مجموعه",
Name = $"ViewerOwner_{complex.Id.ToString()}"
};
var createViewerResult = await _roleManager.CreateAsync(viewOwnerRole);
if (!createViewerResult.Succeeded)
throw new AppException(string.Join('|', createViewerResult.Errors));
foreach (var claim in ApplicationClaims.ManagerClaims)
await _roleManager.AddClaimAsync(viewOwnerRole, claim);
var superVisorRole = new ApplicationRole
{
ComplexId = complex.Id,

View File

@ -11,7 +11,7 @@
<PackageReference Include="Mapster" Version="7.4.0" />
<PackageReference Include="Mapster.Core" Version="1.2.1" />
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.2" />
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
</ItemGroup>-->

View File

@ -1,9 +1,9 @@
namespace Brizco.Domain.CommandQueries.Commands;
public record CreateShiftPlanCommand(long PlanDate,Guid ShiftId,Guid RoutineId, List<KeyValuePair<Guid,Guid>> UserAndPositionIds)
public record CreateShiftPlanCommand(long PlanDate,Guid ShiftId,Guid RoutineId,Guid SupervisionUserId, List<KeyValuePair<Guid,Guid>> UserAndPositionIds)
:IRequest<ShiftPlanLDto>;
public record UpdateShiftPlanCommand(Guid Id,long PlanDate, Guid ShiftId, Guid RoutineId, List<KeyValuePair<Guid, Guid>> UserAndPositionIds)
public record UpdateShiftPlanCommand(Guid Id,long PlanDate, Guid ShiftId, Guid RoutineId, Guid SupervisionUserId, List<KeyValuePair<Guid, Guid>> UserAndPositionIds)
: IRequest<bool>;
public record DeleteShiftPlanCommand(Guid Id)

View File

@ -6,9 +6,11 @@ public class ShiftPlanLDto : BaseDto<ShiftPlanLDto , ShiftPlan>
{
public DateTime PlanFor { get; set; }
public Guid RoutineId { get; set; }
public bool IsCompleted { get; internal set; }
public int CompletePercent { get; internal set; }
public string CompleteDescription { get; internal set; } = string.Empty;
public bool IsCompleted { get; set; }
public int CompletePercent { get; set; }
public string CompleteDescription { get; set; } = string.Empty;
public Guid ShiftId { get; set; }
public List<ShiftPlanUserSDto> Users { get; set; } = new();
public Guid SupervisorId { get; set; }
public string SupervisorFullName { get; set; } = string.Empty;
}

View File

@ -5,5 +5,6 @@ namespace Brizco.Domain.Dtos.SmallDtos;
public class TaskPositionSDto : BaseDto<TaskPositionSDto , TaskPosition>
{
public Guid PositionId { get; set; }
public string PositionName { get; set; } = string.Empty;
public Guid TaskId { get; set; }
}

View File

@ -1,7 +1,9 @@
namespace Brizco.Domain.Dtos.SmallDtos;
public class TaskShiftSDto
public class TaskShiftSDto : BaseDto<TaskShiftSDto,TaskShift>
{
public Guid ShiftId { get; set; }
public string ShiftName { get; set; } = string.Empty;
public Guid TaskId { get; set; }
public string TaskTitle { get; set; } = string.Empty;
}

View File

@ -14,9 +14,9 @@ public partial class Shift
this.Days.Add(shiftDay);
return shiftDay;
}
public ShiftPlan AddPlan(DateTime planDate,Guid routineId)
public ShiftPlan AddPlan(DateTime planDate,Guid routineId , Guid superVisorId)
{
var plan = new ShiftPlan(planDate , routineId, Id ,this.ComplexId);
var plan = new ShiftPlan(planDate , routineId, Id, superVisorId, this.ComplexId);
Plans.Add(plan);
return plan;
}

View File

@ -1,4 +1,6 @@
namespace Brizco.Domain.Entities.Shift;
using Brizco.Domain.Entities.User;
namespace Brizco.Domain.Entities.Shift;
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)]
@ -11,11 +13,12 @@ public partial class ShiftPlan : ApiEntity
}
internal ShiftPlan(DateTime planFor, Guid routineId,Guid shiftId, Guid complexId)
internal ShiftPlan(DateTime planFor, Guid routineId,Guid shiftId,Guid supervisionId, Guid complexId)
{
PlanFor = planFor;
RoutineId = routineId;
ShiftId = shiftId;
SupervisorId = supervisionId;
ComplexId = complexId;
}
public DateTime PlanFor { get; internal set; }
@ -33,5 +36,8 @@ public partial class ShiftPlan : ApiEntity
public Guid ComplexId { get; internal set; }
public Complex.Complex? Complex { get; internal set; }
public Guid SupervisorId { get; internal set; }
public ApplicationUser? Supervisor { get; internal set; }
public List<ShiftPlanUser> Users { get; internal set; } = new();
}

View File

@ -4,7 +4,10 @@ using System.Linq;
using System.Linq.Expressions;
using Brizco.Domain.Dtos.LargDtos;
using Brizco.Domain.Dtos.SmallDtos;
using Brizco.Domain.Entities.Routine;
using Brizco.Domain.Entities.Shift;
using Brizco.Domain.Entities.User;
using Mapster.Models;
namespace Brizco.Domain.Mappers
{
@ -98,7 +101,11 @@ namespace Brizco.Domain.Mappers
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),
Id = p9.Id
};
@ -116,61 +123,71 @@ namespace Brizco.Domain.Mappers
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.Users = funcMain2(p11.Users, result.Users);
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.Id = p11.Id;
return result;
}
public static ShiftPlanLDto AdaptToLDto(this ShiftPlan p15)
public static ShiftPlanLDto AdaptToLDto(this ShiftPlan p21)
{
return p15 == null ? null : new ShiftPlanLDto()
return p21 == null ? null : new ShiftPlanLDto()
{
PlanFor = p15.PlanFor,
RoutineId = p15.RoutineId,
IsCompleted = p15.IsCompleted,
CompletePercent = p15.CompletePercent,
CompleteDescription = p15.CompleteDescription,
ShiftId = p15.ShiftId,
Users = funcMain3(p15.Users),
Id = p15.Id
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
};
}
public static ShiftPlanLDto AdaptTo(this ShiftPlan p17, ShiftPlanLDto p18)
public static ShiftPlanLDto AdaptTo(this ShiftPlan p23, ShiftPlanLDto p24)
{
if (p17 == null)
if (p23 == null)
{
return null;
}
ShiftPlanLDto result = p18 ?? new ShiftPlanLDto();
ShiftPlanLDto result = p24 ?? new ShiftPlanLDto();
result.PlanFor = p17.PlanFor;
result.RoutineId = p17.RoutineId;
result.IsCompleted = p17.IsCompleted;
result.CompletePercent = p17.CompletePercent;
result.CompleteDescription = p17.CompleteDescription;
result.ShiftId = p17.ShiftId;
result.Users = funcMain4(p17.Users, result.Users);
result.Id = p17.Id;
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;
return result;
}
public static Expression<Func<ShiftPlan, ShiftPlanLDto>> ProjectToLDto => p21 => new ShiftPlanLDto()
public static Expression<Func<ShiftPlan, ShiftPlanLDto>> ProjectToLDto => p27 => new ShiftPlanLDto()
{
PlanFor = p21.PlanFor,
RoutineId = p21.RoutineId,
IsCompleted = p21.IsCompleted,
CompletePercent = p21.CompletePercent,
CompleteDescription = p21.CompleteDescription,
ShiftId = p21.ShiftId,
Users = p21.Users.Select<ShiftPlanUser, ShiftPlanUserSDto>(p22 => new ShiftPlanUserSDto()
PlanFor = p27.PlanFor,
RoutineId = p27.RoutineId,
IsCompleted = p27.IsCompleted,
CompletePercent = p27.CompletePercent,
CompleteDescription = p27.CompleteDescription,
ShiftId = p27.ShiftId,
Users = p27.Users.Select<ShiftPlanUser, ShiftPlanUserSDto>(p28 => new ShiftPlanUserSDto()
{
ShiftPlanId = p22.ShiftPlanId,
UserId = p22.UserId,
PositionId = p22.PositionId,
Id = p22.Id
ShiftPlanId = p28.ShiftPlanId,
UserId = p28.UserId,
PositionId = p28.PositionId,
Id = p28.Id
}).ToList<ShiftPlanUserSDto>(),
Id = p21.Id
SupervisorId = p27.SupervisorId,
SupervisorFullName = p27.Supervisor != null ? p27.Supervisor.FirstName + " " + p27.Supervisor.LastName : string.Empty,
Id = p27.Id
};
private static List<ShiftPlanUser> funcMain1(List<ShiftPlanUserSDto> p10)
@ -200,20 +217,47 @@ namespace Brizco.Domain.Mappers
}
private static List<ShiftPlanUser> funcMain2(List<ShiftPlanUserSDto> p13, List<ShiftPlanUser> p14)
private static Shift funcMain2(Never p13, Shift p14, ShiftPlanLDto p11)
{
if (p13 == null)
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<ShiftPlanUser> funcMain5(List<ShiftPlanUserSDto> p19, List<ShiftPlanUser> p20)
{
if (p19 == null)
{
return null;
}
List<ShiftPlanUser> result = new List<ShiftPlanUser>(p13.Count);
List<ShiftPlanUser> result = new List<ShiftPlanUser>(p19.Count);
int i = 0;
int len = p13.Count;
int len = p19.Count;
while (i < len)
{
ShiftPlanUserSDto item = p13[i];
ShiftPlanUserSDto item = p19[i];
result.Add(item == null ? null : new ShiftPlanUser()
{
ShiftPlanId = item.ShiftPlanId,
@ -227,20 +271,20 @@ namespace Brizco.Domain.Mappers
}
private static List<ShiftPlanUserSDto> funcMain3(List<ShiftPlanUser> p16)
private static List<ShiftPlanUserSDto> funcMain6(List<ShiftPlanUser> p22)
{
if (p16 == null)
if (p22 == null)
{
return null;
}
List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p16.Count);
List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p22.Count);
int i = 0;
int len = p16.Count;
int len = p22.Count;
while (i < len)
{
ShiftPlanUser item = p16[i];
ShiftPlanUser item = p22[i];
result.Add(item == null ? null : new ShiftPlanUserSDto()
{
ShiftPlanId = item.ShiftPlanId,
@ -254,20 +298,20 @@ namespace Brizco.Domain.Mappers
}
private static List<ShiftPlanUserSDto> funcMain4(List<ShiftPlanUser> p19, List<ShiftPlanUserSDto> p20)
private static List<ShiftPlanUserSDto> funcMain7(List<ShiftPlanUser> p25, List<ShiftPlanUserSDto> p26)
{
if (p19 == null)
if (p25 == null)
{
return null;
}
List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p19.Count);
List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p25.Count);
int i = 0;
int len = p19.Count;
int len = p25.Count;
while (i < len)
{
ShiftPlanUser item = p19[i];
ShiftPlanUser item = p25[i];
result.Add(item == null ? null : new ShiftPlanUserSDto()
{
ShiftPlanId = item.ShiftPlanId,

View File

@ -6,6 +6,7 @@ using Brizco.Common.Extensions;
using Brizco.Domain.Dtos.LargDtos;
using Brizco.Domain.Dtos.SmallDtos;
using Brizco.Domain.Entities.Complex;
using Brizco.Domain.Entities.Shift;
using Brizco.Domain.Entities.Task;
using Mapster.Models;
using Task = Brizco.Domain.Entities.Task.Task;
@ -245,11 +246,15 @@ namespace Brizco.Domain.Mappers
Shifts = p62.Shifts.Select<TaskShift, TaskShiftSDto>(p63 => new TaskShiftSDto()
{
ShiftId = p63.ShiftId,
TaskId = p63.TaskId
ShiftName = p63.Shift != null ? p63.Shift.Title : string.Empty,
TaskId = p63.TaskId,
TaskTitle = p63.Task != null ? p63.Task.Title : string.Empty,
Id = p63.Id
}).ToList<TaskShiftSDto>(),
Positions = p62.Positions.Select<TaskPosition, TaskPositionSDto>(p64 => new TaskPositionSDto()
{
PositionId = p64.PositionId,
PositionName = p64.Position != null ? p64.Position.Name : string.Empty,
TaskId = p64.TaskId,
Id = p64.Id
}).ToList<TaskPositionSDto>(),
@ -549,7 +554,14 @@ namespace Brizco.Domain.Mappers
result.Add(item == null ? null : new TaskShift()
{
TaskId = item.TaskId,
ShiftId = item.ShiftId
Task = new Task()
{
Title = item.TaskTitle,
Id = item.TaskId
},
ShiftId = item.ShiftId,
Shift = new Shift() {Id = item.ShiftId},
Id = item.Id
});
i++;
}
@ -626,7 +638,13 @@ namespace Brizco.Domain.Mappers
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++;
@ -652,7 +670,14 @@ namespace Brizco.Domain.Mappers
result.Add(item == null ? null : new TaskShift()
{
TaskId = item.TaskId,
ShiftId = item.ShiftId
Task = new Task()
{
Title = item.TaskTitle,
Id = item.TaskId
},
ShiftId = item.ShiftId,
Shift = new Shift() {Id = item.ShiftId},
Id = item.Id
});
i++;
}
@ -729,7 +754,13 @@ namespace Brizco.Domain.Mappers
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++;
@ -755,7 +786,10 @@ namespace Brizco.Domain.Mappers
result.Add(item == null ? null : new TaskShiftSDto()
{
ShiftId = item.ShiftId,
TaskId = item.TaskId
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++;
}
@ -780,6 +814,7 @@ namespace Brizco.Domain.Mappers
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
});
@ -858,7 +893,10 @@ namespace Brizco.Domain.Mappers
result.Add(item == null ? null : new TaskShiftSDto()
{
ShiftId = item.ShiftId,
TaskId = item.TaskId
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++;
}
@ -883,6 +921,7 @@ namespace Brizco.Domain.Mappers
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
});

View File

@ -1,7 +1,10 @@
using System;
using System.Linq.Expressions;
using Brizco.Domain.Dtos.SmallDtos;
using Brizco.Domain.Entities.Complex;
using Brizco.Domain.Entities.Task;
using Mapster.Models;
using Task = Brizco.Domain.Entities.Task.Task;
namespace Brizco.Domain.Mappers
{
@ -12,7 +15,13 @@ namespace Brizco.Domain.Mappers
return p1 == null ? null : new TaskPosition()
{
PositionId = p1.PositionId,
Position = new Position()
{
Name = p1.PositionName,
Id = p1.PositionId
},
TaskId = p1.TaskId,
Task = new Task() {Id = p1.TaskId},
Id = p1.Id
};
}
@ -25,45 +34,75 @@ namespace Brizco.Domain.Mappers
TaskPosition result = p3 ?? new TaskPosition();
result.PositionId = p2.PositionId;
result.Position = funcMain1(new Never(), result.Position, p2);
result.TaskId = p2.TaskId;
result.Task = funcMain2(new Never(), result.Task, p2);
result.Id = p2.Id;
return result;
}
public static Expression<Func<TaskPositionSDto, TaskPosition>> ProjectToTaskPosition => p4 => new TaskPosition()
public static Expression<Func<TaskPositionSDto, TaskPosition>> ProjectToTaskPosition => p8 => new TaskPosition()
{
PositionId = p4.PositionId,
TaskId = p4.TaskId,
Id = p4.Id
};
public static TaskPositionSDto AdaptToSDto(this TaskPosition p5)
{
return p5 == null ? null : new TaskPositionSDto()
PositionId = p8.PositionId,
Position = new Position()
{
PositionId = p5.PositionId,
TaskId = p5.TaskId,
Id = p5.Id
Name = p8.PositionName,
Id = p8.PositionId
},
TaskId = p8.TaskId,
Task = new Task() {Id = p8.TaskId},
Id = p8.Id
};
public static TaskPositionSDto AdaptToSDto(this TaskPosition p9)
{
return p9 == null ? null : new TaskPositionSDto()
{
PositionId = p9.PositionId,
PositionName = p9.Position != null ? p9.Position.Name : string.Empty,
TaskId = p9.TaskId,
Id = p9.Id
};
}
public static TaskPositionSDto AdaptTo(this TaskPosition p6, TaskPositionSDto p7)
public static TaskPositionSDto AdaptTo(this TaskPosition p10, TaskPositionSDto p11)
{
if (p6 == null)
if (p10 == null)
{
return null;
}
TaskPositionSDto result = p7 ?? new TaskPositionSDto();
TaskPositionSDto result = p11 ?? new TaskPositionSDto();
result.PositionId = p6.PositionId;
result.TaskId = p6.TaskId;
result.Id = p6.Id;
result.PositionId = p10.PositionId;
result.PositionName = p10.Position != null ? p10.Position.Name : string.Empty;
result.TaskId = p10.TaskId;
result.Id = p10.Id;
return result;
}
public static Expression<Func<TaskPosition, TaskPositionSDto>> ProjectToSDto => p8 => new TaskPositionSDto()
public static Expression<Func<TaskPosition, TaskPositionSDto>> ProjectToSDto => p12 => new TaskPositionSDto()
{
PositionId = p8.PositionId,
TaskId = p8.TaskId,
Id = p8.Id
PositionId = p12.PositionId,
PositionName = p12.Position != null ? p12.Position.Name : string.Empty,
TaskId = p12.TaskId,
Id = p12.Id
};
private static Position funcMain1(Never p4, Position p5, TaskPositionSDto p2)
{
Position result = p5 ?? new Position();
result.Name = p2.PositionName;
result.Id = p2.PositionId;
return result;
}
private static Task funcMain2(Never p6, Task p7, TaskPositionSDto p2)
{
Task result = p7 ?? new Task();
result.Id = p2.TaskId;
return result;
}
}
}

View File

@ -1,7 +1,10 @@
using System;
using System.Linq.Expressions;
using Brizco.Domain.Dtos.SmallDtos;
using Brizco.Domain.Entities.Shift;
using Brizco.Domain.Entities.Task;
using Mapster.Models;
using Task = Brizco.Domain.Entities.Task.Task;
namespace Brizco.Domain.Mappers
{
@ -12,7 +15,14 @@ namespace Brizco.Domain.Mappers
return p1 == null ? null : new TaskShift()
{
TaskId = p1.TaskId,
ShiftId = p1.ShiftId
Task = new Task()
{
Title = p1.TaskTitle,
Id = p1.TaskId
},
ShiftId = p1.ShiftId,
Shift = new Shift() {Id = p1.ShiftId},
Id = p1.Id
};
}
public static TaskShift AdaptTo(this TaskShiftSDto p2, TaskShift p3)
@ -24,40 +34,78 @@ namespace Brizco.Domain.Mappers
TaskShift result = p3 ?? new TaskShift();
result.TaskId = p2.TaskId;
result.Task = funcMain1(new Never(), result.Task, p2);
result.ShiftId = p2.ShiftId;
result.Shift = funcMain2(new Never(), result.Shift, p2);
result.Id = p2.Id;
return result;
}
public static Expression<Func<TaskShiftSDto, TaskShift>> ProjectToTaskShift => p4 => new TaskShift()
public static Expression<Func<TaskShiftSDto, TaskShift>> ProjectToTaskShift => p8 => new TaskShift()
{
TaskId = p4.TaskId,
ShiftId = p4.ShiftId
};
public static TaskShiftSDto AdaptToSDto(this TaskShift p5)
{
return p5 == null ? null : new TaskShiftSDto()
TaskId = p8.TaskId,
Task = new Task()
{
ShiftId = p5.ShiftId,
TaskId = p5.TaskId
Title = p8.TaskTitle,
Id = p8.TaskId
},
ShiftId = p8.ShiftId,
Shift = new Shift() {Id = p8.ShiftId},
Id = p8.Id
};
public static TaskShiftSDto AdaptToSDto(this TaskShift p9)
{
return p9 == null ? null : new TaskShiftSDto()
{
ShiftId = p9.ShiftId,
ShiftName = p9.Shift != null ? p9.Shift.Title : string.Empty,
TaskId = p9.TaskId,
TaskTitle = p9.Task != null ? p9.Task.Title : string.Empty,
Id = p9.Id
};
}
public static TaskShiftSDto AdaptTo(this TaskShift p6, TaskShiftSDto p7)
public static TaskShiftSDto AdaptTo(this TaskShift p10, TaskShiftSDto p11)
{
if (p6 == null)
if (p10 == null)
{
return null;
}
TaskShiftSDto result = p7 ?? new TaskShiftSDto();
TaskShiftSDto result = p11 ?? new TaskShiftSDto();
result.ShiftId = p6.ShiftId;
result.TaskId = p6.TaskId;
result.ShiftId = p10.ShiftId;
result.ShiftName = p10.Shift != null ? p10.Shift.Title : string.Empty;
result.TaskId = p10.TaskId;
result.TaskTitle = p10.Task != null ? p10.Task.Title : string.Empty;
result.Id = p10.Id;
return result;
}
public static Expression<Func<TaskShift, TaskShiftSDto>> ProjectToSDto => p8 => new TaskShiftSDto()
public static Expression<Func<TaskShift, TaskShiftSDto>> ProjectToSDto => p12 => new TaskShiftSDto()
{
ShiftId = p8.ShiftId,
TaskId = p8.TaskId
ShiftId = p12.ShiftId,
ShiftName = p12.Shift != null ? p12.Shift.Title : string.Empty,
TaskId = p12.TaskId,
TaskTitle = p12.Task != null ? p12.Task.Title : string.Empty,
Id = p12.Id
};
private static Task funcMain1(Never p4, Task p5, TaskShiftSDto p2)
{
Task result = p5 ?? new Task();
result.Title = p2.TaskTitle;
result.Id = p2.TaskId;
return result;
}
private static Shift funcMain2(Never p6, Shift p7, TaskShiftSDto p2)
{
Shift result = p7 ?? new Shift();
result.Id = p2.ShiftId;
return result;
}
}
}

View File

@ -13,6 +13,15 @@ public class MapsterRegister : IRegister
.Map("Positions", o => o.Positions.Select(d => d.Position != null ? d.Position.Name : string.Empty))
.TwoWays();
config.NewConfig<TaskShift, TaskShiftSDto>()
.Map("ShiftName", o => o.Shift != null ? o.Shift.Title : string.Empty)
.Map("TaskTitle", o => o.Task != null ? o.Task.Title : string.Empty)
.TwoWays();
config.NewConfig<TaskPosition, TaskPositionSDto>()
.Map("PositionName", o => o.Position != null ? o.Position.Name : string.Empty)
.TwoWays();
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)
@ -31,6 +40,10 @@ public class MapsterRegister : IRegister
.Map("Days", o => o.Days.Select(d => d.DayOfWeek).ToList())
.TwoWays();
config.NewConfig<ShiftPlan, ShiftPlanLDto>()
.Map("SupervisorFullName", o => o.Supervisor != null ? o.Supervisor.FirstName + " " + o.Supervisor.LastName : string.Empty)
.TwoWays();
config.NewConfig<ComplexUserRole, ComplexUserRoleSDto>()
.Map("RoleName", org => org.Role!.PersianName)
.TwoWays();

View File

@ -8,22 +8,22 @@
<ItemGroup>
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="FluentValidation" Version="11.8.1" />
<PackageReference Include="FluentValidation" Version="11.9.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Pluralize.NET" Version="1.0.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="StackExchange.Redis" Version="2.7.4" />
<PackageReference Include="StackExchange.Redis.Extensions.Core" Version="9.1.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.2" />
<PackageReference Include="StackExchange.Redis" Version="2.7.17" />
<PackageReference Include="StackExchange.Redis.Extensions.Core" Version="10.2.0" />
</ItemGroup>
<ItemGroup>

View File

@ -79,7 +79,10 @@ public static class ModelBuilderExtensions
.SelectMany(t => t.GetForeignKeys())
.Where(fk => !fk.IsOwnership && fk.DeleteBehavior == DeleteBehavior.Cascade);
foreach (var fk in cascadeFKs)
{
fk.DeleteBehavior = DeleteBehavior.Restrict;
fk.IsRequired = false;
}
}
/// <summary>

View File

@ -29,7 +29,7 @@ public class CreateShiftPlanCommandHandler : IRequestHandler<CreateShiftPlanComm
try
{
await _repositoryWrapper.BeginTransaction(cancellationToken);
var shiftPlan = shift.AddPlan(planFor , request.RoutineId);
var shiftPlan = shift.AddPlan(planFor, request.RoutineId, request.SupervisionUserId);
if (request.UserAndPositionIds.Count == 0)
throw new AppException("شیفت بندی مورد نظر باید حداقل متشکل از یک فرد باشد", ApiResultStatusCode.BadRequest);

View File

@ -24,7 +24,7 @@ public class UpdateShiftPlanCommandHandler : IRequestHandler<UpdateShiftPlanComm
throw new AppException("Shift not found", ApiResultStatusCode.NotFound);
var newPlan = shift.AddPlan(DateTimeExtensions.UnixTimeStampToDateTime(request.PlanDate), request.RoutineId);
var newPlan = shift.AddPlan(DateTimeExtensions.UnixTimeStampToDateTime(request.PlanDate), request.RoutineId,request.SupervisionUserId);
newPlan.Id = request.Id;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Brizco.Repository.Migrations
{
/// <inheritdoc />
public partial class EditShiftPlanAddSuperVisiorB : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Brizco.Repository.Migrations
{
/// <inheritdoc />
public partial class EditForeignKey : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -37,7 +37,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
@ -47,7 +46,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
@ -58,7 +56,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("SupportPhone")
@ -83,7 +80,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
@ -93,14 +89,12 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("UserId")
@ -128,7 +122,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
@ -138,14 +131,12 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("RoleId")
@ -173,7 +164,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
@ -187,7 +177,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
@ -198,7 +187,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("SectionId")
@ -226,7 +214,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
@ -240,7 +227,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
@ -251,7 +237,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
@ -274,7 +259,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
@ -288,7 +272,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
@ -299,7 +282,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
@ -322,7 +304,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
@ -339,14 +320,12 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<TimeSpan>("StartAt")
@ -373,7 +352,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("DayOfWeek")
@ -386,14 +364,12 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ShiftId")
@ -426,7 +402,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsCompleted")
@ -439,7 +414,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("PlanFor")
@ -449,7 +423,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("RoutineId")
@ -458,6 +431,9 @@ namespace Brizco.Repository.Migrations
b.Property<Guid>("ShiftId")
.HasColumnType("uuid");
b.Property<Guid>("SupervisorId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ComplexId");
@ -466,6 +442,8 @@ namespace Brizco.Repository.Migrations
b.HasIndex("ShiftId");
b.HasIndex("SupervisorId");
b.ToTable("ShiftPlans", "public");
});
@ -479,7 +457,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
@ -489,7 +466,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("PositionId")
@ -499,7 +475,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ShiftPlanId")
@ -529,7 +504,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
@ -539,14 +513,12 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("RoutineId")
@ -583,7 +555,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
@ -611,14 +582,12 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("ScheduleType")
@ -655,7 +624,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("DayOfWeek")
@ -668,14 +636,12 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("TaskId")
@ -698,7 +664,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
@ -708,7 +673,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("PositionId")
@ -718,7 +682,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("TaskId")
@ -743,7 +706,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
@ -753,14 +715,12 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("RoutineId")
@ -788,7 +748,6 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
@ -798,14 +757,12 @@ namespace Brizco.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ShiftId")
@ -1098,14 +1055,12 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex")
.WithMany("Users")
.HasForeignKey("ComplexId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Complex");
@ -1117,14 +1072,12 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.Complex.ComplexUser", "ComplexUser")
.WithMany("Roles")
.HasForeignKey("ComplexUserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", "Role")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("ComplexUser");
@ -1136,14 +1089,12 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex")
.WithMany()
.HasForeignKey("ComplexId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Complex.Section", "Section")
.WithMany("Positions")
.HasForeignKey("SectionId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Complex");
@ -1155,8 +1106,7 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex")
.WithMany()
.HasForeignKey("ComplexId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Complex");
});
@ -1166,8 +1116,7 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex")
.WithMany()
.HasForeignKey("ComplexId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Complex");
});
@ -1177,8 +1126,7 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex")
.WithMany("Shifts")
.HasForeignKey("ComplexId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Complex");
});
@ -1188,8 +1136,7 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift")
.WithMany("Days")
.HasForeignKey("ShiftId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Shift");
});
@ -1199,26 +1146,30 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex")
.WithMany()
.HasForeignKey("ComplexId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine")
.WithMany()
.HasForeignKey("RoutineId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift")
.WithMany("Plans")
.HasForeignKey("ShiftId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "Supervisor")
.WithMany()
.HasForeignKey("SupervisorId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Complex");
b.Navigation("Routine");
b.Navigation("Shift");
b.Navigation("Supervisor");
});
modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", b =>
@ -1226,20 +1177,17 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position")
.WithMany()
.HasForeignKey("PositionId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Shift.ShiftPlan", "ShiftPlan")
.WithMany("Users")
.HasForeignKey("ShiftPlanId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Position");
@ -1253,14 +1201,12 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine")
.WithMany("Shifts")
.HasForeignKey("RoutineId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift")
.WithMany("Routines")
.HasForeignKey("ShiftId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Routine");
@ -1272,8 +1218,7 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex")
.WithMany("Tasks")
.HasForeignKey("ComplexId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Complex");
});
@ -1283,8 +1228,7 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.Task.Task", "Task")
.WithMany("Days")
.HasForeignKey("TaskId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Task");
});
@ -1294,14 +1238,12 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position")
.WithMany()
.HasForeignKey("PositionId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Task.Task", "Task")
.WithMany("Positions")
.HasForeignKey("TaskId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Position");
@ -1313,14 +1255,12 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine")
.WithMany("Tasks")
.HasForeignKey("RoutineId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Task.Task", "Task")
.WithMany("Routines")
.HasForeignKey("TaskId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Routine");
@ -1332,14 +1272,12 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift")
.WithMany()
.HasForeignKey("ShiftId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.Task.Task", "Task")
.WithMany("Shifts")
.HasForeignKey("TaskId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Shift");
@ -1360,8 +1298,7 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
@ -1369,8 +1306,7 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
@ -1378,8 +1314,7 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
@ -1387,14 +1322,12 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
@ -1402,8 +1335,7 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
});
modelBuilder.Entity("Brizco.Domain.Entities.Task.Activity", b =>
@ -1411,14 +1343,12 @@ namespace Brizco.Repository.Migrations
b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift")
.WithMany()
.HasForeignKey("ShiftId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Shift");