public async Task <IActionResult> PutPaymentTb(int id, PaymentTb paymentTb) { if (id != paymentTb.Id) { return(BadRequest()); } _context.Entry(paymentTb).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PaymentTbExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <PaymentTb> > PostPaymentTb(PaymentTb paymentTb) { _context.PaymentTbs.Add(paymentTb); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPaymentTb", new { id = paymentTb.Id }, paymentTb)); }
public async Task <CreatePaymentDto> Handle(CreatePayment request, CancellationToken cancellationToken) { var notificationList = _context.payments.ToList(); var paydata = new PaymentTb() { Payment_type = request.Data.Attributes.Payment_type, gross_amout = request.Data.Attributes.gross_amout, Order_id = request.Data.Attributes.Order_id }; await _context.SaveChangesAsync(); var target = new TargetCommand() { Id = 3123, Email_destination = "*****@*****.**" }; PostCommand command = new PostCommand() { Title = "this is simple", Message = "dont judge me", Type = "email", From = 1, Targets = new List <TargetCommand>() { target } }; var attributes = new Data <PostCommand>() { Attributes = command }; var httpContent = new RequestData <PostCommand>() { Data = attributes }; var jsonObj = JsonConvert.SerializeObject(httpContent); var factory = new ConnectionFactory() { HostName = "localhost" }; using (var connection = factory.CreateConnection()) using (var channel = connection.CreateModel()) { channel.ExchangeDeclare("userDataExchange", "fanout"); channel.QueueDeclare("notification", true, false, false, null); channel.QueueBind("notification", "userDataExchange", string.Empty); var body = Encoding.UTF8.GetBytes(jsonObj); channel.BasicPublish( exchange: "userDataExchange", routingKey: "", basicProperties: null, body: body ); Console.WriteLine("User data has been forwarded"); } return(new CreatePaymentDto { Success = true, Message = " successfully created", }); }