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

                string id = User.Identity.Name;
                carForRentModel.userID = id;
                CarForRentModel addedCarForRent = carForRentRepository.AddCarForRent(carForRentModel);
                return(StatusCode(StatusCodes.Status201Created, addedCarForRent));
            }
            catch (Exception ex)
            {
                Errors errors = ErrorsHelper.GetErrors(ex);
                return(StatusCode(StatusCodes.Status500InternalServerError, errors));
            }
        }
 //[BasicAuthentication]
 //[AutorizeByRole(AutorizeByRoleAttribute.roles.Admin)]
 public HttpResponseMessage AddCarForRent(CarForRentModel carForRentModel, string userName)
 {
     try
     {
         HttpResponseMessage hrm = new HttpResponseMessage(HttpStatusCode.Created)
         {
             Content = new StringContent(JsonConvert.SerializeObject(carForRentRepository.AddCarForRent(carForRentModel)))
         };
         return(hrm);
     }
     catch (Exception ex)
     {
         Errors errors          = ErrorsHelper.GetErrors(ex);
         HttpResponseMessage hr = new HttpResponseMessage(HttpStatusCode.InternalServerError)
         {
             Content = new StringContent(errors.ToString())
         };
         return(hr);
     }
 }
 public HttpResponseMessage AddCarForRent(CarForRentModel carForRentModel)
 {
     try
     {
         if (carForRentModel == null)
         {
             return(Request.CreateResponse(HttpStatusCode.BadRequest, "Data is null."));
         }
         if (!ModelState.IsValid)
         {
             Errors errors = ErrorsHelper.GetErrors(ModelState);
             return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
         }
         CarForRentModel addedCarForRent = carForRentRepository.AddCarForRent(carForRentModel);
         return(Request.CreateResponse(HttpStatusCode.Created, addedCarForRent));
     }
     catch (Exception ex)
     {
         Errors errors = ErrorsHelper.GetErrors(ex);
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors));
     }
 }