public IActionResult GetApproved(Guid Id)
        {
            var result = _IApproveOfAuthorityThatOrderCommissionsService.GetApproved(Id);

            if (!result.IsSuccess)
            {
                return(BadRequest(result));
            }

            return(Ok(result));
        }
Exemple #2
0
        public ServiceResult <byte[]> PrintAccountFor(Guid solicitationId)
        {
            var newDirectory = Path.Combine(StaticFilesDirectory, "Reports", "Rendición.rdl");
            var files        = new FileInfo(newDirectory);

            var notif = new ServiceResult <byte[]>();

            if (!files.Exists)
            {
                notif.AddError("Error", "El Reporte no fue encontrado.");
                return(notif);
            }
            var solic = _solicitationSubsidyService.GetByIdSubsidy(solicitationId).Response;

            if (solic == null)
            {
                notif.AddError("Error", "La solicitud no existe.");
                return(notif);
            }
            var rv = new reportingNameSpace.LocalReport(newDirectory);

            rv.AddDataSource("SolicitationDataset", new List <FindByIdSolicitationSubsidyDto>()
            {
                solic
            });
            rv.AddDataSource("UserDataSet", new List <UserDto>()
            {
                solic.User
            });
            rv.AddDataSource("SolicitationStateDataSet", new List <SolicitationStateDto>()
            {
                solic.SolicitationStates.FirstOrDefault(x => x.FileNumber != null)
            });
            rv.AddDataSource("OrganismDataSet", new List <OrganismBaseDto>()
            {
                new OrganismBaseDto()
                {
                    Name = _context.Distributions.FirstOrDefault(x => x.Id == solic.User.DistributionId).Name
                }
            });
            rv.AddDataSource("DestinationDataSet", solic.Destinies);
            solic.Expenditures.Add(new ExpenditureFromSolicitationSubsidyByIdDto()
            {
                SupportingDateTime  = new Nullable <DateTime>(),
                OrderNumber         = new Nullable <int>(),
                Description         = solic.Motive,
                AccountedForAmount  = new Nullable <decimal>(),
                ExpenditureTypeName = ""
            });
            rv.AddDataSource("ExpenditureDataSet", solic.Expenditures);
            var adv = solic.Destinies.Sum(x => x.Days * x.PercentageCodeLiquidation * x.AdvanceCategory) +
                      solic.Expenditures.Where(x => x.IsRequested).Sum(j => j.Amount);
            var supp = solic.Destinies.Sum(x => x.DaysPay * x.PercentageCodeLiquidation * x.AdvanceCategory) +
                       solic.Expenditures.Sum(j => j.AccountedForAmount ?? 0);

            var newCommon = new ReportDto()
            {
                Advance                = adv,
                SupportingPresent      = supp,
                Total                  = adv - supp,
                LegalRulingDescription = solic.LegalRulingDescription == null ? "" : solic.LegalRulingDescription
            };

            newCommon.TotalBool();
            var secondCommon = new ReportDto()
            {
                Advance           = adv,
                SupportingPresent = supp,
                Total             = adv - supp
            };

            rv.AddDataSource("CommonDataSet", new List <ReportDto>()
            {
                newCommon,
                secondCommon
            });

            var result1     = _iApproveOfAuthorityThatOrderCommissionsService.GetApproved(solic.Id);
            var listApprove = new VerificationCommissionDto();

            listApprove.SetValues(result1.Response);
            rv.AddDataSource("VerificationCommissionDataSet", new List <VerificationCommissionDto>()
            {
                listApprove
            });

            rv.AddDataSource("ObservationList", new List <ObservationDto>(solic.Observations));
            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);

            var result = rv.Execute(reportingNameSpace.RenderType.Pdf);

            return(new ServiceResult <byte[]>(result.MainStream));
        }