Exemplo n.º 1
0
        public IList <TSHoursRecord> GetRecordsForWeek(int year, int week, int employeeId)
        {
            var startWeekDate = DateTimeExtention.FirstDateOfWeekISO8601(year, week);
            var endWeekDate   = DateTimeExtention.LastDateOfWeekISO8601(year, week);

            return(Get(records => records.Where(x => x.RecordDate >= startWeekDate && x.RecordDate <= endWeekDate && x.EmployeeID == employeeId).ToList()));
        }
Exemplo n.º 2
0
        public ProductionCalendarRecord GetSpecifiedWorkDayInSelectedWeek(int numberWorkDay, DateTime dateTime)
        {
            //получить эту неделю
            var currentYear       = dateTime.Year;
            var currentWeekNumber = DateTimeExtention.GetIso8601WeekOfYear(dateTime);

            var currentWeekStart = DateTimeExtention.FirstDateOfWeekISO8601(currentYear, currentWeekNumber);
            var currentWeekEnd   = DateTimeExtention.LastDateOfWeekISO8601(currentYear, currentWeekNumber);

            ProductionCalendarRecord foundWorkingCalendarDay = null;
            var currentWeekDateRange = currentWeekStart.Range(currentWeekEnd);

            foreach (var date in RepositoryFactory.GetRepository <IProductionCalendarRepository>().GetQueryable().Where(x => currentWeekDateRange.Any(o => x.CalendarDate == o)))
            {
                if (date.WorkingHours > 0)
                {
                    --numberWorkDay;
                }

                if (numberWorkDay == 0)
                {
                    foundWorkingCalendarDay = date;
                    break;
                }
            }
            return(foundWorkingCalendarDay);
        }
Exemplo n.º 3
0
 public void SetCache(string key, object value, TimeSpan timeout, ExpireType expireType = ExpireType.Absolute)
 {
     if (expireType == ExpireType.Absolute)
     {
         MemoryCache.Set(key, value, new DateTimeOffset(DateTimeExtention.GetCstTime() + timeout));
     }
     else
     {
         MemoryCache.Set(key, value, timeout);
     }
 }
Exemplo n.º 4
0
        public UpdatePersonCommandValidator(IUnitOfWork unitOfWork)
        {
            _unitOfWork = unitOfWork;

            RuleFor(m => m.Id)
            .NotEmpty()
            .MustAsync((s, t, r) => PersonDoesNotExists(s.Id))
            .WithMessage(ValidationErrorMessages.PersonDoesNotExists);

            RuleFor(m => m.FirstName)
            .NotEmpty()
            .Length(2, 50)
            .Must(m =>
                  !string.IsNullOrWhiteSpace(m) &&
                  (Regex.IsMatch(m, "^[a-zA-Z]*$") || Regex.IsMatch(m, "^[ა-ჰ]*$")))
            .WithMessage(ValidationErrorMessages.UnicodeError);

            RuleFor(m => m.LastName)
            .NotEmpty()
            .Length(2, 50)
            .Must(m =>
                  !string.IsNullOrWhiteSpace(m) &&
                  (Regex.IsMatch(m, "^[a-zA-Z]*$") || Regex.IsMatch(m, "^[ა-ჰ]*$")))
            .WithMessage(ValidationErrorMessages.UnicodeError);

            RuleFor(m => m.PersonalNumber)
            .NotEmpty()
            .Length(11, 11)
            .Matches("^[0-9]*$");

            RuleFor(m => m.BirthDate)
            .NotEmpty()
            .Must(b => DateTimeExtention.IsAdult(b)).WithMessage("Person is under 18")
            .WithMessage(ValidationErrorMessages.IsNotAdult);

            RuleFor(m => m.Gender)
            .NotEmpty();
            RuleFor(m => m.CityId)
            .NotEmpty()
            .MustAsync((s, t) => CityExists(s))
            .WithMessage(ValidationErrorMessages.CityDoesNotExists);
        }
Exemplo n.º 5
0
 public void SetCache(string key, object value, TimeSpan timeout)
 {
     MemoryCache.Set(key, value, new DateTimeOffset(DateTimeExtention.GetCstTime() + timeout));
 }