コード例 #1
0
        public ActionResult Receipt()
        {
            var p = new PilatesReceipt
            {
                CustomerFullName  = "Pepe Sanchez",
                PointOfSaleNumber = "00002",
                ReceiptNumber     = "00000012",

                ReceiptConcepts = new List <ReceiptConcept>
                {
                    new ReceiptConcept
                    {
                        Amount      = 500,
                        Description = "Pilates - Septiembre"
                    },
                    new ReceiptConcept
                    {
                        Amount      = 500,
                        Description = "Pilates - Octubre"
                    },
                }
            };

            p.Create();

            return(Ok());
        }
コード例 #2
0
        public ActionResult Receipt(long feeId)
        {
            using (var context = _repository.GetContext())
            {
                var fee = _repository.GetByIdInclude(feeId, IncludeExpressions);
                context.Attach(fee);

                string number = fee.Movement.ReceiptNumber;

                if (string.IsNullOrEmpty(number))
                {
                    var receiptNumber = _receiptNumberRepo.GetByQuery(x => x.ReceiptTypeId == (long)ReceiptTypeEnum.FeeReceipt).SingleOrDefault();
                    receiptNumber.IncrementNumber();
                    _receiptNumberRepo.Update(receiptNumber);

                    fee.Movement.SetReceiptNumber(receiptNumber.LastNumberFormatted);

                    _repository.Update(fee);

                    number = receiptNumber.LastNumberFormatted;
                }

                var receipt = new PilatesReceipt
                {
                    CustomerFullName  = fee.Student.FullName,
                    PointOfSaleNumber = "00002",
                    ReceiptNumber     = number,
                    Date            = fee.Movement.Date.Value,
                    ReceiptConcepts = new List <ReceiptConcept>
                    {
                        new ReceiptConcept
                        {
                            Amount      = fee.Movement.Amount,
                            Description = "Pilates - " + fee.Month.Name
                        }
                    }
                };

                var file = receipt.Create();

                return(File(file, "application/pdf", "Recibo_" + fee.Month.Name + "_" + fee.Student.FullName + ".pdf"));
            }
        }