public IActionResult Index() { var payRecords = _payComputationServie.GetAll().Select(pay => new PaymentRecordIndexViewModel { Id = pay.Id, EmployeeId = pay.EmployeeId, FullName = pay.FullName, PayDate = pay.PayDate, PayMonth = pay.PayMonth, TaxYearId = pay.TaxYearId, Year = _payComputationServie.GetTaxYearById(pay.TaxYearId).YearOfTax, TotalEarnings = pay.TotalEarnings, TotalDeduction = pay.TotalDeduction, Employee = pay.Employee }); return(View(payRecords)); }
public IActionResult Index() { var payRecords = _payComputationService.GetAll().Select(pay => new PaymentRecordIndexViewModel { Id = pay.Id, EmployeeId = pay.EmployeeId, FullName = pay.FullName, PayDate = pay.PayDate, PayMonth = pay.PayMonth, TaxYearId = pay.TaxYearId, Year = _payComputationService.GetTaxYearById(pay.TaxYearId).YearOfTax, //We need to write a method in the PayComputationService and pass this id to that method TotalEarnings = pay.TotalEarnings, TotalDeduction = pay.TotalDeduction, NetPayment = pay.NetPayment, Employee = pay.Employee, }); return(View(payRecords)); //We need a view model for this index, right click models add new model }
public async Task <IActionResult> Index() { var payRecords = await _payComputationService.GetAll(); var payRecordsToView = payRecords.Select(pay => new PaymentRecordIndexViewModel { Id = pay.Id, EmployeeId = pay.EmployeeId, FullName = pay.FullName, PayDate = pay.PayDate, PayMonth = pay.PayMonth, TaxYearId = pay.TaxYearId, Year = _payComputationService.GetTaxYearById(pay.TaxYearId).Result.YearOfTax, TotalEarnings = pay.TotalEarnings, TotalDeduction = pay.TotalDeduction, NetPayment = pay.NetPayment, Employee = pay.Employee }); return(View(payRecordsToView)); }