public async Task <IActionResult> makeAdmin(int id) { User userRepo = await _repo.getUser(id); if (userRepo == null) { return(BadRequest("User not found")); } userRepo.Role = "admin"; _repo.Update <User>(userRepo); return(Ok(await _repo.SaveAll())); }
private async Task <bool> chargeUserAccount(int userId, double amount) { User userToCharge = await _repo.getUser(userId); userToCharge.AccountBalance -= amount; _repo.Update <User>(userToCharge); if (await _repo.SaveAll()) { if (userToCharge.AccountBalance < 0) { _sms.sendMessage($" Insufficient fund, your account balance is below zero, please Recharge as soon as possible {amount}", $"{userToCharge.PhoneNumber}"); return(false); } else { _sms.sendMessage($" THANK YOU. your toll account was successfully charged {amount}", $"{userToCharge.PhoneNumber}"); return(true); } } _sms.sendMessage($" An error occured charging your account please pay {amount}, manually", $"{userToCharge.PhoneNumber}"); return(false); }