public async Task <ActionResult> Edit(PaymentViewModel payment) { if (!ModelState.IsValid) { return(View(payment)); } try { await _paymentRepository.UpdateAsync(PaymentViewModel.FromPaymentViewModel(payment)); return(RedirectToAction(nameof(Index))); } catch { return(View(payment)); } }
public async Task <ActionResult> Create(PaymentViewModel paymentVM) { paymentVM.Id = System.Guid.NewGuid().ToString(); var payment = PaymentViewModel.FromPaymentViewModel(paymentVM); if (!ModelState.IsValid) { return(View(paymentVM)); } try { await _paymentRepository.AddAsync(payment); return(RedirectToAction(nameof(Index))); } catch (Exception e) { ModelState.AddModelError("", e.Message); return(View(paymentVM)); } }