public IResult<IQueryable<ICompanySummaryReturn>> GetCompanies(FilterCompanyParameters parameters) { var parsedParameters = parameters.ToParsedParameters(); if(!parsedParameters.Success) { return parsedParameters.ConvertTo<IQueryable<ICompanySummaryReturn>>(); } var predicateResult = CompanyPredicateBuilder.BuildPredicate(parsedParameters.ResultingObject); if(!predicateResult.Success) { return predicateResult.ConvertTo<IQueryable<ICompanySummaryReturn>>(); } var results = _companyUnitOfWork.CompanyRepository .Filter(predicateResult.ResultingObject) .SplitSelect(CompanyProjectors.SplitSelectSummary()); return new SuccessResult<IQueryable<ICompanySummaryReturn>>(results); }
public IResult<ICompanyDetailReturn> GetCompany(string companyKey) { if(companyKey == null) { throw new ArgumentNullException("companyKey"); } var companyKeyResult = KeyParserHelper.ParseResult<ICompanyKey>(companyKey); if(!companyKeyResult.Success) { return companyKeyResult.ConvertTo<ICompanyDetailReturn>(); } var parsedCompanyKey = companyKeyResult.ResultingObject.ToCompanyKey(); var companyResult = _companyUnitOfWork.CompanyRepository .Filter(parsedCompanyKey.FindByPredicate) .SplitSelect(CompanyProjectors.SplitSelectDetail()) .FirstOrDefault(); if(companyResult == null) { return new InvalidResult<ICompanyDetailReturn>(null, string.Format(UserMessages.CompanyNotFound, companyKey)); } return new SuccessResult<ICompanyDetailReturn>(companyResult); }