/// <summary> /// Справка за доказателства в ексел /// </summary> /// <param name="courtId"></param> /// <param name="model"></param> /// <returns></returns> public byte[] CaseEvidenceSpr_ToExcel(int courtId, CaseEvidenceSprFilterVM model) { var caseEvidenceSprs = CaseEvidenceSpr(courtId, model).OrderBy(x => x.DateAccept).ToList(); var htmlTemplate = repo.AllReadonly <HtmlTemplate>() .Where(x => x.Alias.ToUpper() == "Evidence".ToUpper()) .FirstOrDefault(); NPoiExcelService excelService = new NPoiExcelService(htmlTemplate.Content, 0); excelService.rowIndex = (htmlTemplate.XlsDataRow ?? 0) - 1; excelService.InsertList( caseEvidenceSprs, new List <Expression <Func <CaseEvidenceSprVM, object> > >() { x => x.RegNumber, x => x.DateAccept, x => x.FileNumber, x => x.CaseGroupLabel, x => x.CaseNumber, x => x.NamePodsydim, x => x.Description, x => x.MovementsDateSend, x => x.MovementsDateReceive, x => x.Movements } ); return(excelService.ToArray()); }
/// <summary> /// Справка за доказателства /// </summary> /// <returns></returns> public IActionResult CaseEvidenceSpr() { var model = new CaseEvidenceSprFilterVM(); model.DateFrom = new DateTime(DateTime.Now.Year, 1, 1); model.DateTo = new DateTime(DateTime.Now.Year, 12, 31); return(View(model)); }
/// <summary> /// Извлича данни за справка за движения /// </summary> /// <param name="courtId"></param> /// <param name="model"></param> /// <returns></returns> private IQueryable <CaseEvidenceSprVM> CaseEvidenceSpr(int courtId, CaseEvidenceSprFilterVM 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 <CaseEvidence, bool> > dateSearch = x => true; if (model.DateFrom != null || model.DateTo != null) { dateSearch = x => x.DateAccept.Date >= dateFromSearch.Date && x.DateAccept.Date <= dateToSearch.Date; } Expression <Func <CaseEvidence, bool> > regNumberSearch = x => true; if (model.FromNumber != null || model.ToNumber != null) { regNumberSearch = x => (x.RegNumberValue ?? 0) >= (model.FromNumber ?? 1) && (x.RegNumberValue ?? 0) <= (model.ToNumber ?? int.MaxValue); } var caseEvidenceSprVMs = repo.AllReadonly <CaseEvidence>() .Where(x => x.Case.CourtId == courtId && x.DateExpired == null) .Where(x => x.EvidenceTypeId != NomenclatureConstants.EvidenceType.Electronically) .Where(regNumberSearch) .Where(dateSearch) .Select(x => new CaseEvidenceSprVM() { Id = x.Id, CaseId = x.CaseId, CaseNumber = (x.Case != null) ? x.Case.RegNumber + "/" + x.Case.RegDate.ToString("dd.MM.yyyy") : string.Empty, CaseGroupLabel = x.Case.CaseType.Label, EvidenceTypeLabel = (x.EvidenceType != null) ? x.EvidenceType.Label : string.Empty, RegNumber = x.RegNumber, FileNumber = x.FileNumber ?? string.Empty, DateAccept = x.DateAccept, Description = (x.Description != null) ? x.Description : string.Empty, EvidenceStateLabel = (x.EvidenceState != null) ? x.EvidenceState.Label : string.Empty }) .ToList(); foreach (var caseEvidence in caseEvidenceSprVMs) { caseEvidence.NamePodsydim = GetCasePersonsRightSide(caseEvidence.CaseId); var caseEvidenceMovementVMs = CaseEvidenceMovement_Select(caseEvidence.Id).ToList(); caseEvidence.Movements = GetEvidenceMovements(caseEvidenceMovementVMs); caseEvidence.MovementsDateSend = GetEvidenceMovementsDateSendOrReciveOtherInstitution(caseEvidenceMovementVMs, true); caseEvidence.MovementsDateReceive = GetEvidenceMovementsDateSendOrReciveOtherInstitution(caseEvidenceMovementVMs, false); } return(caseEvidenceSprVMs.AsQueryable()); }
public IActionResult CaseEvidenceSpr(CaseEvidenceSprFilterVM model) { var xlsBytes = service.CaseEvidenceSpr_ToExcel(userContext.CourtId, model); return(File(xlsBytes, System.Net.Mime.MediaTypeNames.Application.Rtf, "Spravka.xlsx")); }