Exemplo n.º 1
0
        public IActionResult Checkout(long id, string customerName)
        {
            var bikeViewModel = new BikeViewModel
            {
                Bike = new Bike
                {
                    id           = id,
                    CustomerName = customerName,
                    DateModified = DateTime.Now,
                    CheckOutTime = DateTime.Now,
                    CheckInTime  = null
                }
            };

            if (id == 0)
            {
                bikeViewModel.Bike.id = _bikeService.GetLastId();
                _bikeService.AddBike(bikeViewModel.Bike);
            }
            else
            {
                _bikeService.UpdateBike(bikeViewModel.Bike);
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public void Execute(AddBikeCommandContext commandContext)
        {
            if (!_bikeNameVerifier.IsFree(commandContext.Name))
            {
                throw new InvalidOperationException("Bike with same name already exists");
            }

            commandContext.CreatedBike = _bikeService.AddBike(commandContext.Name, commandContext.HourCost, commandContext.Cost);

            _bikeService.MoveBike(commandContext.CreatedBike, commandContext.RentPoint);
        }
Exemplo n.º 3
0
 public void Execute(AddNewBikeCommandContext commandContext)
 {
     _bikeService.AddBike(commandContext.Name, commandContext.HourCost);
 }
Exemplo n.º 4
0
 public void AddBikeTest()
 {
     _bikeService.AddBike("1", 0.2m);
 }