public ResponseEntityVM FindBy(Expression <Func <PolicyModel, bool> > predicate) { try { var coverateTypeCodes = ((List <CodeVM>)_codeService.GetCoverageTypeCodes().Result).ToList(); var riskTypeCodes = ((List <CodeVM>)_codeService.GetRiskTypeCodes().Result).ToList(); var policyList = _repository.FindBy(predicate).Where(x => x.DeleteDate.Equals(null)).ToList().Select(x => new PolicyVM() { PolicyID = x.PolicyID, CoveragePercentage = x.CoveragePercentage, CoverageTypeID = x.CoverageTypeID, CoverageType = coverateTypeCodes.Where(y => y.CodeID.Equals(x.CoverageTypeID)).FirstOrDefault().Code, Description = x.Description, Name = x.Name, Price = x.Price, RiskTypeID = x.RiskTypeID, RiskType = riskTypeCodes.Where(y => y.CodeID.Equals(x.RiskTypeID)).FirstOrDefault().Code, CoverageTerm = x.CoverageTerm } ).ToList(); return(new ResponseEntityVM() { StatusCode = System.Net.HttpStatusCode.OK, Result = policyList }); } catch (Exception ex) { return(new ResponseEntityVM() { StatusCode = System.Net.HttpStatusCode.InternalServerError, Message = $"There was an error getting the Policies: {ex.Message}" }); } }
public async Task <IHttpActionResult> GetCodes(string filter) { switch (filter) { case "COVERAGE": return(Result(await Task.FromResult(_service.GetCoverageTypeCodes()))); case "POLICY": return(Result(await Task.FromResult(_service.GetPolicyStatusCodes()))); case "RISK": return(Result(await Task.FromResult(_service.GetRiskTypeCodes()))); case "ASSIGNMENT": return(Result(await Task.FromResult(_service.GetAssignmentStatusCodes()))); default: return(Result(new Domain.ViewModel.ResponseEntityVM() { StatusCode = System.Net.HttpStatusCode.NotFound })); } }