public async Task <IActionResult> addVehicle([FromBody] Vehicle vehicle) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _repo.Add <Vehicle>(vehicle); return(Ok(await _repo.SaveAll())); }
public async Task <IActionResult> addPlaza([FromBody] Plaza plaza) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _repo.Add <Plaza>(plaza); if (await _repo.SaveAll()) { return(Ok()); } return(BadRequest("Failed to Add plaza")); }
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); }
public async Task addLog(ChargeLog chargeLog) { _repo.Add(chargeLog); await _repo.SaveAll(); }