private PersonTask CloneTask(PersonTask task) { PersonTask newTask; if (task is JiraPersonTask) newTask = new JiraPersonTask(task.Name); else newTask = new CustomPersonTask(task.Name); newTask.Id = task.Id; newTask.WorkMonthId = task.WorkMonthId; newTask.Project = task.Project; newTask.StartTime = null; newTask.Hours = null; newTask.MultipleDays = true; return newTask; }
private PersonTask GetNextCustomTask(List<PersonTask> tasksWithTimeData, WorkDay day, TimeSpan actualWorkHours, PersonTask task) { var todayRemainingTime = day.WorkingHours.Subtract(actualWorkHours); var hoursForTask = task.Hours.Value; if (hoursForTask > todayRemainingTime) { var tomorrowTask = CloneTask(task); tomorrowTask.Hours = hoursForTask.Subtract(todayRemainingTime); tomorrowTask.StartTime = task.StartTime.Value.AddDays(1); tasksWithTimeData.Add(tomorrowTask); hoursForTask = todayRemainingTime; task.MultipleDays = true; } task.Hours = hoursForTask; task.StartTime = GetTaskStartTime(actualWorkHours, day); return task; }