public ActionResult Index(int?page, MailsIndexModel model) { Company currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany; int pageIndex = page.HasValue ? page.Value - 1 : 0; int pageSize = 10; int totalRecord = 0; DateTime?FromDate = null; DateTime?ToDate = null; if (!string.IsNullOrWhiteSpace(model.FromSendedDate)) { FromDate = DateTime.ParseExact(model.FromSendedDate, "dd/MM/yyyy", null); } if (!string.IsNullOrWhiteSpace(model.ToSendedDate)) { ToDate = DateTime.ParseExact(model.ToSendedDate, "dd/MM/yyyy", null); } if (FromDate != null && ToDate != null && FromDate > ToDate) { Messages.AddErrorMessage("Nhập đúng dữ liệu tìm kiếm theo ngày!"); FromDate = ToDate = null; model.FromSendedDate = model.ToSendedDate = ""; } IList <SendMail> lstSendMail = _SendmailSvc.SearchByMail(currentCom.id, model.Subject, FromDate, ToDate, model.Status, model.EmailTo, pageIndex, pageSize, out totalRecord); model.PageListMail = new PagedList <SendMail>(lstSendMail, pageIndex, pageSize, totalRecord); return(View(model)); }