Exemple #1
0
        public ListRecordsTmpModel(int dossierId,
                                   int CurrentPage  = 1,
                                   int ItemsPerPage = 20)
        {
            _ItemsPerPage = (ItemsPerPage == 0)?20: ItemsPerPage;
            _CurrentPage  = (CurrentPage == 0) ? 1 : CurrentPage;

            _dossierId   = dossierId;
            _dossierName = _context.dossiers.Find(_dossierId).dossierName;

            List <POCO.importRecordTmp> _listRecordsSess;

            // Getting full list from DB or from Session
            _listRecordsSess = (from
                                rec in _context.sp_getImportRecordTmp(_dossierId)     //_context.importRecordTmps
                                where
                                rec.dossierId == _dossierId
                                select
                                new POCO.importRecordTmp {
                importRecordTmpId = rec.importRecordTmpId,
                dossierId = rec.dossierId,
                revenue = rec.revenue,
                expense = rec.expense,
                comment = rec.comment,
                description = rec.description,
                date = rec.date,
                category = rec.category,
                subcategory = rec.subcategory,
                duplicates = rec.duplicates,
                doubles = rec.doubles
            }).ToList();



            if (!IsPostBack)
            {
                //TODO: Implement a caching system different than Session.
                //Try Object Cache
            }

            // data for paging
            _PagedListRecords    = _listRecordsSess.Skip(_ItemsPerPage * (_CurrentPage - 1)).Take(_ItemsPerPage).ToList();
            _TotalNumberOfPages  = (_listRecordsSess.Count() / _ItemsPerPage);
            _TotalNumberOfPages += ((_listRecordsSess.Count() % _ItemsPerPage) == 0) ? 0 : 1;

            _emptyRecordForEdit = new RecordTmpModel(_dossierId);
        }