public ActionResult EligibilityUploadDetails(EligibilityUploadListModelFilter filter = null, int pageNumber = 1)
        {
            try
            {
                int totalRecords;
                var model = _eligibilityUploadService.GetEligibilityUploadDetails(pageNumber, _pageSize, filter, out totalRecords) ??
                            new EligibilityUploadListModel();

                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);

                return(View(model));
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("EligibilityUpload Details\nException occurred"));
                _logger.Error(string.Format("Exception message: {0}\n\tStackTrace:{1}", ex.Message, ex.StackTrace));

                var model = new EligibilityUploadListModel {
                    Filter = filter
                };
                return(View(model));
            }
        }
Пример #2
0
        public EligibilityUploadListModel GetEligibilityUploadDetails(int pageNumber, int pageSize, EligibilityUploadListModelFilter filter, out int totalRecords)
        {
            var eligibilityUploads = (IReadOnlyCollection <EligibilityUpload>)_eligibilityUploadRepository.GetByFilter(pageNumber, pageSize, filter, out totalRecords);

            if (eligibilityUploads == null || !eligibilityUploads.Any())
            {
                return(null);
            }

            var successfileIds = eligibilityUploads.Select(s => s.FileId).ToArray();
            var failedfileIds  = eligibilityUploads.Where(x => x.LogFileId.HasValue).Select(s => s.LogFileId.Value).ToArray();
            var fileIds        = successfileIds.Concat(failedfileIds).ToArray();
            var accountIds     = eligibilityUploads.Select(x => x.AccountId).ToArray();
            var accounts       = _corporateAccountRepository.GetByIds(accountIds);

            IEnumerable <FileModel> fileModels = null;

            if (fileIds != null && fileIds.Any())
            {
                var files = _fileRepository.GetByIds(fileIds);

                if (files != null && files.Any())
                {
                    fileModels = GetFileModelFromFile(files, _mediaRepository.GetEligibilityUploadMediaFileLocation());
                }
            }
            var eligibilityUploadByIds = eligibilityUploads.Select(c => c.UploadedBy).ToArray();
            IEnumerable <OrderedPair <long, string> > uploadedbyAgentNameIdPair = null;

            uploadedbyAgentNameIdPair = _organizationRoleUserRepository.GetNameIdPairofUsers(eligibilityUploadByIds).ToArray();

            return(_eligibilityUploadListModelFactory.Create(fileModels, eligibilityUploads, uploadedbyAgentNameIdPair, accounts));
        }
Пример #3
0
        public IEnumerable <EligibilityUpload> GetByFilter(int pageNumber, int pageSize, EligibilityUploadListModelFilter filter, out int totalRecords)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);

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

                    var entities = linqMetaData.EligibilityUpload.OrderByDescending(p => p.UploadTime).TakePage(pageNumber, pageSize).Select(x => x).ToArray();
                    return(Mapper.Map <IEnumerable <EligibilityUploadEntity>, IEnumerable <EligibilityUpload> >(entities));
                }
                else
                {
                    var query = (from c in linqMetaData.EligibilityUpload 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(Mapper.Map <IEnumerable <EligibilityUploadEntity>, IEnumerable <EligibilityUpload> >(entities));
                }
            }
        }