public IActionResult GetByCarId(int carId)
        {
            var result = _carImageService.GetByCarId(carId);

            if (result.Success)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
Example #2
0
        public ActionResult GetByCarId(int id)
        {
            var result = _carImageService.GetByCarId(id);

            if (result != null)
            {
                return(Ok(result));
            }

            return(BadRequest());
        }
 public IActionResult GetByCarId(int carId)
 {
     try
     {
         var result = _carImageService.GetByCarId(carId);
         return(Ok(result));
     }
     catch (Exception)
     {
         return(BadRequest("Bir hata meydana geldi"));
     }
 }
        public IDataResult <CarDetailAndImagesDto> GetCarDetailAndImagesDto(int carId)
        {
            var result      = _carDal.GetCarDetails();
            var imageResult = _carImageService.GetByCarId(carId);

            if (result == null || imageResult.Success == false)
            {
                return(new ErrorDataResult <CarDetailAndImagesDto>(Messages.ErrorCarMessage));
            }

            var carDetailAndImagesDto = new CarDetailAndImagesDto
            {
                Car       = result,
                CarImages = imageResult.Data
            };

            return(new SuccessDataResult <CarDetailAndImagesDto>(carDetailAndImagesDto, Messages.SuccessCarMessage));
        }
Example #5
0
        public IResult Delete(Car car)
        {
            IResult result = BusinessRules.Run(
                CheckIfCarIdIsNotExists(car.Id)
                );

            if (result != null)
            {
                return(result);
            }

            // This actions deletes the rentals and images of the car
            _rentalService.GetByCarId(car.Id).Data.ForEach(r => _rentalService.Delete(r));
            _carImageService.GetByCarId(car.Id).Data.ForEach(c => _carImageService.Delete(c));

            _carDal.Delete(car);
            return(new SuccessResult());
        }
Example #6
0
        public IActionResult GetCarDetails(int id)
        {
            List <IActionResult> file = new List <IActionResult>();
            string filePath           = _webHostEnvironment.WebRootPath + "\\Images\\";
            var    result             = _carImageService.GetByCarId(id);

            if (result.Success)
            {
                if (result.Data.Count == 0)
                {
                    file.Add(File(FileHelper.Get(filePath, "default.png"), "image/png"));
                }
                else
                {
                    foreach (var i in result.Data)
                    {
                        file.Add(File(FileHelper.Get(filePath, i.ImagePath), "image/jpeg"));
                    }
                }
                return(file[0]);
            }

            return(BadRequest(result.Message));
        }
Example #7
0
        public IActionResult GetCarImagesByCarId(int carId)
        {
            var results = _carImageService.GetByCarId(carId);

            return(Ok(results));
        }
 public IActionResult GetByCarId(int carId)
 {
     return(Ok(_carImageService.GetByCarId(carId)));
 }
Example #9
0
 //  [CacheRemoveAspect("ICarService.Get")]
 public IResult Delete(Car car)
 {
     _carDal.Delete(car);
     _carImageService.Delete(_carImageService.GetByCarId(car.Id).Data.Find(ci => ci.CarId == car.Id));
     return(new SuccessResult(Messages.CarDeleted));
 }
        public IActionResult GetCarImageByCarId(int id)
        {
            var result = _carImageService.GetByCarId(id);

            return(result.Success ? Ok(result) : BadRequest(result));
        }