Beispiel #1
0
        public ActionResult DisplayPDFData(PDFData pdfData)
        {
            if (pdfData == null)
            {
                return(RedirectToAction("CreatePDF"));
            }

            return(View("CreatePDF", pdfData));
        }
Beispiel #2
0
        public ActionResult CreatePDF(PDFData pdfData, HttpPostedFileBase file)
        {
            var pdf = _pdfCaller.GetFileBytes(file);

            if (pdf == null)
            {
                return(View(pdfData));
            }



            return(new FileContentResult(_pdfCaller.GetPDF(pdfData, pdf), "application/pdf"));
        }
        public ActionResult <string> StorePDF([FromForm] PDFData formData)
        {
            string Base64 = formData.Base64;

            byte[] byteArray = Convert.FromBase64String(Base64);

            //Calculating Bill profit after dedcution of Discount %

            int Accurateprofit = formData.Billprofit - formData.Deduction;

            BillsDatasTE Billdata = new BillsDatasTE()
            {
                Billnumber    = formData.Billnumber,
                Billamount    = formData.Billamount,
                Deduction     = formData.Deduction,
                Payableamount = formData.Payableamount,
                Billprofit    = Accurateprofit,
                Billbytearray = byteArray,
                Billdate      = DateTime.Now,
                Ispaid        = false,
                Customerid    = formData.Customerid
            };

            _context.Add(Billdata);
            _context.SaveChanges();

            BillsPendingTE billPending = new BillsPendingTE()
            {
                Pendingamount = formData.Payableamount,
                Billnumber    = formData.Billnumber,
                Iscompleted   = false,
                Customerid    = formData.Customerid,
            };

            _context.Add(billPending);
            _context.SaveChanges();

            int maxID = _context.billscollections.Max(x => x.Id);

            byte[] byteArray2 = _context.billscollections.Single(x => x.Id == maxID).Billbytearray;
            string Base642    = Convert.ToBase64String(byteArray);

            return(Ok(Base642));
        }
        public byte[] GetPDF(PDFData pdfData, byte[] pdf)
        {
            var _data = new List <PdfField>()
            {
                new PdfField("FirstName", pdfData.FirstName),
                new PdfField("MiddleInitial", pdfData.MiddleInitial),
                new PdfField("LastName", pdfData.LastName),
                new PdfField("Street", pdfData.Street),
                new PdfField("City", pdfData.City),
                new PdfField("State", pdfData.State),
                new PdfField("Zip", pdfData.Zip),

                new PdfField("Active", pdfData.Active ? "Yes": string.Empty),
                new PdfField("CustomerSince", stripDelimter(pdfData.CustomerSince, "/"), pdfData.CustomerSince),
                new PdfField("PointBalance", stripDelimter(pdfData.PointBalance, ","), pdfData.PointBalance),
                new PdfField("TIN", stripDelimter(pdfData.TIN, "-"), pdfData.TIN)
            };

            return(PdfMethods.SetData(ImmutableArray.Create <PdfField>(_data.ToArray()), ImmutableArray.Create <byte>(pdf)).ToArray());
        }