public Contract CreateContract(ContractDetails contractDetails) { Contract contract = new Contract(); try { Random r = new Random(); CoveragePlan coveragePlan = GetCoveragePlan(contractDetails); int age = GetAge(contractDetails.CustomerDateOfBirth); int netPrice = GetNetPrice(coveragePlan.CoveragePlanType.ToUpper(), age, contractDetails.CustomerGender); if (coveragePlan != null) { contract = new Contract { ContractId = "LIC" + r.Next().ToString(), CustomerName = contractDetails.CustomerName, CustomerAddress = contractDetails.CustomerAddress.City, CustomerGender = contractDetails.CustomerGender, CustomerCountry = contractDetails.CustomerAddress.Country, CustomerDateofbirth = contractDetails.CustomerDateOfBirth, SaleDate = contractDetails.SaleDate, CoveragePlan = coveragePlan.CoveragePlanType, NetPrice = netPrice }; _InsuranceRepository.Add(contract); } } catch (Exception Ex) { //Log exception } return(contract); }