Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 public async Task <ActionResult <CarModelDto> > GetById(Guid id)
 {
     try
     {
         if (id == Guid.Empty)
         {
             return(BadRequest("Id must be a valid Guid"));
         }
         return(await _carModelService.GetByIdAsync(id));
     }
     catch (Exception e)
     {
         return(BadRequest(e));
     }
 }