Ejemplo n.º 1
0
        public ActionResult Index(int?page, PubIndexModels model)
        {
            Company currentCompany  = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            int     curentPageIndex = page.HasValue ? page.Value - 1 : 0;
            int     pageSize        = 10;
            int     totalRecords    = 0;

            DateTime DateFrom = String.IsNullOrEmpty(model.fromdate) ? DateTime.MinValue : DateTime.ParseExact(model.fromdate, "dd/MM/yyyy", null);
            DateTime DateTo   = String.IsNullOrEmpty(model.todate) ? DateTime.MaxValue : DateTime.ParseExact(model.todate, "dd/MM/yyyy", null);

            if (DateFrom != null && DateTo != null && DateFrom > DateTo)
            {
                Messages.AddErrorMessage("Nhập đúng dữ liệu tìm kiếm theo ngày!");
                DateFrom       = DateTime.MinValue;
                DateTo         = DateTime.MaxValue;
                model.fromdate = model.todate = "";
            }
            int pstatus = (String.IsNullOrEmpty(model.status) ? -1 : Convert.ToInt32(model.status));

            IPublishService pubSrc = IoC.Resolve <IPublishService>();
            IList <Publish> lst    = pubSrc.SearchByDate(currentCompany.id, DateFrom, DateTo, pstatus, curentPageIndex, pageSize, out totalRecords);

            model.PageListPUB = new PagedList <Publish>(lst, curentPageIndex, pageSize, totalRecords);
            return(View(model));
        }