public ActionResult TADADetails(string TADAYearMonth, string employeeID) { var TADAEntryMonth = TADAYearMonth.Substring(4, 2);; DateTime dateFrom = DateTime.Now, dateTo = DateTime.Now; if (string.IsNullOrEmpty(TADAEntryMonth)) { dateFrom = Helper.MonthStartDate(DateTime.Now); dateTo = Helper.MonthEndDate(DateTime.Now); } else { if (DateTime.Now.Month < Convert.ToInt32(TADAEntryMonth)) { dateFrom = Helper.MonthStartDateFromMonthNumber(Convert.ToInt32(TADAEntryMonth), new DateTime(DateTime.Now.Year - 1, Convert.ToInt32(TADAEntryMonth), 1)); dateTo = Helper.MonthEndDateFromMonthNumber(Convert.ToInt32(TADAEntryMonth), new DateTime(DateTime.Now.Year - 1, Convert.ToInt32(TADAEntryMonth), 1)); } else { dateFrom = Helper.MonthStartDateFromMonthNumber(Convert.ToInt32(TADAEntryMonth), DateTime.Now); dateTo = Helper.MonthEndDateFromMonthNumber(Convert.ToInt32(TADAEntryMonth), DateTime.Now); } } return(View(new GridModel <TADADetails> { Data = hrmsData.ReadTADADetails(dateFrom, dateTo, employeeID) })); }