// Constructor used to map from MaturityDataBaseModel public MaturityDataModel(MaturityDataBaseModel maturityDataBaseModel) : base() { PolicyNumber = maturityDataBaseModel.PolicyNumber; PolicyStartDate = maturityDataBaseModel.PolicyStartDate; Premiums = maturityDataBaseModel.Premiums; Membership = maturityDataBaseModel.Membership; DiscretionaryBonus = maturityDataBaseModel.DiscretionaryBonus; UpliftPercentage = maturityDataBaseModel.UpliftPercentage; }
public MaturityDataModel CreateModelFromBaseAndPopulateValues(MaturityDataBaseModel baseModel) { // Logic for mapping fields has been moved from here into the MaturityDataModel constructor MaturityDataModel model = new MaturityDataModel(baseModel); // PolicyTypeService is used populate values in accordance with rules that relate to the relevant policy type. _policyTypeServ.PopulateValues(model); return(model); }
public MaturityDataModel CreateModelFromBaseModel(MaturityDataBaseModel item) { // Convert to model containing additional derived/calculated fields return(new MaturityDataModel { PolicyNumber = item.PolicyNumber, PolicyStartDate = item.PolicyStartDate, Premiums = item.Premiums, Membership = item.Membership, DiscretionaryBonus = item.DiscretionaryBonus, UpliftPercentage = item.UpliftPercentage }); }
private MaturityDataBaseModel ConvertCsvValuesToModel(string[] values) { string policy_number = values[0]; string policy_start_date = values[1]; string premiums = values[2]; string membership = values[3]; string discretionary_bonus = values[4]; string uplift_percentage = values[5]; MaturityDataBaseModel maturityData = new MaturityDataBaseModel { PolicyNumber = policy_number, PolicyStartDate = DateTime.Parse(policy_start_date), Premiums = int.Parse(premiums), Membership = membership.ToUpper() == "Y" ? true : false, DiscretionaryBonus = decimal.Parse(discretionary_bonus), UpliftPercentage = decimal.Parse(uplift_percentage) }; return(maturityData); }
public IEnumerable <MaturityDataBaseModel> GetMaturityData() { // Check CSV file exists if (!File.Exists(csvPath)) { throw new Exception(string.Format("Please ensure that {0} is in the {1} folder", csvFilename, csvFolder)); } List <MaturityDataBaseModel> maturityDataList = new List <MaturityDataBaseModel>(); // Load CSV file into StreamReader using (var sr = new StreamReader(csvPath)) { int count = 1; // Iterate through lines of CSV while (!sr.EndOfStream) { var line = sr.ReadLine(); // Skip the first line containing the column headers if (count > 1) { // Split CSV line into string array var values = line.Split(','); // Convert CSV values to MaturityDataBaseModel MaturityDataBaseModel maturityData = ConvertCsvValuesToModel(values); // Add to list maturityDataList.Add(maturityData); } count++; } } return(maturityDataList); }