public async Task <IActionResult> AddToWallet(string id, AddToWalletViewModel model) { if (id != model.Id) { return(NotFound()); } if (ModelState.IsValid) { var employee = await _context.Employees.SingleOrDefaultAsync(m => m.Id == model.Id); if (employee == null) { return(NotFound()); } if (employee.Wallet + model.AddToWallet >= 0) { employee.Wallet += model.AddToWallet; _context.Update(employee); await _context.SaveChangesAsync(); } return(RedirectToAction("Index")); } // If we got this far, something failed, redisplay form return(View(model)); }
public async Task <IActionResult> AddToWallet(string id) { if (id == null) { return(NotFound()); } Employee employee = await _userManager.FindByIdAsync(id); if (employee == null) { return(NotFound()); } AddToWalletViewModel model = new AddToWalletViewModel { Id = employee.Id, FirstName = employee.FirstName, LastName = employee.LastName, UserName = employee.UserName, Email = employee.Email, Wallet = employee.Wallet, AddToWallet = (decimal)0.00 }; return(View(model)); }