I use jQuery datatable in my project. The code for getting all data from database is:
var pm = _pmRepository.GetAllPMs().Reverse().ToList();
The repository pattern used for this purpose is:
public IEnumerable<PM> GetAllPMs()
{
return context.PMs;
}
My database has some columns with DateTime format. I want to convert date format. I have written a class that can do this:
public class DateTimeConverter
{
PersianCalendar pc = new PersianCalendar();
public string DateConverter(string inputDate)
{
DateTime d = DateTime.Parse(inputDate);
string[] convertedDateString = new string[3];
convertedDateString[0] = pc.GetYear(d).ToString();
convertedDateString[1] = pc.GetMonth(d).ToString();
convertedDateString[2] = pc.GetDayOfMonth(d).ToString();
string currentConvertedDate = string.Format("{0}/{1}/{2}",
convertedDateString[0], convertedDateString[1],
convertedDateString[2]);
return currentConvertedDate;
}
}
How can I use my date converter before sending data to datatable?