public async Task <IActionResult> PutDPayment(int id, DPayment dPayment) { if (id != dPayment.Id) { return(BadRequest()); } _context.Entry(dPayment).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DPaymentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <DPayment> > PostNewDPayment(PaymentDTO dto) { try { var newPayment = new DPayment() { CustomerId = dto.CustomerId, OrderId = dto.OrderId, TotalAmount = dto.Amount }; _context.Payment.Add(newPayment); await _context.SaveChangesAsync(); var paymentID = newPayment.Id; return(Ok(new { id = paymentID })); } catch (Exception ex) { return(NotFound()); } }
/// <summary> /// Initiates the Payment Authorization Sequence. /// </summary> public bool PaymentAsync(double amount) { expectedAmount = amount; if (isInitialized) { using (FileStream stream = new FileStream(@"Artema.log", FileMode.Append, FileAccess.Write)) { StreamWriter writer = new StreamWriter(stream); writer.WriteLine(string.Format(@"Datetime {0} -- PaymentAsync invoked with Amount = {1}.", DateTime.Now, amount)); writer.Flush(); writer.Close(); } // Initialize delegate methods only once in application life cycle. paymentMethod = new DPayment(this.Payment); // Initiating Card Payment. paymentMethod.BeginInvoke(amount, null, null); } return false; }