public IActionResult Calculator(CalculatorViewModel model) { if (model != null) { var calService = new CalculatorService(); var record = (IList <EntryDepart>)model.EntryDepartRecord; var resultMonths = calService.CalculateResult(ref record, model.VisaStartDate.Value, model.VisaEndDate.Value); var formattedEntryDepartRecord = new List <dynamic>(); if (record != null) { record.ToList().ForEach(edr => { formattedEntryDepartRecord.Add(new { EntryDate = edr.EntryDate.ToString("dd/MM/yyyy"), DepartDate = edr.DepartDate.Value.ToString("dd/MM/yyyy") }); }); } return(Json(new { Result = true, Data = new { ResultMonths = resultMonths, EntryDepartRecord = formattedEntryDepartRecord } })); } else { return(Json(new { Result = false })); } }