public void GetBikeByIdTest() { _bikeService.AddBike("1", 0.2m); var bike = _bikeService.GetBikeById("1"); Assert.AreEqual("1", bike.Id); Assert.AreEqual(0.2m, bike.PricePerMinute); }
public void StartRent(string id) { if (string.IsNullOrEmpty(id)) { throw new BikeIdNullException(); } var bike = _service.GetBikeById(id); _rentedBikeService.StartRentOfBike(bike); }
public IActionResult GetBikeById(int id) { try { var bike = _bikeService.GetBikeById(id); return(Ok(bike)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public IActionResult Edit(int id) { var res = _bikeService.GetBikeById(id); if (res == null) { return(NotFound()); } ChangeBikeViewModel model = new ChangeBikeViewModel { Id = res.Id, Name = res.Name, MaxSpeed = res.MaxSpeed, TypeEngine = res.TypeEngine, Power = res.Power, Fuel = res.Fuel, Description = res.Description, Price = res.Price }; return(View(model)); }
public IActionResult GetBike(int id) { return(Ok(_bikeService.GetBikeById(id))); }