public string GetInvalidMessage(HabitGoal goal)
        {
            var goalInvalidMessage = _goalValidator.GetInvalidMessage(goal);

            if (!string.IsNullOrEmpty(goalInvalidMessage))
            {
                return(goalInvalidMessage);
            }

            return(goal.Target <= 0 ? "Target must be greater than 0." : "Logs must be between the goal start and end date.");
        }
        public string GetInvalidMessage(ListGoal goal)
        {
            var goalInvalidMessage = _goalValidator.GetInvalidMessage(goal);

            if (!string.IsNullOrEmpty(goalInvalidMessage))
            {
                return(goalInvalidMessage);
            }

            if (string.IsNullOrEmpty(goal.ListName) || string.IsNullOrWhiteSpace(goal.ListName))
            {
                return("List must have a valid name.");
            }

            return(goal.Target <= 0 ? "Target must be greater than 0." : "All list items must have a name.");
        }
예제 #3
0
        public string GetInvalidMessage(NumberGoal goal)
        {
            var goalInvalidMessage = _goalValidator.GetInvalidMessage(goal);

            if (!string.IsNullOrEmpty(goalInvalidMessage))
            {
                return(goalInvalidMessage);
            }

            if (goal.Target <= 0)
            {
                return("Target must be greater than 0.");
            }

            return(goal.Logs.Any(log => log.Date < goal.StartDate || log.Date > goal.EndDate) ?
                   "Logs must be between the goal start and end date." : "All log amounts must be greater than 0.");
        }