public async Task <bool> processTransaction(string transactionCode) { string[] codeArray = transactionCode.Split('/'); string tagNumber = codeArray[0]; string plazaId = codeArray[1]; double amount = 0; Vehicle vehicle = await _repo.getVehicleWithTag(tagNumber); Plaza plaza = await _repo.GetPlaza(Int32.Parse(plazaId)); switch (vehicle.VehicleType) { case "jeep": amount = 30 * plaza.Amount; break; case "car": amount = 20 * plaza.Amount; break; case "tricycle": amount = 10 * plaza.Amount; break; case "motorcycle": amount = 5 * plaza.Amount; break; case "trailer": amount = 50 * plaza.Amount; break; case "lorry": amount = 40 * plaza.Amount; break; } if (!(await chargeUserAccount(vehicle.VehicleOwnerId, amount))) { return(false); } await logTransaction(new ChargeLog { Amount = amount, VehicleId = vehicle.VehicleId, UserId = vehicle.VehicleOwnerId, PlazaId = plaza.PlazaId }); return(true); }
public async Task <IActionResult> getPlaza(int id) { var plazaRepo = await _repo.GetPlaza(id); return(Ok(plazaRepo)); }