public async Task AddAsync(ReservationDto obj) { var reservation = Reservation.FromDto(obj); var car = await _carService.GetByIdAsync(reservation.CarId); var carModel = await _carModelService.GetByIdAsync(car.CarModelid); var carCategory = await _carCategoryService.GetByIdAsync(carModel.CategoryId); reservation.DailyFee = carCategory.DailyFee; reservation.SetActive(); reservation.CalculateTotal(); await _repository.AddAsync(reservation); }
public async Task <ActionResult <CarCategoryDto> > GetById(Guid id) { try { if (id == Guid.Empty) { return(BadRequest("Id must be a valid Guid")); } return(await _carCategoryService.GetByIdAsync(id)); } catch (Exception e) { return(BadRequest(e)); } }