Beispiel #1
0
        public JobTask AddNewJobTask(TitleAndDescription titleAndDescription)
        {
            JobTask jobTask = new JobTask(this, titleAndDescription);

            int maxOrderValue = _jobTasks.Any() ? _jobTasks.Max(j => j.Order) + 1 : 0;

            jobTask.PlaceTaskInPosition(maxOrderValue);

            _jobTasks.Add(jobTask);

            return(jobTask);
        }
Beispiel #2
0
        public JobTask UpdateJobTask(JobTaskId jobTaskId, TitleAndDescription titleAndDescription, int order, IEnumerable <JobTaskItem> jobTaskItems)
        {
            JobTask existingJobTask = _jobTasks.SingleOrDefault(jt => jt.Id == jobTaskId);

            Guard.Against.Null(existingJobTask, nameof(existingJobTask));

            int currentOrder = existingJobTask.Order;
            int newTaskOrder = order > _jobTasks.Max(jt => jt.Order) ? _jobTasks.Max(jt => jt.Order) : order;

            existingJobTask
            .UpdateTitleAndDescription(titleAndDescription);

            existingJobTask.ClearAllJobTaskItems();
            if (jobTaskItems.Any())
            {
                foreach (var jobTaskItem in jobTaskItems)
                {
                    existingJobTask.AddNewJobTaskItem(jobTaskItem);
                }
            }

            if (existingJobTask.Order == newTaskOrder)
            {
                return(existingJobTask);
            }

            existingJobTask.PlaceTaskInPosition(newTaskOrder);

            // If the new task order is greater than the current order of the job task,
            // everything task below it in order gets decremented
            if (newTaskOrder > currentOrder)
            {
                ReorderJobTasks(
                    _jobTasks.Where(j => j.Order <= newTaskOrder && j.Id != existingJobTask.Id),
                    jt => jt.DecrementOrder(),
                    jt => jt.Order != 0
                    );
            }
            else
            {
                ReorderJobTasks(
                    _jobTasks.Where(j => j.Order >= newTaskOrder && j.Id != existingJobTask.Id),
                    jt => jt.IncrementOrder(),
                    jt => jt.Order + 1 < _jobTasks.Count
                    );
            }

            return(existingJobTask);
        }
Beispiel #3
0
        public JobTask InsertNewJobTaskAt(TitleAndDescription titleAndDescription, int position)
        {
            JobTask jobTaskAtPosition = _jobTasks.SingleOrDefault(j => j.Order == position);

            if (jobTaskAtPosition == null)
            {
                return(AddNewJobTask(titleAndDescription));
            }

            ReorderJobTasks(
                _jobTasks.Where(j => j.Order >= jobTaskAtPosition.Order),
                jt => jt.IncrementOrder(),
                jt => true
                );

            var jobTask = new JobTask(this, titleAndDescription);

            jobTask.PlaceTaskInPosition(position);
            _jobTasks.Add(jobTask);

            return(jobTaskAtPosition);
        }
Beispiel #4
0
        public Job UpdateTitleAndDescription(TitleAndDescription titleAndDescription)
        {
            TitleAndDescription = titleAndDescription;

            return(this);
        }
Beispiel #5
0
 public Job(TitleAndDescription titleAndDescription, int industryId) : this(new JobId())
 {
     TitleAndDescription = titleAndDescription;
     IndustryId          = industryId;
 }
 private Industry(int type, TitleAndDescription titleAndDescription) : this(new IndustryId())
 {
     Type = type;
     TitleAndDescription = titleAndDescription;
 }
 public JobTask(Job job, TitleAndDescription titleAndDescription) : this(new JobTaskId())
 {
     JobId = job.Id;
     TitleAndDescription = titleAndDescription;
 }