public async Task <IActionResult> Edit(string id) { var details = await GetApi().Payment.Get(id); var payment = new EditPaymentVm() { Id = details.Id, Amount = details.Amount, TransactionDate = details.TransactionDate, Description = details.Description, PayerId = details.Payer.Id, SourceId = details.Attempts.OrderByDescending(x => x.TransactionDate) .FirstOrDefault()?.Source?.Id }; return(View(payment)); }
public async Task <IActionResult> Edit(EditPaymentVm model) { var result = await GetApi().Payment.Save(new PaymentSaveOptions() { Id = model.Id, PayerId = model.PayerId, TransactionDate = model.TransactionDate, Amount = model.Amount, Description = model.Description, SourceId = model.SourceId }); if (!result.Success) { result.Errors.ForEach(x => { ModelState.AddModelError(x.PropertyName, x.ErrorMessage); }); return(View(model)); } return(RedirectToAction("Scheduled")); }