コード例 #1
0
        public async Task <IActionResult> Update(PaymentsBatch paymentsBatch)
        {
            var pc = await _ercContext.PaymentBatches.FindAsync(paymentsBatch.Id);

            if (pc is null)
            {
                return(NotFound());
            }

            _ercContext.Entry(pc).CurrentValues.SetValues(paymentsBatch);
            await _ercContext.SaveChangesAsync();

            return(Ok());
        }
コード例 #2
0
        public async Task <IActionResult> Add([FromForm] NewPaymentsBatch paymentBatch)
        {
            var paymentChannel = await _mediator.Send(new GetPaymentChannelById(paymentBatch.PaymentChannelId));

            if (paymentChannel is null)
            {
                return(BadRequest("Payment channel not found!"));
            }

            var paymentList = new List <Domain.Payments.Payment>();

            if (paymentBatch.UploadFile != null)
            {
                var extFile = Path.GetExtension(paymentBatch.UploadFile.FileName);
                if (extFile == ".dbf")
                {
                    paymentList = new PaymentsDbfParser(_ercContext, _branchOfficeService).Parser(paymentBatch.BranchOfficeId, paymentChannel, paymentBatch.UploadFile);
                }
                else if (extFile == ".xls" || extFile == ".xlsx")
                {
                    return(BadRequest("Excel files not yet supported"));
                }
            }

            var payBatch = new PaymentsBatch(
                paymentBatch.BranchOfficeId,
                paymentBatch.PaymentChannelId,
                paymentBatch.IncomingDate,
                paymentList
                );

            _ercContext.PaymentBatches.Add(payBatch);
            await _ercContext.SaveChangesAsync();

            return(await GetOne(payBatch.Id));
        }