public ShareCarService(IShareKeyRepository shareKeyRepository, ICarRepository carRepository,
                        IUserCarRepository userCarRepository)
 {
     _shareKeyRepository = shareKeyRepository;
     _carRepository      = carRepository;
     _userCarRepository  = userCarRepository;
 }
        private UserCar CheckAndGetUserCar(IUserCarRepository repository, long userCarId, string userId)
        {
            var userCar = repository.GetAll(false)
                          .Include(u => u.User)
                          .Include(u => u.Applications)
                          .FirstOrDefault(u => u.Id == userCarId);

            if (userCar == null)
            {
                throw new BusinessFaultException(BusinessLogicExceptionResources.UserCarNotFound);
            }
            if (userCar.User.ApplicationUser.Id != userId)
            {
                throw new BusinessFaultException(BusinessLogicExceptionResources.CarDoesNotBelongToUser);
            }
            return(userCar);
        }
Exemplo n.º 3
0
 public CarService(ICarRepository carRepository, IUserCarRepository userCarRepository, IMapper mapper)
 {
     _mapper            = mapper;
     _carRepository     = carRepository;
     _userCarRepository = userCarRepository;
 }