public async Task<ActionResult> Create(PaymentMethodViewModel method) { if (ModelState.IsValid) { await _paymentMethodService.CreateAsync(new PaymentMethod() {Name = method.Name}); return RedirectToAction("Index"); } return View(method); }
public async Task<ActionResult> Edit(int id) { var paymentMethod = await _paymentMethodService.GetByIdAsync(id); if (paymentMethod == null) { return HttpNotFound("PaymentMethod not found"); } var paymentMethodViewModel = new PaymentMethodViewModel() { Id = paymentMethod.Id, Name = paymentMethod.Name }; return View(paymentMethodViewModel); }
public async Task<ActionResult> Edit(PaymentMethodViewModel method) { if (ModelState.IsValid) { var paymentMethod = await _paymentMethodService.GetByIdAsync(method.Id); if (paymentMethod == null) { return HttpNotFound("PaymentMethod not found"); } paymentMethod.Name = method.Name; await _paymentMethodService.UpdateAsync(paymentMethod); return RedirectToAction("Index"); } return View(method); }