Example #1
0
        public async Task <ActionResult> BatchDownload([FromQuery] string ids)
        {
            using (var ms = new MemoryStream())
            {
                if (!string.IsNullOrWhiteSpace(ids))
                {
                    using (var archive = new ZipArchive(ms, ZipArchiveMode.Create, true))
                    {
                        using (var dataAccess = new MasterSideLetterDataAccess(_connectionStrings.MasterSideLetterDb))
                        {
                            foreach (var id in ids.Split(','))
                            {
                                var sideLetter = await dataAccess.GetFundInvestorSideLetterAsync(Convert.ToInt32(id));

                                if (sideLetter?.Name != null && sideLetter.Content != null)
                                {
                                    var zipEntry = archive.CreateEntry(sideLetter.Name);
                                    using (var zipEntryStream = zipEntry.Open())
                                    {
                                        zipEntryStream.Write(sideLetter.Content);
                                    }
                                }
                            }
                        }
                    }
                }
                return(File(ms.ToArray(), "application/zip", "SideLetterArchive.zip"));
            }
        }
Example #2
0
        public async Task <ActionResult> DownloadSideLetter(int id)
        {
            using (var dataAccess = new MasterSideLetterDataAccess(_connectionStrings.MasterSideLetterDb))
            {
                var document = await dataAccess.GetFundInvestorSideLetterAsync(id);

                return(File(document.Content, System.Net.Mime.MediaTypeNames.Application.Octet, document.Name));
            }
        }