public virtual byte[] CreatePayInSlip() { byte[] pdf = new byte[0]; using (var container = new TransactionModelContainer()) { long id = long.Parse(PaymentId); Payment payment = container.Payments.Where(x => x.Id == id).FirstOrDefault(); if (payment != null) { var config = container.Configurations.Where(x => x.Group == "Pay_In").ToList(); PayInSlipReport report = new PayInSlipReport(); report.DataSource = PayInSlipDetail.CreatePayInSlipSource( config.Where(x => x.Name.ToLower() == "companyname").FirstOrDefault().Value1, config.Where(x => x.Name.ToLower() == "companyname").FirstOrDefault().Value2, config.Where(x => x.Name.ToLower() == "companyname").FirstOrDefault().Value3, config.Where(x => x.Name.ToLower() == "taxno").FirstOrDefault().Value1, config.Where(x => x.Name.ToLower() == "accno").FirstOrDefault().Value1, config.Where(x => x.Name.ToLower() == "accno").FirstOrDefault().Value2, config.Where(x => x.Name.ToLower() == "accno").FirstOrDefault().Value3, DateTime.Now.ToString("dd/MM/yyyy"), config.Where(x => x.Name.ToLower() == "servicecode").FirstOrDefault().Value1, payment.CustomerName, payment.PaymentCode, payment.CustomerIdmPartyId.ToString(), payment.RemainingAmount().ToString(ConfigurationManager.Format.Decimal_Format) ); var reportprocess = new ReportProcessor(); var result = reportprocess.RenderReport("PDF", report, null); pdf = result.DocumentBytes; payment.AddPayInSlip(DateTime.Now, payment.CustomerName, pdf, Convert.ToInt32(payment.Id), payment.PaymentCode); container.SaveChanges(); RefreshWhenDomainModelChanged(payment); } else { throw new ArgumentException("PAYMENT_NOT_FOUND"); } } return(pdf); }