165 lines
3.8 KiB
C#
165 lines
3.8 KiB
C#
using Brizco.Common.Models.Exception;
|
|
using Brizco.Domain.Entities.Routine;
|
|
|
|
namespace Brizco.Domain.Entities.Task;
|
|
|
|
|
|
public partial class Task
|
|
{
|
|
|
|
public static Task Create(
|
|
string title,
|
|
string description,
|
|
TaskType type,
|
|
bool isDisposable,
|
|
DateTime setFor,
|
|
bool hasDisposed,
|
|
int amount,
|
|
PurchaseAmountType amountType,
|
|
Guid complexId,
|
|
TaskScheduleType scheduleType)
|
|
{
|
|
if (scheduleType == TaskScheduleType.Custom && setFor == DateTime.MinValue)
|
|
throw new AppException("اگر تکرار وظیفه یک روز خاص باشد باید ان روز را انتخاب کنید");
|
|
if (scheduleType == TaskScheduleType.Custom)
|
|
isDisposable = true;
|
|
return new Task(
|
|
type,
|
|
isDisposable,
|
|
setFor,
|
|
hasDisposed,
|
|
amount,
|
|
amountType,
|
|
title,
|
|
description,
|
|
complexId,
|
|
scheduleType);
|
|
}
|
|
|
|
|
|
public TaskDay SetDay(DayOfWeek dayOfWeek)
|
|
{
|
|
var taskDay = new TaskDay(dayOfWeek, Id);
|
|
Days.Add(taskDay);
|
|
return taskDay;
|
|
}
|
|
|
|
|
|
public void AddShift(params Guid[] shiftIds)
|
|
{
|
|
foreach (var shiftId in shiftIds)
|
|
{
|
|
var plan = new TaskShift(Id, shiftId);
|
|
Shifts.Add(plan);
|
|
}
|
|
}
|
|
|
|
public TaskShift AddShift(Guid shiftId)
|
|
{
|
|
var plan = new TaskShift(Id, shiftId);
|
|
Shifts.Add(plan);
|
|
return plan;
|
|
}
|
|
|
|
public void AddPosition(params Guid[] positionIds)
|
|
{
|
|
foreach (var positionId in positionIds)
|
|
{
|
|
var position = new TaskPosition(positionId, Id);
|
|
Positions.Add(position);
|
|
}
|
|
}
|
|
public TaskPosition AddPosition(Guid positionId)
|
|
{
|
|
var position = new TaskPosition(positionId, Id);
|
|
Positions.Add(position);
|
|
return position;
|
|
}
|
|
|
|
|
|
|
|
public void AddRoutine(params Guid[] routineIds)
|
|
{
|
|
foreach (var routineId in routineIds)
|
|
{
|
|
var routine = new TaskRoutine(routineId, Id);
|
|
Routines.Add(routine);
|
|
}
|
|
}
|
|
public TaskRoutine AddRoutine(Guid routineId)
|
|
{
|
|
var routine = new TaskRoutine(routineId, Id);
|
|
Routines.Add(routine);
|
|
return routine;
|
|
}
|
|
}
|
|
|
|
public partial class Activity
|
|
{
|
|
|
|
public static Activity Create(
|
|
ActivityStatus status,
|
|
DateTime doneAt,
|
|
string performanceDescription,
|
|
string title,
|
|
string description,
|
|
TaskType type,
|
|
bool isDisposable,
|
|
DateTime setFor,
|
|
bool hasDisposed,
|
|
int amount,
|
|
PurchaseAmountType amountType,
|
|
Guid complexId,
|
|
TaskScheduleType scheduleType)
|
|
{
|
|
return new Activity(
|
|
status,
|
|
doneAt,
|
|
performanceDescription,
|
|
type,
|
|
isDisposable,
|
|
setFor,
|
|
hasDisposed,
|
|
amount,
|
|
amountType,
|
|
title,
|
|
description,
|
|
complexId,
|
|
scheduleType);
|
|
}
|
|
|
|
public void SetShift(Guid shiftId)
|
|
{
|
|
this.ShiftId = shiftId;
|
|
}
|
|
|
|
|
|
public void SetUser(Guid userId)
|
|
{
|
|
this.UserId = userId;
|
|
}
|
|
|
|
public void DoneActivity()
|
|
{
|
|
DoneAt = DateTime.UtcNow;
|
|
IsDone = true;
|
|
Status = ActivityStatus.Done;
|
|
}
|
|
|
|
public void CompleteActivity(bool isDone, string performanceDescription)
|
|
{
|
|
if (!isDone)
|
|
Status = ActivityStatus.UnDone;
|
|
else
|
|
Status = ActivityStatus.Complete;
|
|
IsDone = isDone;
|
|
PerformanceDescription = performanceDescription;
|
|
}
|
|
|
|
public void UnDoneActivity(string undoneReason)
|
|
{
|
|
IsDone = false;
|
|
UnDoneReason = undoneReason;
|
|
Status = ActivityStatus.UnDone;
|
|
}
|
|
} |