complete shifting and add version 0.1.0.3

master
Amir Hossein Khademi 2023-11-05 18:00:05 +03:30
parent f36d10f8fe
commit 9092109cd2
36 changed files with 1364 additions and 383 deletions

View File

@ -1 +1 @@
0.1.0.2 0.1.0.3

View File

@ -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.0.2</AssemblyVersion> <AssemblyVersion>0.1.0.3</AssemblyVersion>
<FileVersion>0.1.0.2</FileVersion> <FileVersion>0.1.0.3</FileVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -59,6 +59,7 @@
<Using Include="Brizco.Common.Models.Entity" /> <Using Include="Brizco.Common.Models.Entity" />
<Using Include="Brizco.Common.Models.Exception" /> <Using Include="Brizco.Common.Models.Exception" />
<Using Include="Brizco.Common.Models.Mapper" /> <Using Include="Brizco.Common.Models.Mapper" />
<Using Include="Brizco.Core.CoreServices.Abstracts" />
<Using Include="Brizco.Core.EntityServices.Abstracts" /> <Using Include="Brizco.Core.EntityServices.Abstracts" />
<Using Include="Brizco.Domain.CommandQueries.Commands" /> <Using Include="Brizco.Domain.CommandQueries.Commands" />
<Using Include="Brizco.Domain.CommandQueries.Queries" /> <Using Include="Brizco.Domain.CommandQueries.Queries" />

View File

@ -1,9 +1,4 @@
using Brizco.Common.Models.Api; namespace Brizco.Api.Controllers;
using Brizco.Core.BaseServices;
using Brizco.Core.CoreServices.Abstracts;
using Microsoft.AspNetCore.Authorization.Infrastructure;
namespace Brizco.Api.Controllers;
public class AuthController : ICarterModule public class AuthController : ICarterModule
{ {

View File

@ -0,0 +1,34 @@
using Brizco.Common.Models.Api;
using MD.PersianDateTime.Standard;
using System.Diagnostics;
namespace Brizco.Api.Controllers;
public class HealthController : ICarterModule
{
public void AddRoutes(IEndpointRouteBuilder app)
{
var group = app.NewVersionedApi("Health")
.MapGroup($"health");
group.MapGet("", GetHealth)
.WithDisplayName("CheckHealth")
.HasApiVersion(1.0);
}
public IResult GetHealth()
{
var version = typeof(Program)?.Assembly.GetName()?.Version?.ToString();
var check = new HealthCheck
{
Health = true,
Version = version ?? string.Empty,
StartAt = System.Diagnostics.Process.GetCurrentProcess().StartTime.ToString("F"),
StartAtPersian = new PersianDateTime(System.Diagnostics.Process.GetCurrentProcess().StartTime).ToLongDateTimeString(),
MachineName = Environment.MachineName
};
var process = Process.GetCurrentProcess();
check.TotalMemory = process.PrivateMemorySize64.ToString();
return TypedResults.Ok(check);
}
}

View File

@ -0,0 +1,50 @@
namespace Brizco.Api.Controllers;
public class ShiftPlanController : ICarterModule
{
public void AddRoutes(IEndpointRouteBuilder app)
{
var group = app.NewVersionedApi("ShiftPlan")
.MapGroup($"api/shift/plan")
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser());
group.MapGet("", GetAllAsync)
.WithDisplayName("GetShiftPlans")
.HasApiVersion(1.0);
group.MapGet("{id:guid}", GetAsync)
.WithDisplayName("GetShiftPlan")
.HasApiVersion(1.0);
group.MapPost("", Post)
.HasApiVersion(1.0);
group.MapPut("", Put)
.HasApiVersion(1.0);
group.MapDelete("{id:guid}", Delete)
.HasApiVersion(1.0);
}
// GET:Get All Entity
public async Task<IResult> GetAllAsync([FromQuery] int page, ISender sender, CancellationToken cancellationToken)
=> TypedResults.Ok(await sender.Send(new GetShiftPlansQuery(page), cancellationToken));
// GET:Get An Entity By Id
public async Task<IResult> GetAsync(Guid id, ISender sender, CancellationToken cancellationToken)
=> TypedResults.Ok(await sender.Send(new GetShiftPlanQuery(id)));
// POST:Create Entity
public async Task<IResult> Post([FromBody] CreateShiftPlanCommand ent, ISender mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(ent, cancellationToken));
// PUT:Update Entity
public async Task<IResult> Put([FromBody] UpdateShiftPlanCommand ent, ISender mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(ent, cancellationToken));
// DELETE:Delete Entity
public async Task<IResult> Delete(Guid id, ISender mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new DeleteShiftPlanCommand(id), cancellationToken));
}

View File

@ -3,7 +3,10 @@
public class HealthCheck public class HealthCheck
{ {
public bool Health { get; set; } public bool Health { get; set; }
public string Version { get; set; } public string Version { get; set; } = string.Empty;
public string TotalMemory { get; set; } public string TotalMemory { get; set; } = string.Empty;
public string StartAt { get; set; } = string.Empty;
public string StartAtPersian { get; set; } = string.Empty;
public string MachineName { get; set; } = string.Empty;
} }
} }

View File

@ -0,0 +1,6 @@
namespace Brizco.Core.EntityServices.Abstracts;
public interface IShiftPlanService
{
Task ChangeShiftPlanTaskStatusAsync(Guid shiftPlanId,bool isChangeToShift , bool isDisable);
}

View File

@ -0,0 +1,18 @@
using Brizco.Domain.CommandQueries.Queries;
namespace Brizco.Core.EntityServices;
public class ShiftPlanService : IShiftPlanService
{
private readonly ISender _sender;
public ShiftPlanService(ISender sender)
{
_sender = sender;
}
public async Task ChangeShiftPlanTaskStatusAsync(Guid shiftPlanId, bool isChangeToShift, bool isDisable)
{
var shiftPlan = await _sender.Send(new GetShiftPlanQuery(shiftPlanId));
}
}

View File

@ -7,7 +7,6 @@ public sealed record CreateActivityCommand(
TaskType Type, TaskType Type,
string Title, string Title,
string Description, string Description,
bool IsRelatedToShift,
bool IsRelatedToRole, bool IsRelatedToRole,
bool IsRelatedToPerson, bool IsRelatedToPerson,
bool IsDisposable, bool IsDisposable,
@ -26,7 +25,6 @@ public sealed record UpdateActivityCommand(Guid Id,
TaskType Type, TaskType Type,
string Title, string Title,
string Description, string Description,
bool IsRelatedToShift,
bool IsRelatedToRole, bool IsRelatedToRole,
bool IsRelatedToPerson, bool IsRelatedToPerson,
bool IsDisposable, bool IsDisposable,

View File

@ -2,10 +2,10 @@
namespace Brizco.Domain.CommandQueries.Commands; namespace Brizco.Domain.CommandQueries.Commands;
public sealed record CreateShiftCommand(string Title, TimeSpan StartAt, TimeSpan EndAt, string Description , List<DayOfWeek> DayOfWeeks) public sealed record CreateShiftCommand(string Title, TimeSpan StartAt, TimeSpan EndAt, string Description )
: IRequest<ShiftSDto>; : IRequest<ShiftSDto>;
public sealed record UpdateShiftCommand(Guid Id,string Title, TimeSpan StartAt, TimeSpan EndAt, string Description, List<DayOfWeek> DayOfWeeks) public sealed record UpdateShiftCommand(Guid Id,string Title, TimeSpan StartAt, TimeSpan EndAt, string Description)
: IRequest<bool>; : IRequest<bool>;
public sealed record DeleteShiftCommand(Guid Id) public sealed record DeleteShiftCommand(Guid Id)

View File

@ -1,10 +1,10 @@
namespace Brizco.Domain.CommandQueries.Commands; namespace Brizco.Domain.CommandQueries.Commands;
public record CreateShiftPlanCommand(DateTime StartAt, DateTime EndAt,Guid ShiftId,List<Guid> UserIds) public record CreateShiftPlanCommand(DateTime PlanDate,Guid ShiftId,List<Guid> UserIds)
:IRequest<ShiftPlanLDto>; :IRequest<ShiftPlanLDto>;
public record UpdateShiftPlanCommand(Guid Id,DateTime StartAt, DateTime EndAt, Guid ShiftId, List<Guid> UserIds) public record UpdateShiftPlanCommand(Guid Id,DateTime PlanDate, Guid ShiftId, List<Guid> UserIds)
: IRequest<bool>; : IRequest<bool>;
public record DeleteShiftPlanCommand(Guid Id, DateTime StartAt, DateTime EndAt, Guid ShiftId, List<Guid> UserIds) public record DeleteShiftPlanCommand(Guid Id)
: IRequest<bool>; : IRequest<bool>;

View File

@ -7,6 +7,5 @@ public class ShiftSDto : BaseDto<ShiftSDto,Shift>
public string Description { get; set; } = string.Empty; public string Description { get; set; } = string.Empty;
public TimeSpan StartAt { get; set; } public TimeSpan StartAt { get; set; }
public TimeSpan EndAt { get; set; } public TimeSpan EndAt { get; set; }
public List<DayOfWeek> Days { get; set; } = new();
public Guid ComplexId { get; set; } public Guid ComplexId { get; set; }
} }

View File

@ -8,16 +8,9 @@ public partial class Shift
return new Shift(title, description, startAt, endAt,complexId); return new Shift(title, description, startAt, endAt,complexId);
} }
public ShiftDay SetDay(DayOfWeek dayOfWeek) public ShiftPlan AddPlan(DateTime planDate)
{ {
var shiftDay = new ShiftDay(dayOfWeek , Id); var plan = new ShiftPlan(planDate , Id);
Days.Add(shiftDay);
return shiftDay;
}
public ShiftPlan AddPlan(DateTime startAt, DateTime endAt)
{
var plan = new ShiftPlan(startAt, endAt , Id);
Plans.Add(plan); Plans.Add(plan);
return plan; return plan;
} }

View File

@ -23,7 +23,5 @@ public partial class Shift : ApiEntity
public Guid ComplexId { get; set; } public Guid ComplexId { get; set; }
public Complex.Complex? Complex { get; set; } public Complex.Complex? Complex { get; set; }
public List<ShiftDay> Days { get; internal set; } = new();
public List<ShiftPlan> Plans { get; internal set; } = new(); public List<ShiftPlan> Plans { get; internal set; } = new();
} }

View File

@ -1,20 +0,0 @@
namespace Brizco.Domain.Entities.Shift;
public class ShiftDay : ApiEntity
{
public ShiftDay()
{
}
internal ShiftDay(DayOfWeek dayOfWeek,Guid shiftId)
{
DayOfWeek = dayOfWeek;
ShiftId = shiftId;
}
public DayOfWeek DayOfWeek { get; internal set; }
public Guid ShiftId { get; internal set; }
public Shift? Shift { get; internal set; }
}

View File

@ -10,13 +10,12 @@ public partial class ShiftPlan : ApiEntity
} }
internal ShiftPlan(DateTime startAt, DateTime endAt,Guid shiftId) internal ShiftPlan(DateTime planDate,Guid shiftId)
{ {
StartAt = startAt; PlanDate = planDate;
EndAt = endAt; ShiftId = shiftId;
} }
public DateTime StartAt { get; internal set; } public DateTime PlanDate { get; internal set; }
public DateTime EndAt { get; internal set; }
public Guid ShiftId { get; internal set; } public Guid ShiftId { get; internal set; }
public virtual Shift? Shift { get; internal set; } public virtual Shift? Shift { get; internal set; }

View File

@ -15,7 +15,6 @@ public partial class Activity : Task
DateTime doneAt, DateTime doneAt,
string performanceDescription, string performanceDescription,
TaskType type, TaskType type,
bool isRelatedToShift,
bool isRelatedToRole, bool isRelatedToRole,
bool isRelatedToPerson, bool isRelatedToPerson,
bool isDisposable, bool isDisposable,
@ -25,18 +24,8 @@ public partial class Activity : Task
PurchaseAmountType amountType, PurchaseAmountType amountType,
string title, string title,
string description, string description,
Guid complexId) : base(type, Guid complexId) : base(
isRelatedToShift, type,isRelatedToRole, isRelatedToPerson, isDisposable, setFor, hasDisposed, amount, amountType, title, description, complexId)
isRelatedToRole,
isRelatedToPerson,
isDisposable,
setFor,
hasDisposed,
amount,
amountType,
title,
description,
complexId)
{ {
Status = status; Status = status;
DoneAt = doneAt; DoneAt = doneAt;

View File

@ -19,7 +19,6 @@ public partial class Task
Guid complexId) Guid complexId)
{ {
return new Task(type, return new Task(type,
isRelatedToShift,
isRelatedToRole, isRelatedToRole,
isRelatedToPerson, isRelatedToPerson,
isDisposable, isDisposable,
@ -97,7 +96,6 @@ public partial class Activity
string title, string title,
string description, string description,
TaskType type, TaskType type,
bool isRelatedToShift,
bool isRelatedToRole, bool isRelatedToRole,
bool isRelatedToPerson, bool isRelatedToPerson,
bool isDisposable, bool isDisposable,
@ -112,7 +110,6 @@ public partial class Activity
doneAt, doneAt,
performanceDescription, performanceDescription,
type, type,
isRelatedToShift,
isRelatedToRole, isRelatedToRole,
isRelatedToPerson, isRelatedToPerson,
isDisposable, isDisposable,

View File

@ -12,7 +12,6 @@ public partial class Task : ApiEntity
} }
internal Task( internal Task(
TaskType type, TaskType type,
bool isRelatedToShift,
bool isRelatedToRole, bool isRelatedToRole,
bool isRelatedToPerson, bool isRelatedToPerson,
bool isDisposable, bool isDisposable,
@ -25,7 +24,6 @@ public partial class Task : ApiEntity
Guid complexId) Guid complexId)
{ {
Type = type; Type = type;
IsRelatedToShift = isRelatedToShift;
IsRelatedToRole = isRelatedToRole; IsRelatedToRole = isRelatedToRole;
IsRelatedToPerson = isRelatedToPerson; IsRelatedToPerson = isRelatedToPerson;
IsDisposable = isDisposable; IsDisposable = isDisposable;
@ -41,7 +39,6 @@ public partial class Task : ApiEntity
public TaskType Type { get; internal set; } public TaskType Type { get; internal set; }
public string Title { get; internal set; } = string.Empty; public string Title { get; internal set; } = string.Empty;
public string Description { get; internal set; } = string.Empty; public string Description { get; internal set; } = string.Empty;
public bool IsRelatedToShift { get; internal set; }
public bool IsRelatedToRole { get; internal set; } public bool IsRelatedToRole { get; internal set; }
public bool IsRelatedToPerson { get; internal set; } public bool IsRelatedToPerson { get; internal set; }
public bool IsDisposable { get; internal set; } public bool IsDisposable { get; internal set; }
@ -60,7 +57,7 @@ public partial class Task : ApiEntity
public List<TaskShift> Shifts { get; internal set; } = new(); public List<TaskShift> Shifts { get; internal set; } = new();
public List<TaskDay> Days { get; internal set; } public List<TaskDay> Days { get; internal set; } = new();
public List<TaskRole> Roles { get; internal set; } = new(); public List<TaskRole> Roles { get; internal set; } = new();
} }

View File

@ -19,7 +19,6 @@ namespace Brizco.Domain.Mappers
Type = p1.Type, Type = p1.Type,
Title = p1.Title, Title = p1.Title,
Description = p1.Description, Description = p1.Description,
IsRelatedToShift = p1.IsRelatedToShift,
IsRelatedToRole = p1.IsRelatedToRole, IsRelatedToRole = p1.IsRelatedToRole,
IsRelatedToPerson = p1.IsRelatedToPerson, IsRelatedToPerson = p1.IsRelatedToPerson,
IsDisposable = p1.IsDisposable, IsDisposable = p1.IsDisposable,
@ -45,7 +44,6 @@ namespace Brizco.Domain.Mappers
result.Type = p2.Type; result.Type = p2.Type;
result.Title = p2.Title; result.Title = p2.Title;
result.Description = p2.Description; result.Description = p2.Description;
result.IsRelatedToShift = p2.IsRelatedToShift;
result.IsRelatedToRole = p2.IsRelatedToRole; result.IsRelatedToRole = p2.IsRelatedToRole;
result.IsRelatedToPerson = p2.IsRelatedToPerson; result.IsRelatedToPerson = p2.IsRelatedToPerson;
result.IsDisposable = p2.IsDisposable; result.IsDisposable = p2.IsDisposable;
@ -66,7 +64,6 @@ namespace Brizco.Domain.Mappers
Type = p4.Type, Type = p4.Type,
Title = p4.Title, Title = p4.Title,
Description = p4.Description, Description = p4.Description,
IsRelatedToShift = p4.IsRelatedToShift,
IsRelatedToRole = p4.IsRelatedToRole, IsRelatedToRole = p4.IsRelatedToRole,
IsRelatedToPerson = p4.IsRelatedToPerson, IsRelatedToPerson = p4.IsRelatedToPerson,
IsDisposable = p4.IsDisposable, IsDisposable = p4.IsDisposable,
@ -83,7 +80,6 @@ namespace Brizco.Domain.Mappers
Type = p5.Type, Type = p5.Type,
Title = p5.Title, Title = p5.Title,
Description = p5.Description, Description = p5.Description,
IsRelatedToShift = p5.IsRelatedToShift,
IsRelatedToRole = p5.IsRelatedToRole, IsRelatedToRole = p5.IsRelatedToRole,
IsRelatedToPerson = p5.IsRelatedToPerson, IsRelatedToPerson = p5.IsRelatedToPerson,
IsDisposable = p5.IsDisposable, IsDisposable = p5.IsDisposable,
@ -109,7 +105,6 @@ namespace Brizco.Domain.Mappers
result.Type = p6.Type; result.Type = p6.Type;
result.Title = p6.Title; result.Title = p6.Title;
result.Description = p6.Description; result.Description = p6.Description;
result.IsRelatedToShift = p6.IsRelatedToShift;
result.IsRelatedToRole = p6.IsRelatedToRole; result.IsRelatedToRole = p6.IsRelatedToRole;
result.IsRelatedToPerson = p6.IsRelatedToPerson; result.IsRelatedToPerson = p6.IsRelatedToPerson;
result.IsDisposable = p6.IsDisposable; result.IsDisposable = p6.IsDisposable;
@ -130,7 +125,6 @@ namespace Brizco.Domain.Mappers
Type = p8.Type, Type = p8.Type,
Title = p8.Title, Title = p8.Title,
Description = p8.Description, Description = p8.Description,
IsRelatedToShift = p8.IsRelatedToShift,
IsRelatedToRole = p8.IsRelatedToRole, IsRelatedToRole = p8.IsRelatedToRole,
IsRelatedToPerson = p8.IsRelatedToPerson, IsRelatedToPerson = p8.IsRelatedToPerson,
IsDisposable = p8.IsDisposable, IsDisposable = p8.IsDisposable,
@ -155,7 +149,6 @@ namespace Brizco.Domain.Mappers
Type = p9.Type, Type = p9.Type,
Title = p9.Title, Title = p9.Title,
Description = p9.Description, Description = p9.Description,
IsRelatedToShift = p9.IsRelatedToShift,
IsRelatedToRole = p9.IsRelatedToRole, IsRelatedToRole = p9.IsRelatedToRole,
IsRelatedToPerson = p9.IsRelatedToPerson, IsRelatedToPerson = p9.IsRelatedToPerson,
IsDisposable = p9.IsDisposable, IsDisposable = p9.IsDisposable,
@ -181,7 +174,6 @@ namespace Brizco.Domain.Mappers
result.Type = p10.Type; result.Type = p10.Type;
result.Title = p10.Title; result.Title = p10.Title;
result.Description = p10.Description; result.Description = p10.Description;
result.IsRelatedToShift = p10.IsRelatedToShift;
result.IsRelatedToRole = p10.IsRelatedToRole; result.IsRelatedToRole = p10.IsRelatedToRole;
result.IsRelatedToPerson = p10.IsRelatedToPerson; result.IsRelatedToPerson = p10.IsRelatedToPerson;
result.IsDisposable = p10.IsDisposable; result.IsDisposable = p10.IsDisposable;
@ -202,7 +194,6 @@ namespace Brizco.Domain.Mappers
Type = p12.Type, Type = p12.Type,
Title = p12.Title, Title = p12.Title,
Description = p12.Description, Description = p12.Description,
IsRelatedToShift = p12.IsRelatedToShift,
IsRelatedToRole = p12.IsRelatedToRole, IsRelatedToRole = p12.IsRelatedToRole,
IsRelatedToPerson = p12.IsRelatedToPerson, IsRelatedToPerson = p12.IsRelatedToPerson,
IsDisposable = p12.IsDisposable, IsDisposable = p12.IsDisposable,
@ -219,7 +210,6 @@ namespace Brizco.Domain.Mappers
Type = p13.Type, Type = p13.Type,
Title = p13.Title, Title = p13.Title,
Description = p13.Description, Description = p13.Description,
IsRelatedToShift = p13.IsRelatedToShift,
IsRelatedToRole = p13.IsRelatedToRole, IsRelatedToRole = p13.IsRelatedToRole,
IsRelatedToPerson = p13.IsRelatedToPerson, IsRelatedToPerson = p13.IsRelatedToPerson,
IsDisposable = p13.IsDisposable, IsDisposable = p13.IsDisposable,
@ -245,7 +235,6 @@ namespace Brizco.Domain.Mappers
result.Type = p14.Type; result.Type = p14.Type;
result.Title = p14.Title; result.Title = p14.Title;
result.Description = p14.Description; result.Description = p14.Description;
result.IsRelatedToShift = p14.IsRelatedToShift;
result.IsRelatedToRole = p14.IsRelatedToRole; result.IsRelatedToRole = p14.IsRelatedToRole;
result.IsRelatedToPerson = p14.IsRelatedToPerson; result.IsRelatedToPerson = p14.IsRelatedToPerson;
result.IsDisposable = p14.IsDisposable; result.IsDisposable = p14.IsDisposable;
@ -266,7 +255,6 @@ namespace Brizco.Domain.Mappers
Type = p16.Type, Type = p16.Type,
Title = p16.Title, Title = p16.Title,
Description = p16.Description, Description = p16.Description,
IsRelatedToShift = p16.IsRelatedToShift,
IsRelatedToRole = p16.IsRelatedToRole, IsRelatedToRole = p16.IsRelatedToRole,
IsRelatedToPerson = p16.IsRelatedToPerson, IsRelatedToPerson = p16.IsRelatedToPerson,
IsDisposable = p16.IsDisposable, IsDisposable = p16.IsDisposable,

View File

@ -1,6 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using Brizco.Domain.Dtos.SmallDtos; using Brizco.Domain.Dtos.SmallDtos;
using Brizco.Domain.Entities.Complex; using Brizco.Domain.Entities.Complex;
@ -21,176 +19,81 @@ namespace Brizco.Domain.Mappers
Description = p1.Description, Description = p1.Description,
ComplexId = p1.ComplexId, ComplexId = p1.ComplexId,
Complex = new Complex() {Id = p1.ComplexId}, Complex = new Complex() {Id = p1.ComplexId},
Days = funcMain1(p1.Days),
Id = p1.Id Id = p1.Id
}; };
} }
public static Shift AdaptTo(this ShiftSDto p3, Shift p4) public static Shift AdaptTo(this ShiftSDto p2, Shift p3)
{
if (p3 == null)
{
return null;
}
Shift result = p4 ?? new Shift();
result.Title = p3.Title;
result.StartAt = p3.StartAt;
result.EndAt = p3.EndAt;
result.Description = p3.Description;
result.ComplexId = p3.ComplexId;
result.Complex = funcMain2(new Never(), result.Complex, p3);
result.Days = funcMain3(p3.Days, result.Days);
result.Id = p3.Id;
return result;
}
public static Expression<Func<ShiftSDto, Shift>> ProjectToShift => p9 => new Shift()
{
Title = p9.Title,
StartAt = p9.StartAt,
EndAt = p9.EndAt,
Description = p9.Description,
ComplexId = p9.ComplexId,
Complex = new Complex() {Id = p9.ComplexId},
Days = p9.Days.Select<DayOfWeek, ShiftDay>(p10 => new ShiftDay() {}).ToList<ShiftDay>(),
Id = p9.Id
};
public static ShiftSDto AdaptToSDto(this Shift p11)
{
return p11 == null ? null : new ShiftSDto()
{
Title = p11.Title,
Description = p11.Description,
StartAt = p11.StartAt,
EndAt = p11.EndAt,
Days = funcMain4(p11.Days.Select<ShiftDay, DayOfWeek>(funcMain5).ToList<DayOfWeek>()),
ComplexId = p11.ComplexId,
Id = p11.Id
};
}
public static ShiftSDto AdaptTo(this Shift p13, ShiftSDto p14)
{
if (p13 == null)
{
return null;
}
ShiftSDto result = p14 ?? new ShiftSDto();
result.Title = p13.Title;
result.Description = p13.Description;
result.StartAt = p13.StartAt;
result.EndAt = p13.EndAt;
result.Days = funcMain6(p13.Days.Select<ShiftDay, DayOfWeek>(funcMain5).ToList<DayOfWeek>(), result.Days);
result.ComplexId = p13.ComplexId;
result.Id = p13.Id;
return result;
}
public static Expression<Func<Shift, ShiftSDto>> ProjectToSDto => p17 => new ShiftSDto()
{
Title = p17.Title,
Description = p17.Description,
StartAt = p17.StartAt,
EndAt = p17.EndAt,
Days = p17.Days.Select<ShiftDay, DayOfWeek>(d => d.DayOfWeek).ToList<DayOfWeek>(),
ComplexId = p17.ComplexId,
Id = p17.Id
};
private static List<ShiftDay> funcMain1(List<DayOfWeek> p2)
{ {
if (p2 == null) if (p2 == null)
{ {
return null; return null;
} }
List<ShiftDay> result = new List<ShiftDay>(p2.Count); Shift result = p3 ?? new Shift();
int i = 0; result.Title = p2.Title;
int len = p2.Count; result.StartAt = p2.StartAt;
result.EndAt = p2.EndAt;
result.Description = p2.Description;
result.ComplexId = p2.ComplexId;
result.Complex = funcMain1(new Never(), result.Complex, p2);
result.Id = p2.Id;
return result;
while (i < len) }
public static Expression<Func<ShiftSDto, Shift>> ProjectToShift => p6 => new Shift()
{
Title = p6.Title,
StartAt = p6.StartAt,
EndAt = p6.EndAt,
Description = p6.Description,
ComplexId = p6.ComplexId,
Complex = new Complex() {Id = p6.ComplexId},
Id = p6.Id
};
public static ShiftSDto AdaptToSDto(this Shift p7)
{
return p7 == null ? null : new ShiftSDto()
{ {
DayOfWeek item = p2[i]; Title = p7.Title,
result.Add(new ShiftDay() {}); Description = p7.Description,
i++; StartAt = p7.StartAt,
} EndAt = p7.EndAt,
return result; ComplexId = p7.ComplexId,
Id = p7.Id
};
} }
public static ShiftSDto AdaptTo(this Shift p8, ShiftSDto p9)
private static Complex funcMain2(Never p5, Complex p6, ShiftSDto p3)
{ {
Complex result = p6 ?? new Complex(); if (p8 == null)
result.Id = p3.ComplexId;
return result;
}
private static List<ShiftDay> funcMain3(List<DayOfWeek> p7, List<ShiftDay> p8)
{
if (p7 == null)
{ {
return null; return null;
} }
List<ShiftDay> result = new List<ShiftDay>(p7.Count); ShiftSDto result = p9 ?? new ShiftSDto();
int i = 0; result.Title = p8.Title;
int len = p7.Count; result.Description = p8.Description;
result.StartAt = p8.StartAt;
while (i < len) result.EndAt = p8.EndAt;
{ result.ComplexId = p8.ComplexId;
DayOfWeek item = p7[i]; result.Id = p8.Id;
result.Add(new ShiftDay() {});
i++;
}
return result; return result;
} }
public static Expression<Func<Shift, ShiftSDto>> ProjectToSDto => p10 => new ShiftSDto()
private static List<DayOfWeek> funcMain4(List<DayOfWeek> p12)
{ {
if (p12 == null) Title = p10.Title,
{ Description = p10.Description,
return null; StartAt = p10.StartAt,
} EndAt = p10.EndAt,
List<DayOfWeek> result = new List<DayOfWeek>(p12.Count); ComplexId = p10.ComplexId,
Id = p10.Id
};
int i = 0; private static Complex funcMain1(Never p4, Complex p5, ShiftSDto p2)
int len = p12.Count;
while (i < len)
{
DayOfWeek item = p12[i];
result.Add(item);
i++;
}
return result;
}
private static DayOfWeek funcMain5(ShiftDay d)
{ {
return d.DayOfWeek; Complex result = p5 ?? new Complex();
}
private static List<DayOfWeek> funcMain6(List<DayOfWeek> p15, List<DayOfWeek> p16) result.Id = p2.ComplexId;
{
if (p15 == null)
{
return null;
}
List<DayOfWeek> result = new List<DayOfWeek>(p15.Count);
int i = 0;
int len = p15.Count;
while (i < len)
{
DayOfWeek item = p15[i];
result.Add(item);
i++;
}
return result; return result;
} }

View File

@ -14,8 +14,6 @@ namespace Brizco.Domain.Mappers
{ {
return p1 == null ? null : new ShiftPlan() return p1 == null ? null : new ShiftPlan()
{ {
StartAt = p1.StartAt,
EndAt = p1.EndAt,
ShiftId = p1.ShiftId, ShiftId = p1.ShiftId,
Id = p1.Id Id = p1.Id
}; };
@ -28,8 +26,6 @@ namespace Brizco.Domain.Mappers
} }
ShiftPlan result = p3 ?? new ShiftPlan(); ShiftPlan result = p3 ?? new ShiftPlan();
result.StartAt = p2.StartAt;
result.EndAt = p2.EndAt;
result.ShiftId = p2.ShiftId; result.ShiftId = p2.ShiftId;
result.Id = p2.Id; result.Id = p2.Id;
return result; return result;
@ -37,8 +33,6 @@ namespace Brizco.Domain.Mappers
} }
public static Expression<Func<ShiftPlanSDto, ShiftPlan>> ProjectToShiftPlan => p4 => new ShiftPlan() public static Expression<Func<ShiftPlanSDto, ShiftPlan>> ProjectToShiftPlan => p4 => new ShiftPlan()
{ {
StartAt = p4.StartAt,
EndAt = p4.EndAt,
ShiftId = p4.ShiftId, ShiftId = p4.ShiftId,
Id = p4.Id Id = p4.Id
}; };
@ -46,8 +40,6 @@ namespace Brizco.Domain.Mappers
{ {
return p5 == null ? null : new ShiftPlanSDto() return p5 == null ? null : new ShiftPlanSDto()
{ {
StartAt = p5.StartAt,
EndAt = p5.EndAt,
ShiftId = p5.ShiftId, ShiftId = p5.ShiftId,
ShiftTitle = p5.Shift == null ? null : p5.Shift.Title, ShiftTitle = p5.Shift == null ? null : p5.Shift.Title,
Id = p5.Id Id = p5.Id
@ -61,8 +53,6 @@ namespace Brizco.Domain.Mappers
} }
ShiftPlanSDto result = p7 ?? new ShiftPlanSDto(); ShiftPlanSDto result = p7 ?? new ShiftPlanSDto();
result.StartAt = p6.StartAt;
result.EndAt = p6.EndAt;
result.ShiftId = p6.ShiftId; result.ShiftId = p6.ShiftId;
result.ShiftTitle = p6.Shift == null ? null : p6.Shift.Title; result.ShiftTitle = p6.Shift == null ? null : p6.Shift.Title;
result.Id = p6.Id; result.Id = p6.Id;
@ -71,8 +61,6 @@ namespace Brizco.Domain.Mappers
} }
public static Expression<Func<ShiftPlan, ShiftPlanSDto>> ProjectToSDto => p8 => new ShiftPlanSDto() public static Expression<Func<ShiftPlan, ShiftPlanSDto>> ProjectToSDto => p8 => new ShiftPlanSDto()
{ {
StartAt = p8.StartAt,
EndAt = p8.EndAt,
ShiftId = p8.ShiftId, ShiftId = p8.ShiftId,
ShiftTitle = p8.Shift.Title, ShiftTitle = p8.Shift.Title,
Id = p8.Id Id = p8.Id
@ -81,8 +69,6 @@ namespace Brizco.Domain.Mappers
{ {
return p9 == null ? null : new ShiftPlan() return p9 == null ? null : new ShiftPlan()
{ {
StartAt = p9.StartAt,
EndAt = p9.EndAt,
ShiftId = p9.ShiftId, ShiftId = p9.ShiftId,
Users = funcMain1(p9.Users), Users = funcMain1(p9.Users),
Id = p9.Id Id = p9.Id
@ -96,8 +82,6 @@ namespace Brizco.Domain.Mappers
} }
ShiftPlan result = p12 ?? new ShiftPlan(); ShiftPlan result = p12 ?? new ShiftPlan();
result.StartAt = p11.StartAt;
result.EndAt = p11.EndAt;
result.ShiftId = p11.ShiftId; result.ShiftId = p11.ShiftId;
result.Users = funcMain2(p11.Users, result.Users); result.Users = funcMain2(p11.Users, result.Users);
result.Id = p11.Id; result.Id = p11.Id;
@ -106,8 +90,6 @@ namespace Brizco.Domain.Mappers
} }
public static Expression<Func<ShiftPlanLDto, ShiftPlan>> ProjectLDtoToShiftPlan => p15 => new ShiftPlan() public static Expression<Func<ShiftPlanLDto, ShiftPlan>> ProjectLDtoToShiftPlan => p15 => new ShiftPlan()
{ {
StartAt = p15.StartAt,
EndAt = p15.EndAt,
ShiftId = p15.ShiftId, ShiftId = p15.ShiftId,
Users = p15.Users.Select<ShiftPlanUserSDto, ShiftPlanUser>(p16 => new ShiftPlanUser() Users = p15.Users.Select<ShiftPlanUserSDto, ShiftPlanUser>(p16 => new ShiftPlanUser()
{ {
@ -121,8 +103,6 @@ namespace Brizco.Domain.Mappers
{ {
return p17 == null ? null : new ShiftPlanLDto() return p17 == null ? null : new ShiftPlanLDto()
{ {
StartAt = p17.StartAt,
EndAt = p17.EndAt,
ShiftId = p17.ShiftId, ShiftId = p17.ShiftId,
Users = funcMain3(p17.Users), Users = funcMain3(p17.Users),
Id = p17.Id Id = p17.Id
@ -136,8 +116,6 @@ namespace Brizco.Domain.Mappers
} }
ShiftPlanLDto result = p20 ?? new ShiftPlanLDto(); ShiftPlanLDto result = p20 ?? new ShiftPlanLDto();
result.StartAt = p19.StartAt;
result.EndAt = p19.EndAt;
result.ShiftId = p19.ShiftId; result.ShiftId = p19.ShiftId;
result.Users = funcMain4(p19.Users, result.Users); result.Users = funcMain4(p19.Users, result.Users);
result.Id = p19.Id; result.Id = p19.Id;
@ -146,8 +124,6 @@ namespace Brizco.Domain.Mappers
} }
public static Expression<Func<ShiftPlan, ShiftPlanLDto>> ProjectToLDto => p23 => new ShiftPlanLDto() public static Expression<Func<ShiftPlan, ShiftPlanLDto>> ProjectToLDto => p23 => new ShiftPlanLDto()
{ {
StartAt = p23.StartAt,
EndAt = p23.EndAt,
ShiftId = p23.ShiftId, ShiftId = p23.ShiftId,
Users = p23.Users.Select<ShiftPlanUser, ShiftPlanUserSDto>(p24 => new ShiftPlanUserSDto() Users = p23.Users.Select<ShiftPlanUser, ShiftPlanUserSDto>(p24 => new ShiftPlanUserSDto()
{ {

View File

@ -18,7 +18,6 @@ namespace Brizco.Domain.Mappers
Type = p1.Type, Type = p1.Type,
Title = p1.Title, Title = p1.Title,
Description = p1.Description, Description = p1.Description,
IsRelatedToShift = p1.IsRelatedToShift,
IsRelatedToRole = p1.IsRelatedToRole, IsRelatedToRole = p1.IsRelatedToRole,
IsRelatedToPerson = p1.IsRelatedToPerson, IsRelatedToPerson = p1.IsRelatedToPerson,
IsDisposable = p1.IsDisposable, IsDisposable = p1.IsDisposable,
@ -41,7 +40,6 @@ namespace Brizco.Domain.Mappers
result.Type = p2.Type; result.Type = p2.Type;
result.Title = p2.Title; result.Title = p2.Title;
result.Description = p2.Description; result.Description = p2.Description;
result.IsRelatedToShift = p2.IsRelatedToShift;
result.IsRelatedToRole = p2.IsRelatedToRole; result.IsRelatedToRole = p2.IsRelatedToRole;
result.IsRelatedToPerson = p2.IsRelatedToPerson; result.IsRelatedToPerson = p2.IsRelatedToPerson;
result.IsDisposable = p2.IsDisposable; result.IsDisposable = p2.IsDisposable;
@ -59,7 +57,6 @@ namespace Brizco.Domain.Mappers
Type = p4.Type, Type = p4.Type,
Title = p4.Title, Title = p4.Title,
Description = p4.Description, Description = p4.Description,
IsRelatedToShift = p4.IsRelatedToShift,
IsRelatedToRole = p4.IsRelatedToRole, IsRelatedToRole = p4.IsRelatedToRole,
IsRelatedToPerson = p4.IsRelatedToPerson, IsRelatedToPerson = p4.IsRelatedToPerson,
IsDisposable = p4.IsDisposable, IsDisposable = p4.IsDisposable,
@ -77,7 +74,6 @@ namespace Brizco.Domain.Mappers
Type = p5.Type, Type = p5.Type,
Title = p5.Title, Title = p5.Title,
Description = p5.Description, Description = p5.Description,
IsRelatedToShift = p5.IsRelatedToShift,
IsRelatedToRole = p5.IsRelatedToRole, IsRelatedToRole = p5.IsRelatedToRole,
IsRelatedToPerson = p5.IsRelatedToPerson, IsRelatedToPerson = p5.IsRelatedToPerson,
IsDisposable = p5.IsDisposable, IsDisposable = p5.IsDisposable,
@ -100,7 +96,6 @@ namespace Brizco.Domain.Mappers
result.Type = p6.Type; result.Type = p6.Type;
result.Title = p6.Title; result.Title = p6.Title;
result.Description = p6.Description; result.Description = p6.Description;
result.IsRelatedToShift = p6.IsRelatedToShift;
result.IsRelatedToRole = p6.IsRelatedToRole; result.IsRelatedToRole = p6.IsRelatedToRole;
result.IsRelatedToPerson = p6.IsRelatedToPerson; result.IsRelatedToPerson = p6.IsRelatedToPerson;
result.IsDisposable = p6.IsDisposable; result.IsDisposable = p6.IsDisposable;
@ -118,7 +113,6 @@ namespace Brizco.Domain.Mappers
Type = p8.Type, Type = p8.Type,
Title = p8.Title, Title = p8.Title,
Description = p8.Description, Description = p8.Description,
IsRelatedToShift = p8.IsRelatedToShift,
IsRelatedToRole = p8.IsRelatedToRole, IsRelatedToRole = p8.IsRelatedToRole,
IsRelatedToPerson = p8.IsRelatedToPerson, IsRelatedToPerson = p8.IsRelatedToPerson,
IsDisposable = p8.IsDisposable, IsDisposable = p8.IsDisposable,
@ -136,7 +130,6 @@ namespace Brizco.Domain.Mappers
Type = p9.Type, Type = p9.Type,
Title = p9.Title, Title = p9.Title,
Description = p9.Description, Description = p9.Description,
IsRelatedToShift = p9.IsRelatedToShift,
IsRelatedToRole = p9.IsRelatedToRole, IsRelatedToRole = p9.IsRelatedToRole,
IsRelatedToPerson = p9.IsRelatedToPerson, IsRelatedToPerson = p9.IsRelatedToPerson,
IsDisposable = p9.IsDisposable, IsDisposable = p9.IsDisposable,
@ -161,7 +154,6 @@ namespace Brizco.Domain.Mappers
result.Type = p13.Type; result.Type = p13.Type;
result.Title = p13.Title; result.Title = p13.Title;
result.Description = p13.Description; result.Description = p13.Description;
result.IsRelatedToShift = p13.IsRelatedToShift;
result.IsRelatedToRole = p13.IsRelatedToRole; result.IsRelatedToRole = p13.IsRelatedToRole;
result.IsRelatedToPerson = p13.IsRelatedToPerson; result.IsRelatedToPerson = p13.IsRelatedToPerson;
result.IsDisposable = p13.IsDisposable; result.IsDisposable = p13.IsDisposable;
@ -181,7 +173,6 @@ namespace Brizco.Domain.Mappers
Type = p21.Type, Type = p21.Type,
Title = p21.Title, Title = p21.Title,
Description = p21.Description, Description = p21.Description,
IsRelatedToShift = p21.IsRelatedToShift,
IsRelatedToRole = p21.IsRelatedToRole, IsRelatedToRole = p21.IsRelatedToRole,
IsRelatedToPerson = p21.IsRelatedToPerson, IsRelatedToPerson = p21.IsRelatedToPerson,
IsDisposable = p21.IsDisposable, IsDisposable = p21.IsDisposable,
@ -214,7 +205,6 @@ namespace Brizco.Domain.Mappers
Type = p25.Type, Type = p25.Type,
Title = p25.Title, Title = p25.Title,
Description = p25.Description, Description = p25.Description,
IsRelatedToShift = p25.IsRelatedToShift,
IsRelatedToRole = p25.IsRelatedToRole, IsRelatedToRole = p25.IsRelatedToRole,
IsRelatedToPerson = p25.IsRelatedToPerson, IsRelatedToPerson = p25.IsRelatedToPerson,
IsDisposable = p25.IsDisposable, IsDisposable = p25.IsDisposable,
@ -239,7 +229,6 @@ namespace Brizco.Domain.Mappers
result.Type = p29.Type; result.Type = p29.Type;
result.Title = p29.Title; result.Title = p29.Title;
result.Description = p29.Description; result.Description = p29.Description;
result.IsRelatedToShift = p29.IsRelatedToShift;
result.IsRelatedToRole = p29.IsRelatedToRole; result.IsRelatedToRole = p29.IsRelatedToRole;
result.IsRelatedToPerson = p29.IsRelatedToPerson; result.IsRelatedToPerson = p29.IsRelatedToPerson;
result.IsDisposable = p29.IsDisposable; result.IsDisposable = p29.IsDisposable;
@ -259,7 +248,6 @@ namespace Brizco.Domain.Mappers
Type = p37.Type, Type = p37.Type,
Title = p37.Title, Title = p37.Title,
Description = p37.Description, Description = p37.Description,
IsRelatedToShift = p37.IsRelatedToShift,
IsRelatedToRole = p37.IsRelatedToRole, IsRelatedToRole = p37.IsRelatedToRole,
IsRelatedToPerson = p37.IsRelatedToPerson, IsRelatedToPerson = p37.IsRelatedToPerson,
IsDisposable = p37.IsDisposable, IsDisposable = p37.IsDisposable,

View File

@ -9,7 +9,6 @@ public class MapsterRegister : IRegister
public void Register(TypeAdapterConfig config) public void Register(TypeAdapterConfig config)
{ {
config.NewConfig<Shift, ShiftSDto>() config.NewConfig<Shift, ShiftSDto>()
.Map("Days", org => org.Days.Select(d=>d.DayOfWeek).ToList())
.TwoWays(); .TwoWays();

View File

@ -28,7 +28,6 @@ public class CreateActivityCommandHandler : IRequestHandler<CreateActivityComman
request.Title, request.Title,
request.Description, request.Description,
request.Type, request.Type,
request.IsRelatedToShift,
request.IsRelatedToRole, request.IsRelatedToRole,
request.IsRelatedToPerson, request.IsRelatedToPerson,
request.IsDisposable, request.IsDisposable,
@ -53,12 +52,6 @@ public class CreateActivityCommandHandler : IRequestHandler<CreateActivityComman
task.AddShift(request.Roles.ToArray()); task.AddShift(request.Roles.ToArray());
} }
if (task.IsRelatedToShift)
{
if (request.Shifts.Count == 0)
throw new AppException("اگر فعالیت برای یک شیفت انتخاب شده باشد باید لیست شیفت ها را ارسال نمایید");
task.AddRole(request.Shifts.ToArray());
}
_repositoryWrapper.SetRepository<Domain.Entities.Task.Activity>().Add(task); _repositoryWrapper.SetRepository<Domain.Entities.Task.Activity>().Add(task);
await _repositoryWrapper.SaveChangesAsync(cancellationToken); await _repositoryWrapper.SaveChangesAsync(cancellationToken);

View File

@ -32,7 +32,6 @@ public class UpdateActivityCommandHandler : IRequestHandler<UpdateActivityComman
request.Title, request.Title,
request.Description, request.Description,
request.Type, request.Type,
request.IsRelatedToShift,
request.IsRelatedToRole, request.IsRelatedToRole,
request.IsRelatedToPerson, request.IsRelatedToPerson,
request.IsDisposable, request.IsDisposable,

View File

@ -28,8 +28,6 @@ public class CreateShiftCommandHandler : IRequestHandler<CreateShiftCommand, Shi
request.EndAt, request.EndAt,
complexId); complexId);
request.DayOfWeeks.ForEach(d => shift.SetDay(d));
_repositoryWrapper.SetRepository<Domain.Entities.Shift.Shift>().Add(shift); _repositoryWrapper.SetRepository<Domain.Entities.Shift.Shift>().Add(shift);
await _repositoryWrapper.SaveChangesAsync(cancellationToken); await _repositoryWrapper.SaveChangesAsync(cancellationToken);
await _repositoryWrapper.CommitAsync(cancellationToken); await _repositoryWrapper.CommitAsync(cancellationToken);

View File

@ -16,10 +16,6 @@ public class GetShiftPlansQueryHandler : IRequestHandler<GetShiftsQuery, List<Sh
.Select(ShiftMapper.ProjectToSDto) .Select(ShiftMapper.ProjectToSDto)
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);
shifts.ForEach(s =>
{
s.Days = s.Days.OrderBy(d=>d).ToList();
});
return shifts; return shifts;
} }

View File

@ -1,6 +1,4 @@
using Brizco.Domain.Entities.Shift; namespace Brizco.Repository.Handlers.Shift;
namespace Brizco.Repository.Handlers.Shift;
public class UpdateShiftCommandHandler : IRequestHandler<UpdateShiftCommand, bool> public class UpdateShiftCommandHandler : IRequestHandler<UpdateShiftCommand, bool>
{ {
@ -32,25 +30,6 @@ public class UpdateShiftCommandHandler : IRequestHandler<UpdateShiftCommand, boo
complexId); complexId);
newShift.Id = request.Id; newShift.Id = request.Id;
var shiftDays = await _repositoryWrapper.SetRepository<ShiftDay>()
.TableNoTracking.Where(sd => sd.ShiftId == request.Id)
.ToListAsync(cancellationToken);
foreach (var shiftDay in shiftDays.Where(shiftDay => !request.DayOfWeeks.Contains(shiftDay.DayOfWeek)))
{
_repositoryWrapper.SetRepository<ShiftDay>()
.Delete(shiftDay);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
}
foreach (var dayOfWeek in request.DayOfWeeks)
{
var findDay = shiftDays.FirstOrDefault(sf => sf.DayOfWeek == dayOfWeek);
if (findDay != null)
shift.SetDay(dayOfWeek);
}
_repositoryWrapper.SetRepository<Domain.Entities.Shift.Shift>() _repositoryWrapper.SetRepository<Domain.Entities.Shift.Shift>()
.Update(newShift); .Update(newShift);
await _repositoryWrapper.SaveChangesAsync(cancellationToken); await _repositoryWrapper.SaveChangesAsync(cancellationToken);

View File

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

View File

@ -12,7 +12,7 @@ public class DeleteShiftPlanCommandHandler : IRequestHandler<DeleteShiftPlanComm
public async Task<bool> Handle(DeleteShiftPlanCommand request, CancellationToken cancellationToken) public async Task<bool> Handle(DeleteShiftPlanCommand request, CancellationToken cancellationToken)
{ {
var shiftPlan = await _repositoryWrapper.SetRepository<Domain.Entities.Shift.ShiftPlan>() var shiftPlan = await _repositoryWrapper.SetRepository<Domain.Entities.Shift.ShiftPlan>()
.TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.Id); .TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.Id,cancellationToken);
if (shiftPlan == null) if (shiftPlan == null)
throw new AppException("ShiftPlan not found", ApiResultStatusCode.NotFound); throw new AppException("ShiftPlan not found", ApiResultStatusCode.NotFound);

View File

@ -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.StartAt, request.EndAt); var newPlan = shift.AddPlan(request.PlanDate);
newPlan.Id = request.Id; newPlan.Id = request.Id;

View File

@ -44,13 +44,6 @@ public class CreateActivityCommandHandler : IRequestHandler<CreateTaskCommand, T
task.AddShift(request.Roles.ToArray()); task.AddShift(request.Roles.ToArray());
} }
if (task.IsRelatedToShift)
{
if (request.Shifts.Count == 0)
throw new AppException("اگر فعالیت برای یک شیفت انتخاب شده باشد باید لیست شیفت ها را ارسال نمایید");
task.AddRole(request.Shifts.ToArray());
}
_repositoryWrapper.SetRepository<Domain.Entities.Task.Task>().Add(task); _repositoryWrapper.SetRepository<Domain.Entities.Task.Task>().Add(task);
await _repositoryWrapper.SaveChangesAsync(cancellationToken); await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return task.AdaptToLDto(); return task.AdaptToLDto();

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,95 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Brizco.Repository.Migrations
{
/// <inheritdoc />
public partial class editShift : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ShiftDays",
schema: "public");
migrationBuilder.DropColumn(
name: "IsRelatedToShift",
schema: "public",
table: "Tasks");
migrationBuilder.DropColumn(
name: "EndAt",
schema: "public",
table: "ShiftPlans");
migrationBuilder.RenameColumn(
name: "StartAt",
schema: "public",
table: "ShiftPlans",
newName: "PlanDate");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "PlanDate",
schema: "public",
table: "ShiftPlans",
newName: "StartAt");
migrationBuilder.AddColumn<bool>(
name: "IsRelatedToShift",
schema: "public",
table: "Tasks",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<DateTime>(
name: "EndAt",
schema: "public",
table: "ShiftPlans",
type: "timestamp without time zone",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.CreateTable(
name: "ShiftDays",
schema: "public",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
ShiftId = table.Column<Guid>(type: "uuid", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
DayOfWeek = table.Column<int>(type: "integer", nullable: false),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ShiftDays", x => x.Id);
table.ForeignKey(
name: "FK_ShiftDays_Shifts_ShiftId",
column: x => x.ShiftId,
principalSchema: "public",
principalTable: "Shifts",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_ShiftDays_ShiftId",
schema: "public",
table: "ShiftDays",
column: "ShiftId");
}
}
}

View File

@ -214,49 +214,6 @@ namespace Brizco.Repository.Migrations
b.ToTable("Shifts", "public"); b.ToTable("Shifts", "public");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftDay", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("DayOfWeek")
.HasColumnType("integer");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.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")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ShiftId");
b.ToTable("ShiftDays", "public");
});
modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
@ -270,9 +227,6 @@ namespace Brizco.Repository.Migrations
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTime>("EndAt")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsRemoved") b.Property<bool>("IsRemoved")
.HasColumnType("boolean"); .HasColumnType("boolean");
@ -283,6 +237,9 @@ namespace Brizco.Repository.Migrations
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTime>("PlanDate")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("RemovedAt") b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone"); .HasColumnType("timestamp without time zone");
@ -293,9 +250,6 @@ namespace Brizco.Repository.Migrations
b.Property<Guid>("ShiftId") b.Property<Guid>("ShiftId")
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<DateTime>("StartAt")
.HasColumnType("timestamp without time zone");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ShiftId"); b.HasIndex("ShiftId");
@ -390,9 +344,6 @@ namespace Brizco.Repository.Migrations
b.Property<bool>("IsRelatedToRole") b.Property<bool>("IsRelatedToRole")
.HasColumnType("boolean"); .HasColumnType("boolean");
b.Property<bool>("IsRelatedToShift")
.HasColumnType("boolean");
b.Property<bool>("IsRemoved") b.Property<bool>("IsRemoved")
.HasColumnType("boolean"); .HasColumnType("boolean");
@ -914,17 +865,6 @@ namespace Brizco.Repository.Migrations
b.Navigation("Complex"); b.Navigation("Complex");
}); });
modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftDay", b =>
{
b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift")
.WithMany("Days")
.HasForeignKey("ShiftId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Shift");
});
modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b =>
{ {
b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift")
@ -1112,8 +1052,6 @@ namespace Brizco.Repository.Migrations
modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b =>
{ {
b.Navigation("Days");
b.Navigation("Plans"); b.Navigation("Plans");
}); });