public IActionResult AddCar(CarModel carModel)
        {
            try
            {
                if (carModel == null)
                {
                    return(BadRequest("Data is null."));
                }
                if (!ModelState.IsValid)
                {
                    Errors errors = ErrorsHelper.GetErrors(ModelState);
                    return(BadRequest(errors));
                }

                CarModel addedCar = carsRepository.AddCar(carModel);
                return(StatusCode(StatusCodes.Status201Created, addedCar));
            }
            catch (Exception ex)
            {
                Errors errors = ErrorsHelper.GetErrors(ex);
                return(StatusCode(StatusCodes.Status500InternalServerError, errors));
            }
        }
        public IActionResult UpdateCar(string number, CarModel carModel)
        {
            try
            {
                if (carModel == null)
                {
                    return(BadRequest("Data is null."));
                }
                if (!ModelState.IsValid)
                {
                    Errors errors = ErrorsHelper.GetErrors(ModelState);
                    return(BadRequest(errors));
                }

                carModel.carNumber = number;
                CarModel updatedCar = carsRepository.UpdateCar(carModel);
                return(Ok(updatedCar));
            }
            catch (Exception ex)
            {
                Errors errors = ErrorsHelper.GetErrors(ex);
                return(StatusCode(StatusCodes.Status500InternalServerError, errors));
            }
        }
 public IActionResult DeleteCar(string number)
 {
     try
     {
         string carImage = carsRepository.DeleteCar(number);
         carImage = carImage.Trim();
         CarPictureModel carsPictureModel = carsRepository.GetNumberOfCarWithImage(carImage);
         if (carsPictureModel.numberOfCars == 0)
         {
             string filePath = environment.WebRootPath + "/images/cars/" + carImage;
             var    file     = new FileInfo(filePath);
             if (file.Exists)
             {
                 file.Delete();
             }
         }
         return(NoContent());
     }
     catch (Exception ex)
     {
         Errors errors = ErrorsHelper.GetErrors(ex);
         return(StatusCode(StatusCodes.Status500InternalServerError, errors));
     }
 }
        public IActionResult UpdateUser(string id, UserModel userModel)
        {
            try
            {
                if (userModel == null)
                {
                    return(BadRequest("Data is null."));
                }
                if (!ModelState.IsValid)
                {
                    Errors errors = ErrorsHelper.GetErrors(ModelState);
                    return(BadRequest(errors));
                }

                userModel.userID = id;
                UserModel updatedUser = usersRepository.UpdateUser(userModel);
                return(Ok(updatedUser));
            }
            catch (Exception ex)
            {
                Errors errors = ErrorsHelper.GetErrors(ex);
                return(StatusCode(StatusCodes.Status500InternalServerError, errors));
            }
        }