Ejemplo n.º 1
0
        public Course(string name, decimal price, DateTime startTime, DateTime endTime)
        {
            Name  = name;
            Price = price;

            var isStartTimeBeforeEndTime = startTime <= endTime;
            var isWeekDayCorrect         = DateHelper.AllowedDaysOfWeek.Contains(startTime.DayOfWeek) &&
                                           DateHelper.AllowedDaysOfWeek.Contains(endTime.DayOfWeek);
            var isTimeCorrect = DateHelper.IsWorkTime(startTime) && DateHelper.IsWorkTime(endTime);

            if (isStartTimeBeforeEndTime && isWeekDayCorrect && isTimeCorrect)
            {
                StartTime = startTime;
                EndTime   = endTime;

                return;
            }

            throw ExceptionMessageHelper.GetExceptionAndPopulateMessage(isWeekDayCorrect, isTimeCorrect);
        }