public async Task<ActionResult> Adjust(UserBalanceAdjust adjustment) { if (!ModelState.IsValid) return View(adjustment); var user = await _userManager.FindByIdAsync(adjustment.UserId); if (user == null) { ModelState.AddModelError("UserId", "Cannot find user"); return View(adjustment); } var result = _trnxService.AdjustBalance(user, adjustment.Amount, adjustment.Reason); if (!result.Success) { foreach (var err in result.Errors) ModelState.AddModelError("", err); return View(adjustment); } _uow.SaveChanges(); return RedirectToAction("Detail", "UserManagement", new { Id = adjustment.UserId }); }
public async Task<ActionResult> Adjust(int id) { var user = await _userManager.FindByIdAsync(id); if (user == null) return HttpNotFound(); var model = new UserBalanceAdjust() { UserId = user.Id, UserName = user.UserName, CurrentBalance = user.Money, }; return View(model); }