public void GetOrderInfo(OrderDto order) { if (order != null) { PayInfo info = new PayInfo(); info.OrderId = order.OrderId; info.Id = Guid.NewGuid().ToString("N"); info.Money = order.Money; info.stauts = 0; info.CrateTime = DateTime.Now; _payInfoContext.PayInfo.Add(info); _payInfoContext.SaveChanges(); } }
public void PubPay(string id) { using (var tran = _payInfoContext.Database.BeginTransaction()) { PayInfo pay = _payInfoContext.PayInfo.Where(e => e.OrderId == id).FirstOrDefault(); pay.stauts = 1; pay.UpdateTime = DateTime.Now; _payInfoContext.SaveChanges(); tran.Commit(); OrderDto dto = new OrderDto(); dto.OrderId = pay.OrderId; dto.Money = pay.Money; dto.Status = pay.stauts; _publisher.Publish("pay", dto); } }