public IEnumerable <Payslip> GeneratePayslips(IFormFile file) { var payslips = new List <Payslip>(); using (var reader = new StreamReader(file.OpenReadStream())) { while (!reader.EndOfStream) { var line = reader.ReadLine(); var cells = line.Split(','); decimal annualSalary; decimal superRate; if (this.IsFormFileDataValid(cells, out annualSalary, out superRate)) { var firstName = cells[0]; var lastName = cells[1]; var paymentStartDate = cells[4]; var payslip = new Payslip(); payslip.Name = _taxCalculatorService.GetFullName(firstName, lastName); payslip.PayPeriod = paymentStartDate; payslip.GrossIncome = _taxCalculatorService.CalculateGrossIncome(annualSalary); payslip.IncomeTax = _taxCalculatorService.CalculateIncomeTax(annualSalary); payslip.NetIncome = _taxCalculatorService.CalculateNetIncome(payslip.GrossIncome, payslip.IncomeTax); payslip.Super = _taxCalculatorService.CalculateSuper(payslip.GrossIncome, superRate); payslips.Add(payslip); } } } return(payslips); }