public IQueryable <DocumentResolutionVM> Select(long documentId, long?id = null)
        {
            Expression <Func <DocumentResolution, bool> > idSearch = x => x.DocumentId == documentId;

            if (id > 0)
            {
                idSearch = x => x.Id == id;
            }
            return(repo.AllReadonly <DocumentResolution>()
                   .Include(x => x.JudgeDecisionLawunit)
                   .Include(x => x.ResolutionType)
                   .Include(x => x.ResolutionState)
                   .Include(x => x.Court)
                   .Where(idSearch)
                   .ProjectTo <DocumentResolutionVM>(DocumentResolutionVM.GetMapping())
                   //.Select(x => new DocumentResolutionVM
                   //{
                   //    Id = x.Id,
                   //    DocumentId = x.DocumentId,
                   //    ResolutionTypeId = x.ResolutionTypeId,
                   //    ResolutionTypeName = x.ResolutionType.Label,
                   //    JudgeName = x.JudgeDecisionLawunit.FullName,
                   //    JudgeUserId = x.JudgeDecisionUserId,
                   //    RegNumber = x.RegNumber,
                   //    RegDate = x.RegDate,
                   //    StateName = x.ResolutionState.Label,
                   //    CourtId = x.CourtId,
                   //    CourtName = x.Court.Label,
                   //    CourtCity = x.Court.CityName
                   //})
                   .AsQueryable());
        }
        public IQueryable <DocumentResolutionVM> Select(DocumentResolutionFilterVM filter)
        {
            filter.NormalizeValues();

            return(repo.AllReadonly <DocumentResolution>()
                   .Include(x => x.JudgeDecisionLawunit)
                   .Include(x => x.ResolutionType)
                   .Include(x => x.ResolutionState)
                   .Include(x => x.Court)
                   .Include(x => x.Document)
                   .ThenInclude(x => x.DocumentType)
                   .Where(x => x.CourtId == userContext.CourtId)
                   .Where(x => x.RegDate != null)
                   .Where(x => x.RegDate >= (filter.DateFrom.ForceStartDate() ?? x.RegDate) && x.RegDate <= (filter.DateTo.ForceEndDate() ?? x.RegDate))
                   .Where(x => x.RegNumber == (filter.ResolutionNumber ?? x.RegNumber))
                   .Where(x => x.JudgeDecisionLawunitId == (filter.JudgeId ?? x.JudgeDecisionLawunitId))
                   .Where(x => x.Document.DocumentNumber == (filter.DocumentNumber ?? x.Document.DocumentNumber))
                   .Where(x => x.Document.DocumentDate.Year == (filter.DocumentYear ?? x.Document.DocumentDate.Year))
                   .ProjectTo <DocumentResolutionVM>(DocumentResolutionVM.GetMapping())
                   .AsQueryable());
        }