Пример #1
0
 public Report(ParametersModel param)
 {
     AgeReport     = param.AgeIsNotImportant ? "не важен" : $"от {param.FromAge} до {param.ToAge} лет";
     FirstUserName = param.User;
     DateTime      = DateTime.Now;
     SexReport     = param.Sex.Description();
     Theme         = param.Filter.Description();
 }
Пример #2
0
        public UserFilter(ParametersModel parameters)
        {
            FilteredField = DataFilter[parameters.Filter];
            if (parameters.AgeIsNotImportant)
            {
                AgeConstraints = user => true;
            }
            else
            {
                AgeConstraints = user => user.DateIsValid && user.Age >= parameters.FromAge && user.Age <= parameters.ToAge;
            }

            if (parameters.Sex == SexEnum.Both)
            {
                SexConstraints = user => true;
            }
            else
            {
                var conditionSex = parameters.Sex == SexEnum.Man ? 2 : 1;
                SexConstraints = user => user.Sex == conditionSex;
            }
        }