예제 #1
0
        public override Rent Post(Rent rent)
        {
            switch (rent.TypeOfRent.ToString())
            {
            case "Normal":
                rent.Location = calcNormal.Calculate(rent);
                break;

            case "Promocional":
                rent.Location = calcPromotional.Calculate(rent);
                break;

            case "ClienteNovo":
                rent.Location = calcFirstLocation.Calculate(rent);
                break;
            }

            Vehicle vehicle = _vehicleRepository.GetById(rent.VehicleId);

            vehicle.isRented = true;

            _vehicleRepository.Update(vehicle);
            _rentRepository.Add(rent);

            return(rent);
        }
예제 #2
0
        public async Task <IActionResult> Post(Rent rent)
        {
            try
            {
                var response = await _repository.Add(rent);

                if (response != 0)
                {
                    return(Ok("Added successfully"));
                }
                else
                {
                    return(BadRequest("An error ocurred, contact IT Staff"));
                }
            }
            catch (Exception e)
            {
                //Log error
                Log.Error(e.Message);
                Log.Error(e.StackTrace);
                return(BadRequest("An error ocurred, contact IT Staff"));
            }
        }
예제 #3
0
 public void Add(Rent rent)
 {
     _rentRepository.Add(rent);
 }
예제 #4
0
 public Task <int> Add(Rent entity)
 {
     return(rentRepository.Add(entity));
 }