public ActionResult UploadDetail(MergeCustomerUploadListModelFilter filter = null, int pageNumber = 1)
        {
            try
            {
                int totalRecords;
                var model = _mergeCustomerUploadService.GetMergeCustomerUploadDetails(pageNumber, _pageSize, filter, out totalRecords);


                if (model == null)
                {
                    model = new MergeCustomerUploadListModel();
                }
                model.Filter = filter;

                var currentAction          = ControllerContext.RouteData.Values["action"].ToString();
                Func <int, string> urlFunc =
                    pn =>
                    Url.Action(currentAction,
                               new
                {
                    pageNumber = pn,
                    filter.FromUploadDate,
                    filter.ToUploadDate,
                    filter.UploadedBy
                });

                model.PagingModel = new PagingModel(pageNumber, _pageSize, totalRecords, urlFunc);

                IoC.Resolve <ILogManager>().GetLogger <Global>().Info("Call Upload going to return view @" + DateTime.Now);

                return(View(model));
            }
            catch (Exception ex)
            {
                IoC.Resolve <ILogManager>().GetLogger <Global>().Error(ex.Message);
                IoC.Resolve <ILogManager>().GetLogger <Global>().Error("Call Upload Stack Trace :" + ex.StackTrace);
                var model = new MergeCustomerUploadListModel();
                model.Filter = filter;
                return(View(model));
            }
        }
        public IEnumerable <MergeCustomerUpload> GetByFilter(int pageNumber, int pageSize, MergeCustomerUploadListModelFilter filter, out int totalRecords)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);

                if (filter == null)
                {
                    totalRecords = linqMetaData.MergeCustomerUpload.Count();

                    var entities = linqMetaData.MergeCustomerUpload.OrderByDescending(p => p.UploadTime).TakePage(pageNumber, pageSize).Select(x => x).ToArray();
                    return(AutoMapper.Mapper.Map <IEnumerable <MergeCustomerUploadEntity>, IEnumerable <MergeCustomerUpload> >(entities));
                }
                else
                {
                    var query = (from c in linqMetaData.MergeCustomerUpload select c);

                    if (filter.FromUploadDate != null)
                    {
                        query = (from c in query
                                 where c.UploadTime.Date >= filter.FromUploadDate.Value.Date
                                 select c);
                    }
                    if (filter.ToUploadDate != null)
                    {
                        query = (from c in query
                                 where c.UploadTime.Date <= filter.ToUploadDate.Value.Date
                                 select c);
                    }

                    if (filter.UploadedBy != null && filter.UploadedBy > 0)
                    {
                        query = (from c in query
                                 where c.UploadedBy == filter.UploadedBy
                                 select c);
                    }

                    totalRecords = query.Count();
                    var entities = query.OrderByDescending(p => p.UploadTime).TakePage(pageNumber, pageSize).Select(x => x).ToArray();
                    return(AutoMapper.Mapper.Map <IEnumerable <MergeCustomerUploadEntity>, IEnumerable <MergeCustomerUpload> >(entities));
                }
            }
        }