/// <summary>
        /// Архивирани дела
        /// </summary>
        /// <param name="dateFrom"></param>
        /// <param name="dateTo"></param>
        /// <returns></returns>
        public IActionResult CaseArchive(DateTime?dateFrom, DateTime?dateTo)
        {
            CaseArchiveFilterVM filter = new CaseArchiveFilterVM()
            {
                DateFrom = dateFrom ?? new DateTime(DateTime.Now.Year, 1, 1),
                DateTo   = dateTo ?? DateTime.Now
            };

            SetHelpFile(HelpFileValues.Archive2);
            return(View(filter));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Извличане на данни за дела в архив
        /// </summary>
        /// <param name="courtId"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public IQueryable <CaseArchiveListVM> CaseArchive_Select(int courtId, CaseArchiveFilterVM model)
        {
            DateTime dateFromSearch = model.DateFrom == null?DateTime.Now.AddYears(-100) : (DateTime)model.DateFrom;

            DateTime dateToSearch = model.DateTo == null?DateTime.Now.AddYears(100) : (DateTime)model.DateTo;

            Expression <Func <CaseArchive, bool> > dateSearch = x => true;

            if (model.DateFrom != null || model.DateTo != null)
            {
                dateSearch = x => x.RegDate.Date >= dateFromSearch.Date && x.RegDate.Date <= dateToSearch.Date;
            }

            Expression <Func <CaseArchive, bool> > regNumberSearch = x => true;

            if (string.IsNullOrEmpty(model.RegNumber) == false)
            {
                regNumberSearch = x => x.Case.RegNumber.ToLower().Contains(model.RegNumber.ToLower());
            }

            Expression <Func <CaseArchive, bool> > isDestroySearch = x => true;

            if (model.IsDestroy == true)
            {
                isDestroySearch = x => x.DateDestroy != null;
            }

            return(repo.AllReadonly <CaseArchive>()
                   .Where(x => x.Case.CourtId == courtId)
                   .Where(dateSearch)
                   .Where(regNumberSearch)
                   .Where(isDestroySearch)
                   .Select(x => new CaseArchiveListVM()
            {
                Id = x.Id,
                CaseId = x.Case.Id,
                CaseTypeLabel = x.Case.CaseType.Code,
                CaseStateLabel = x.Case.CaseState.Label,
                CaseRegNumber = x.Case.RegNumber,
                CaseRegDate = x.Case.RegDate,
                RegNumber = x.RegNumber,
                RegDate = x.RegDate,
                BookNumber = x.BookNumber,
                BookYear = x.BookYear,
                StorageYears = x.StorageYears,
                CaseArchiveIndexName = x.CourtArchiveIndex.Label,
                DateDestroy = x.DateDestroy
            })
                   .AsQueryable());
        }
        public IActionResult ListDataCaseArchive(IDataTablesRequest request, CaseArchiveFilterVM model)
        {
            var data = service.CaseArchive_Select(userContext.CourtId, model);

            return(request.GetResponse(data));
        }