public HttpResponseMessage GetRentByCar(string car) { try { List <CarForRentModel> allCarsForRent = carForRentRepository.GetCarsForRentByCarNumber(car); return(Request.CreateResponse(HttpStatusCode.OK, allCarsForRent)); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors)); } }
public IActionResult GetRentByCar(string car) { try { List <CarForRentModel> allCarsForRent = carForRentRepository.GetCarsForRentByCarNumber(car); return(Ok(allCarsForRent)); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); return(StatusCode(StatusCodes.Status500InternalServerError, errors)); } }
//[BasicAuthentication] //[AutorizeByRole(AutorizeByRoleAttribute.roles.Admin)] public HttpResponseMessage GetCarsForRentByCarNumber(string carNumber) { try { HttpResponseMessage hrm = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(JsonConvert.SerializeObject(carForRentRepository.GetCarsForRentByCarNumber(carNumber))) }; return(hrm); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); HttpResponseMessage hr = new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(errors.ToString()) }; return(hr); } }