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); }
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")); } }
public void Add(Rent rent) { _rentRepository.Add(rent); }
public Task <int> Add(Rent entity) { return(rentRepository.Add(entity)); }