/// <summary>
        /// Gets the results of tests on the predicate
        /// </summary>
        /// <param name="predicates">Predicate</param>
        /// <returns>Test results collection</returns>
        public IEnumerable <BllTestResult> GetAllByPredicate(Expression <Func <BllTestResult, bool> > predicates)
        {
            var visitor = new PredicateExpressionVisitor <BllTestResult, DalTestResult>(Expression.Parameter(typeof(DalTestResult), predicates.Parameters[0].Name));
            var exp     = Expression.Lambda <Func <DalTestResult, bool> >(visitor.Visit(predicates.Body), visitor.NewParameter);

            return(testResultRepository.GetAllByPredicate(exp).Select(testResult => testResult.ToBllTestResult()).ToList());
        }
Пример #2
0
        /// <summary>
        /// Removes the results of passing tests from the user.
        /// </summary>
        /// <param name="userId">User id</param>
        public void DeleteUserResults(int userId)
        {
            var userResults = testResultRepository.GetAllByPredicate(r => r.UserId == userId);

            foreach (var userResult in userResults)
            {
                testResultRepository.Delete(userResult);
            }
        }