예제 #1
0
        public async Task <bool> IsValidReorderAsync(IGoalsService goalsService)
        {
            if (this.GoalId == this.TargetParentId)
            {
                return(false);
            }

            try
            {
                var goal = await goalsService.GetGoalAsync(this.GoalId);

                var targetParent = await goalsService.GetGoalAsync(this.TargetParentId);

                var childrenIds          = goal.GetTree().Select(g => g.Id);
                var targetParentIsAChild = childrenIds.Any(c => c == this.TargetParentId);

                return(!targetParentIsAChild);
            }
            catch (GoalNotFoundException)
            {
                return(false);
            }
        }
예제 #2
0
        public async Task <bool> IsWithinParentDatesAsync(IGoalsService goalsService)
        {
            var goal = await goalsService.GetGoalAsync(this.Id);

            if (goal.ParentId == null)
            {
                return(true);
            }

            var startDateValid =
                this.StartDate == null ||
                (this.StartDate >= goal.Parent.StartDate);
            var endDateValid =
                this.EndDate == null ||
                (this.EndDate <= goal.Parent.EndDate);

            return(startDateValid && endDateValid);
        }