示例#1
0
        public Week NewWeek(DateTime maxDate)
        {
            maxDate = new List <DateTime> {
                maxDate, GetMaxStartDate()
            }.Max();
            var startDate = _dateProvider.GetCurrentWeekStartDate();

            while (startDate <= maxDate)
            {
                startDate = startDate.AddDays(7);
            }

            var week = new Week {
                StartDate = startDate
            };

            return(_repo.Save(week));
        }
        public HourCode AddHourCode(string code, string name)
        {
            if (string.IsNullOrWhiteSpace(code) || string.IsNullOrWhiteSpace(name))
            {
                throw new HourGlassUserException(ExceptionType.InvalidHourCode, code, name);
            }

            var hourCode = new HourCode {
                Code = code.Trim(), Name = name.Trim()
            };
            var duplicate = FindDuplicateOf(hourCode);

            if (duplicate != null)
            {
                return(duplicate);
            }

            _repo.Save(hourCode);
            HourCodes.Add(hourCode);
            return(hourCode);
        }