Пример #1
0
        public async Task <ActionstepDocument> SavePDF([FromBody] SettlementMatterViewModel settlementMatter)
        {
            if (settlementMatter is null)
            {
                throw new System.ArgumentNullException(nameof(settlementMatter));
            }

            var currentUser = await _userManager.GetUserAsync(User);

            var pdfTempFilePath = string.Empty;

            try
            {
                pdfTempFilePath = await _mediator.Send(new SettlementMatterGeneratePDF.SettlementMatterGeneratePDFQuery
                {
                    AuthenticatedUser = currentUser,
                    Matter            = settlementMatter.ToDomainModel()
                });

                return(await _mediator.Send(new ActionstepSavePDF.ActionstepSavePDFCommand
                {
                    OrgKey = settlementMatter.ActionstepOrg,
                    MatterId = settlementMatter.MatterId,
                    FilePath = pdfTempFilePath,
                    AuthenticatedUser = currentUser
                }));
            }
            finally
            {
                if (!System.IO.File.Exists(pdfTempFilePath))
                {
                    System.IO.File.Delete(pdfTempFilePath);
                }
            }
        }
Пример #2
0
        public async Task <SettlementMatterViewModel> GetSettlementMatter(string actionstepOrg, int matterId)
        {
            var currentUser = await _userManager.GetUserAsync(User);

            return(SettlementMatterViewModel.FromDomainModel(await _mediator.Send(new GetSettlementMatter.GetSettlementMatterQuery
            {
                AuthenticatedUser = currentUser,
                MatterId = matterId,
                OrgKey = actionstepOrg
            })));
        }
Пример #3
0
        public async Task <SettlementMatter> SaveSettlementMatter([FromBody] SettlementMatterViewModel settlementMatter)
        {
            if (settlementMatter is null)
            {
                throw new System.ArgumentNullException(nameof(settlementMatter));
            }

            var currentUser = await _userManager.GetUserAsync(User);

            return(await _mediator.Send(new SaveSettlementMatter.SaveSettlementMatterCommand
            {
                AuthenticatedUser = currentUser,
                MatterId = settlementMatter.MatterId,
                OrgKey = settlementMatter.ActionstepOrg,
                Matter = settlementMatter.ToDomainModel()
            }));
        }
Пример #4
0
        public async Task <IActionResult> GeneratePDF([FromBody] SettlementMatterViewModel settlementMatter)
        {
            if (settlementMatter is null)
            {
                throw new System.ArgumentNullException(nameof(settlementMatter));
            }

            var currentUser = await _userManager.GetUserAsync(User);

            var pdfTempFilePath = await _mediator.Send(new SettlementMatterGeneratePDF.SettlementMatterGeneratePDFQuery
            {
                AuthenticatedUser = currentUser,
                Matter            = settlementMatter.ToDomainModel()
            });

            var pdfFileStream    = new FileStream(pdfTempFilePath, FileMode.Open, FileAccess.Read, FileShare.None, 4096, FileOptions.DeleteOnClose);
            var fileStreamResult = new FileStreamResult(pdfFileStream, new MediaTypeHeaderValue("application/pdf"));

            fileStreamResult.FileDownloadName = $"{settlementMatter.SettlementData.MatterDetails.Matter}.pdf";
            return(fileStreamResult);
        }