public async Task <IActionResult> ViewTransaction(PaymentModelVM model, string returnUrl = null) { try { var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; var returnmodel = PaymentManager.ViewTransaction(_context, model, userId); //if (!User.IsInRole("Admin")) { // throw new Exception("Only Transaction Initiator can verify transaction"); //} ViewData["ShowVerify"] = false; return(RedirectToAction("ViewTransaction", new { id = returnmodel.paymentModel.Id })); } catch (Exception ex) { ViewData["Error"] = "There was an error in Viewing transaction. " + ex.Message; return(RedirectToAction("ViewTransaction", new { id = model.Id })); } }
public static VM.PaymentModelVM ViewTransaction(ApplicationDbContext _context, int Id, string userId) { var PM = new PaymentModelVM(); PM.Id = Id; PM.BlobUri = ConfigurationManager.GetAppSetting("BlobUri"); PM.SAS = ConfigurationManager.GetAppSetting("SAS"); PM.Container = ConfigurationManager.GetAppSetting("Container"); var temp = _context.Payments.Where(p => p.Id == Id).Include(p => p.Sender).Include(p => p.Receiver).FirstOrDefault(); PM.paymentModel = temp; if (PM.paymentModel == null) { throw new Exception("Payment not found"); } if (PM.paymentModel.SenderIdNew == userId) { PM.Sender = true; } if (PM.paymentModel.ReceiverId == userId) { PM.Receiver = true; } if (PM.paymentModel.ReceiverId == userId || PM.paymentModel.SenderIdNew == userId) { if (PM.paymentModel.SenderIdNew == userId && PM.paymentModel.TxStatus == Common.TxStatusPending) { PM.ShowVerify = true; } } return(PM); }
public static VM.PaymentModelVM ViewTransaction(ApplicationDbContext _context, PaymentModelVM PM, string userId) { var modeldata = _context.Payments.Where(p => p.Id == PM.paymentModel.Id).Include(p => p.Sender).Include(p => p.Receiver).FirstOrDefault(); if (modeldata.ReceiverId == userId) { // var payment = _context.Payments.Where(p => p.ReceiverId == userId).FirstOrDefault(); if (PM.paymentModel.ReceiverAttachment != modeldata.ReceiverAttachment) { modeldata.ReceiverAttachment = PM.paymentModel.ReceiverAttachment; } if (PM.paymentModel.ReceiverComment != modeldata.ReceiverComment) { modeldata.ReceiverComment = PM.paymentModel.ReceiverComment; } _context.Payments.Update(modeldata); _context.SaveChanges(); } if (modeldata.SenderIdNew == userId) { // var payment = _context.Payments.Where(p => p.SenderId == userId).FirstOrDefault(); if (PM.paymentModel.SenderAttachment != modeldata.SenderAttachment) { modeldata.SenderAttachment = PM.paymentModel.SenderAttachment; } if (PM.paymentModel.SenderComment != modeldata.SenderComment) { modeldata.SenderComment = PM.paymentModel.SenderComment; } if (PM.paymentModel.TxStatus == Common.TxStatusVerified) { modeldata.TxStatus = Common.TxStatusVerified; } _context.Payments.Update(modeldata); _context.SaveChanges(); } return(PM); }